You should check on local code requirements before building your handrail. As with any home construction, building to code is necessary both for legal reasons as well as safety. Building code may determine the height requirements of the handrail, as well as the minimum space necessary between the spindles.
Use pressure treated lumber for the handrail construction. Posts that are 4 inches by 4 inches are sufficient for attaching wooden rails to your deck. Either use pre-notched handrail posts or notch them yourself before installing. Notches should be 1 1/2-inch deep and 7 inches long in a 47-inch post. You'll want to keep the posts positioned equally across the deck with no more than 6 feet of space between the posts as measured from post centers. Tack your posts to the deck frame and then drill two 1/2-inch holes through the post and the frame. If you offset the holes, it will provide better stability. Using galvanized or stainless steel, hex the bolts with a washer on both sides. Bolt the posts to the frame.
Measure the distance between every two posts using post bottoms, then cut a board to 2 by 6 inches in length. This board will form your top rail. The bottom rail is formed with a 2 inches by 4 inches board. Place the top rail piece horizontally with the bottom piece of the handrail section placed horizontally with a bevel cut at the top to help shed water. Cut the 2 inches by 2 inches spindles at the same angle so when nailed in place they don't twist. The actual length of the spindles is determined by the height you desire your bottom rail to be from the deck floor.
Pre-drill two holes at the top end of the spindle, the first hole 1 inch from the end, the second 3 inches from the end. Secure the spindles to the top piece, flush with the top edge of the 2 inches by 6 inches board at the desired distance apart, though no greater than 4 inches between spindles. Use a single wood deck screw at the far end of the spindle to secure it, and then connect to the lower rail using another deck screw. Once all the spindles are connected, secure with a second screw at the top.
Once you have connected all the spindles to the top rail and bottom, you can nail the entire hand rail unit into place between your installed rail posts. When installed, cap the rail with another horizontal piece of wood to finish it off. Place small kiddie blocks beneath the bottom rail piece, secured with deck screws.
Kiddie blocks are small blocks of wood attached between the deck and the rail that provide extra strength to the handrail. They also prevent breaking from pressure placed on the bottom rail--for example from example children standing on the rail. They also help to keep the rail rigid as the wood tries to warp from the elements.
When you have constructed the handrail, treat it with a sealant to protect the wood from the elements. Practice safety when assembling the rail by wearing gloves, goggles and a dust mask.