
There are really only 3 pieces inside the lock, the base of the shackle, a bent piece of metal, and a spring that pushes the shackle up when it is unlocked.
The next image shows the grooving on the shackle and a side view of the piece of bent metal.

The metal piece clamps onto the shackle, and because it clamps inside the middle groove, the shackle is locked in place.
The key has a wide section at the end and narrow sections around it:

The narrow sections allow it to spin freely among the otherwise hindering protrusions above and below where the piece of bent metal rests in the housing, and the wide section interacts with the piece of bent metal.
When the key is fully inserted, the wide section at the end of it lies in between the piece of bent metal. When it is twisted, the piece of metal is forced apart- freeing the spring-loaded shackle.

Be Safe
-CD