This video does a good job of visualizing the intricate mechanisms inside an internally-geared bicycle hub.

Edit for phrasing.