The patella (kneecap) is a 'sesamoid bone'. A sesamoid bone is a bone that develops in a muscle tendon, rather than being attached by ligaments to another bone. The tendon in which the patella develops is the tendon of the quadriceps muscle, the big muscle that makes up the bulk of your 'lap'.
The quadriceps muscle at its upper end is actually comprised of four heads- hence the name quadri-ceps, and attach to the hip and the femur bone. It is at the lower end of the quadriceps muscle(s) that the four parts fuse into a common tendon, a strong and fibrous structure that attaches to the tibia bone about three centimetres below the bottom of the patella. It is in this tendon - the quadriceps tendon - that the patella develops.
This illustration shows just the one head of the quadriceps - the most superficial of the four muscles, and which is called the rectus femoris. You can see the sesamoid patellar bone within its tendon.
The place on the tibia bone where the tendon attaches is called the tibial tubercle.
The back of the patella is covered with smooth, shiny white joint cartilage and is in contact with the cartilage of the femur within a groove known as the 'trochlear groove'. This contact area between the back of the patella and the groove of the femur is called the 'patello-femoral' joint.
The red circles in these two drawings of the bones show two different views of the patellofemoral joint.
In the left of the two images one is looking at the bones from the front of the bent knee. In the right image one is looking at the straightened knee from the side.
The flattened areas at the back of the patella are called the 'facets'.