Abstract Photonic integrated circuits (PICs) represent a promising technology for the much-needed medical devices of today. Their primary advantage lies in their ability to integrate multiple functions onto a single chip, thereby reducing the complexity, size, maintenance requirements, and costs. When applied to optical coherence tomography (OCT), the leading tool for state-of-the-art ophthalmic diagnosis, PICs have the potential to increase accessibility, especially in scenarios, where size, weight, or costs are limiting factors. In this paper, we present a PIC-based CMOS-compatible spectrometer for spectral domain OCT with an unprecedented level of integration. To achieve this, we co-integrated a 512-channel arrayed waveguide grating with electronics. We successfully addressed the challenge of establishing a connection from the optical waveguides to the photodiodes monolithically co-integrated on the chip with minimal losses achieving a coupling efficiency of 70%. With this fully integrated PIC-based spectrometer interfaced to a spectral domain OCT system, we reached a sensitivity of 92dB at an imaging speed of 55kHz, with a 6dB signal roll-off occurring at 2mm. We successfully applied this innovative technology to obtain 3D in vivo tomograms of zebrafish larvae and human skin. This ground-breaking fully integrated spectrometer represents a significant step towards a miniaturised, cost-effective, and maintenance-free OCT system.