Neural representations of head direction (HD) have been discovered in many species. Theoretical work has proposed that the dynamics associated with these representations are generated, maintained, and updated by recurrent network structures called ring attractors. We evaluated this theorized structure-function relationship by performing electron-microscopy-based circuit reconstruction and RNA profiling of identified cell types in the HD system of Drosophila melanogaster. We identified motifs that have been hypothesized to maintain the HD representation in darkness, update it when the animal turns, and tether it to visual cues. Functional studies provided support for the proposed roles of individual excitatory or inhibitory circuit elements in shaping activity. We also discovered recurrent connections between neuronal arbors with mixed pre- and postsynaptic specializations. Our results confirm that the Drosophila HD network contains the core components of a ring attractor while also revealing unpredicted structural features that might enhance the network's computational power.