The heart is a muscle that has four chambers. I find it easier to think of it as two separate pumps (right and left) based on it's function. There are the right atrium (upper chamber) and right ventricle (lower chamber) and the same on the other side (left atrium and ventricle). Blood comes into the heart via the superior vena cava (a big vein) and starts filling the right side of the heart while it's relaxed. Once both chambers of the right side of the heart (it's also happening on the left side simultaneously) are filled with blood, the atria are electrically stimulated and they contract. There is a one way valve separating the atria and the ventricles. The blood is forced into from the atria into the ventricles, expanding them. Muscles, when rapidly stretched, contract (Starling's Law). Just as the ventricle starts to contract, because of the stretching, it is also stimulated electrically. The ventricle then forcefully contracts ejecting the blood into the pulmonary artery (in the case of the right ventricle) which is again separated by a one way valve. Blood is then moved to the lungs where carbon dioxide is exchanged for oxygen. This is all that the right side of the heart does, receive blood from the body and pump it to the lungs. Blood returns to the heart via the pulmonary vein. It enters into the left atrium and begins to fill the left side of the heart. Once the chambers of the heart are full the process of contractions starts over. This time the blood is forced past another one way valve into the aorta, the largest of all arteries in the body. From there the blood is distributed to the rest of the body. That is the job of the left side of the heart, blood distribution to the body. The right side of the heart is smaller (the muscle tissue) because it does not require as much force to pump the blood to the lungs. Clear as mud?
In the illustration below it shows all of the major parts of the heart and it has arrows to indicate the flow of blood. The blue blood vessels are connected to the right side of the heart (it carries less oxygenated blood headed for the lungs). The ones in red are connected to the left side of the heart and are oxygen rich.
Now that we understand the physical layout of the heart I'll briefly touch on the electrical system. Cardiac cells are unique in that they all have the ability to produce an electrical charge (automaticity). If they were to do this at random the heart would fail to properly contract and the result would be an absence of blood flow. So to control this there is a very organized system in place. It starts in the right atrium with the sinoatrial node (sinus node or simply SA node). The electrical impulse starts there and goes through the atria causing them to contract. It then hits the atrioventricular node (AV node) which slow down the electrical impulse for a moment before sending it down the Bundle of His to the ventricles causing the ventricles to contract. The amazing part is that if one of the sections of the electrical system fails, the other sections of the conduction system itself act as a back up. While most heart beats are started by the SA node, if it fails to work, then other parts of the heart, such as the AV node, can still do the job (although with some draw backs).
Heart Rhythms Part 1: Basic Anatomy
Heart Rhythms Part 2: Sinus Rhythms
Heart Rhythms Part 3: Junctional Rhythms
Heart Rhythms Part 4: Ventricular Rhythms
Heart Rhythms Part 5: Premature Beats
Heart Rhythms Part 6: Heart Blocks