# ctrdecomp/ctr_sdk architecture

> Architecture diagram of the GitHub repository ctrdecomp/ctr_sdk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ctrdecomp/ctr_sdk
- Repository: https://github.com/ctrdecomp/ctr_sdk

## Overview

CTR_SDK is a decompilation of Nintendo 3DS’s standard SDK: a collection of C/C++ APIs for applications to use device services, graphics, media, and runtime facilities. The principal workflow is an application calling an SDK module to perform a platform task, with service-backed modules communicating with the device or OS. The graph retains major README capabilities, including input, storage, rendering, audio, configuration, and dynamic loading. Source excerpts are limited, so links between modules are shown only where sampled code supports them; other module relationships are intentionally omitted.

Main entry points: [`sources/libraries/snd/CTR/snd_MasterManager.cpp`](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/snd/CTR/snd_MasterManager.cpp) (Sound playback), [`sources/libraries/cfg/CTR/cfg_Api.cpp`](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/cfg/CTR/cfg_Api.cpp) (Device configuration), [`sources/libraries/hid/CTR/hid_Api.cpp`](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/hid/CTR/hid_Api.cpp) (Input devices), [`sources/libraries/camera/camera_Api.cpp`](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/camera/camera_Api.cpp) (Camera)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Device Services"]
  node_applet["App lifecycle<br/>[applet_API.cpp]"]
  node_cfg["Device configuration<br/>[cfg_Api.cpp]"]
  node_hid["Input devices<br/>[hid_Api.cpp]"]
  node_camera["Camera<br/>[camera_Api.cpp]"]
  node_cec["StreetPass<br/>[cec_Api.h]"]
  node_ndm["Network manager<br/>[ndm_Setup.cpp]"]
  node_ptm["Power and RTC<br/>[ptm_Api.cpp]"]
end

subgraph group_graphics["Graphics"]
  node_gx["Graphics API<br/>[gx.h]"]
  node_gles["GLES2 renderer<br/>[systemmanager.c]"]
  node_gr["Geometry helpers<br/>[gr_Utility.cpp]"]
  node_gxlow["GPU backend"]
end

subgraph group_media["Media and Files"]
  node_fs["File services<br/>[fs_Api.cpp]"]
  node_fslow["File I/O backend"]
  node_font["Font rendering<br/>[font_ResFont.cpp]"]
  node_cx["Decompression"]
  node_snd["Sound playback"]
  node_dsp["DSP audio<br/>[dsp_Api.cpp]"]
end

subgraph group_runtime["Runtime"]
  node_os["OS facilities<br/>[os_Initialize.cpp]"]
  node_fnd["Memory and containers<br/>[fnd_HeapBase.cpp]"]
  node_crypto["Hash functions<br/>[crypto_Sha1.cpp]"]
  node_ro["Dynamic loading"]
  node_srv["Service access<br/>[srv_Api.cpp]"]
end

node_app(("3DS application"))
node_device{{"3DS device services"}}

node_app -->|"uses lifecycle"| node_applet
node_app -->|"reads settings"| node_cfg
node_app -->|"reads input"| node_hid
node_app -->|"captures images"| node_camera
node_app -->|"exchanges messages"| node_cec
node_app -->|"controls networking"| node_ndm
node_app -->|"reads device state"| node_ptm
node_app -->|"requests graphics"| node_gx
node_app -->|"renders with GLES2"| node_gles
node_app -->|"uses geometry"| node_gr
node_app -->|"reads and writes files"| node_fs
node_app -->|"draws text"| node_font
node_app -->|"decompresses data"| node_cx
node_app -->|"plays audio"| node_snd
node_app -->|"uses OS facilities"| node_os
node_app -->|"allocates memory"| node_fnd
node_app -->|"hashes data"| node_crypto
node_app -->|"loads modules"| node_ro
node_app -->|"accesses services"| node_srv
node_snd -->|"reads sound settings"| node_cfg
node_gx -.->|"uses GPU backend"| node_gxlow
node_gles -.->|"dispatches GPU work"| node_gxlow
node_fs -.->|"uses I/O backend"| node_fslow
node_snd -.->|"uses DSP audio"| node_dsp
node_cfg -.->|"communicates with"| node_device
node_hid -.->|"reads device state"| node_device
node_camera -.->|"controls camera"| node_device
node_cec -.->|"uses device service"| node_device
node_ndm -.->|"controls networking"| node_device
node_ptm -.->|"reads device state"| node_device
node_srv -.->|"connects services"| node_device

click node_applet "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/applet/CTR/applet_API.cpp"
click node_cfg "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/cfg/CTR/cfg_Api.cpp"
click node_hid "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/hid/CTR/hid_Api.cpp"
click node_camera "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/camera/camera_Api.cpp"
click node_cec "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/include/nn/cec/CTR/cec_Api.h"
click node_ndm "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ndm/ndm_Setup.cpp"
click node_ptm "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ptm/CTR/MPCore/ptm_Api.cpp"
click node_gx "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/include/nn/gx.h"
click node_gles "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gles2/systemmanager.c"
click node_gr "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gr/gr_Utility.cpp"
click node_gxlow "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gxlow/CTR/gxlow_Management.cpp"
click node_fs "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fs/CTR/MPCore/fs_Api.cpp"
click node_fslow "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fslow/fslow_QueryOptimalBucketCount.cpp"
click node_font "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/font/font_ResFont.cpp"
click node_cx "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/cx/cx_Uncompression.cpp"
click node_snd "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/snd/CTR/snd_MasterManager.cpp"
click node_dsp "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/dsp/CTR/dsp_Api.cpp"
click node_os "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/os/os_Initialize.cpp"
click node_fnd "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fnd/fnd_HeapBase.cpp"
click node_crypto "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/crypto/Hash/crypto_Sha1.cpp"
click node_ro "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ro/ro_DynamicLoader.cpp"
click node_srv "https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/srv/srv_Api.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_applet,node_cfg,node_hid,node_camera,node_cec,node_ndm,node_ptm toneBlue
class node_gx,node_gles,node_gr,node_gxlow toneAmber
class node_fs,node_fslow,node_font,node_cx,node_snd,node_dsp toneMint
class node_os,node_fnd,node_crypto,node_ro,node_srv toneRose
class node_app,node_device toneIndigo
```

## Components

### Device Services

- [App lifecycle](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/applet/CTR/applet_API.cpp): `sources/libraries/applet/CTR/applet_API.cpp`
- [Device configuration](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/cfg/CTR/cfg_Api.cpp): `sources/libraries/cfg/CTR/cfg_Api.cpp`
- [Input devices](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/hid/CTR/hid_Api.cpp): `sources/libraries/hid/CTR/hid_Api.cpp`
- [Camera](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/camera/camera_Api.cpp): `sources/libraries/camera/camera_Api.cpp`
- [StreetPass](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/include/nn/cec/CTR/cec_Api.h): `include/nn/cec/CTR/cec_Api.h`
- [Network manager](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ndm/ndm_Setup.cpp): `sources/libraries/ndm/ndm_Setup.cpp`
- [Power and RTC](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ptm/CTR/MPCore/ptm_Api.cpp): `sources/libraries/ptm/CTR/MPCore/ptm_Api.cpp`

### Graphics

- [Graphics API](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/include/nn/gx.h): `include/nn/gx.h`
- [GLES2 renderer](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gles2/systemmanager.c): `sources/libraries/gles2/systemmanager.c`
- [Geometry helpers](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gr/gr_Utility.cpp): `sources/libraries/gr/gr_Utility.cpp`
- [GPU backend](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/gxlow/CTR/gxlow_Management.cpp): `sources/libraries/gxlow/CTR/gxlow_Management.cpp`

### Media and Files

- [File services](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fs/CTR/MPCore/fs_Api.cpp): `sources/libraries/fs/CTR/MPCore/fs_Api.cpp`
- [File I/O backend](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fslow/fslow_QueryOptimalBucketCount.cpp): `sources/libraries/fslow/fslow_QueryOptimalBucketCount.cpp`
- [Font rendering](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/font/font_ResFont.cpp): `sources/libraries/font/font_ResFont.cpp`
- [Decompression](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/cx/cx_Uncompression.cpp): `sources/libraries/cx/cx_Uncompression.cpp`
- [Sound playback](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/snd/CTR/snd_MasterManager.cpp): `sources/libraries/snd/CTR/snd_MasterManager.cpp`
- [DSP audio](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/dsp/CTR/dsp_Api.cpp): `sources/libraries/dsp/CTR/dsp_Api.cpp`

### Runtime

- [OS facilities](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/os/os_Initialize.cpp): `sources/libraries/os/os_Initialize.cpp`
- [Memory and containers](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/fnd/fnd_HeapBase.cpp): `sources/libraries/fnd/fnd_HeapBase.cpp`
- [Hash functions](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/crypto/Hash/crypto_Sha1.cpp): `sources/libraries/crypto/Hash/crypto_Sha1.cpp`
- [Dynamic loading](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/ro/ro_DynamicLoader.cpp): `sources/libraries/ro/ro_DynamicLoader.cpp`
- [Service access](https://github.com/ctrdecomp/ctr_sdk/blob/SDK_4_X_X/sources/libraries/srv/srv_Api.cpp): `sources/libraries/srv/srv_Api.cpp`

### Other components

- **3DS application**
- **3DS device services**

## Connections

- 3DS application → App lifecycle: uses lifecycle
- 3DS application → Device configuration: reads settings
- 3DS application → Input devices: reads input
- 3DS application → Camera: captures images
- 3DS application → StreetPass: exchanges messages
- 3DS application → Network manager: controls networking
- 3DS application → Power and RTC: reads device state
- 3DS application → Graphics API: requests graphics
- 3DS application → GLES2 renderer: renders with GLES2
- 3DS application → Geometry helpers: uses geometry
- 3DS application → File services: reads and writes files
- 3DS application → Font rendering: draws text
- 3DS application → Decompression: decompresses data
- 3DS application → Sound playback: plays audio
- 3DS application → OS facilities: uses OS facilities
- 3DS application → Memory and containers: allocates memory
- 3DS application → Hash functions: hashes data
- 3DS application → Dynamic loading: loads modules
- 3DS application → Service access: accesses services
- Sound playback → Device configuration: reads sound settings
- Graphics API → GPU backend: uses GPU backend
- GLES2 renderer → GPU backend: dispatches GPU work
- File services → File I/O backend: uses I/O backend
- Sound playback → DSP audio: uses DSP audio
- Device configuration → 3DS device services: communicates with
- Input devices → 3DS device services: reads device state
- Camera → 3DS device services: controls camera
- StreetPass → 3DS device services: uses device service
- Network manager → 3DS device services: controls networking
- Power and RTC → 3DS device services: reads device state
- Service access → 3DS device services: connects services
