A pergola is a structure built to provide overhead shade. It is usually supported on four sides by vertical posts that hold in place a lattice of wooden members. Some pergolas are attached to the house at one side with a ledger board. If you plan to do this, make sure you take all the same precautions to maintain a watertight connection using flashing and caulking. The sizes of the overhead members can vary but the lowest boards in the assembly will be the heaviest. Beams attached to posts will support one or more layers of cross members. The spacing and size of these members or louvers will dictate the amount of sunlight that is allowed to penetrate and the visual mass of the structure. Sometimes vines are trained to grow through the latticework to provide a lush natural canopy.
For pergolas and other overhead structures, they are certainly subject to building codes. While intended only for shade, these structures often support hanging swings. Depending on the design, slats overhead intended for shade, may be close enough to support bridging snow. Due to the structure of some snowflakes, snow is able to bridge over gaps as big as 4 inches or more. Snow piling up on a pergola likens it to that of a roof. Even without snow bridging possibilities, many building authorities will assign a minimum 20 psf live load for the structure to support.
It is very important to properly attach pergola posts when installing a pergola over a deck. The main concern is how the structure will react under high wind conditions. Most deck builders bolt pergola support posts to the frame of the deck using (2) 1/2"x6" lag screws with washers per post. This technique is the same as attaching a rail post. Pergolas are top heavy and can sway in the wind without lateral bracing and can act experience strong uplift forces as the pergola acts as a sail. Attaching sections of rail in between pergola posts will strengthen the pergola. Installing 45 degree bracing in between the post and header beam will also increase stability. Using 6x6's for support posts will further strengthen the structure. Deck Lok brackets are an option for extremely windy areas and hurricane zones.