# ctrdecomp/sead architecture

> Architecture diagram of the GitHub repository ctrdecomp/sead, 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/sead
- Repository: https://github.com/ctrdecomp/sead

## Overview

sead is a decompiled 3DS C++ runtime library for first-party Nintendo games, intended to recreate the original library and enable interoperability. Its broad runtime supports game/framework tasks, input, graphics, file and resource handling, and foundational utilities. A visible workflow is the framework’s task-oriented runtime, with controller management updating devices and controllers and CTR controllers translating HID state into game-facing input. The README documents additional capabilities not represented in sampled source; those are shown as subsystems without speculative call links. Controller wiring is grounded in sampled code; other internals are summarized from the tree and README.

Main entry points: [`include/controller/seadControllerMgr.h`](https://github.com/ctrdecomp/sead/blob/master/include/controller/seadControllerMgr.h) (Controller manager), [`modules/src/controller/ctr/seadCtrController.cpp`](https://github.com/ctrdecomp/sead/blob/master/modules/src/controller/ctr/seadCtrController.cpp) (CTR controller), [`include/resource/seadResourceMgr.h`](https://github.com/ctrdecomp/sead/blob/master/include/resource/seadResourceMgr.h) (Resource loading), [`include/framework/seadGameFramework.h`](https://github.com/ctrdecomp/sead/blob/master/include/framework/seadGameFramework.h) (Framework and tasks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_framework["Framework and tasks"]
  node_taskmgr["Task manager<br/>[seadTaskMgr.h]"]
  node_controller_mgr["Controller manager"]
  node_controller["Controller state"]
  node_ctr_controller["CTR controller"]
  node_hid_device["CTR HID device"]
  node_graphics["Graphics and rendering<br/>[seadGraphics.h]"]
end

subgraph group_io["I/O and Resources"]
  node_filedevice["File devices"]
  node_streams["Stream I/O<br/>[seadStream.h]"]
  node_resources["Resource loading<br/>[seadResourceMgr.h]"]
  node_decompression["SZS decompression"]
  node_message["Message Studio<br/>[seadMessageSet.h]"]
end

subgraph group_platform["Platform Services"]
  node_hostio["Host I/O<br/>[seadHostIOServer.h]"]
  node_debug["Debug utilities<br/>[seadStackTrace.h]"]
  node_threads["Thread utilities<br/>[seadThread.h]"]
end

subgraph group_foundation["Core Facilities"]
  node_math["Math and geometry<br/>[seadVector.h]"]
  node_heaps["Heap management<br/>[seadHeapMgr.h]"]
  node_containers["Containers<br/>[seadBuffer.h]"]
  node_primitives["Strings and primitives<br/>[seadSafeString.h]"]
  node_codec["Encoding and CRC<br/>[seadBase64.h]"]
  node_random_time["Random and time<br/>[seadRandom.h]"]
end

node_game(("Game client"))

node_game -->|"uses runtime"| node_framework
node_framework -->|"manages tasks"| node_taskmgr
node_game -->|"uses input"| node_controller_mgr
node_controller_mgr -->|"calculates device"| node_hid_device
node_controller_mgr -->|"calculates controller"| node_ctr_controller
node_ctr_controller -->|"reads HID state"| node_hid_device
node_ctr_controller -->|"updates input state"| node_controller
node_game -->|"uses graphics"| node_graphics
node_game -->|"loads resources"| node_resources
node_resources -->|"decompresses data"| node_decompression
node_resources -->|"uses file access"| node_filedevice
node_streams -->|"streams file data"| node_filedevice

click node_framework "https://github.com/ctrdecomp/sead/blob/master/include/framework/seadGameFramework.h"
click node_taskmgr "https://github.com/ctrdecomp/sead/blob/master/include/framework/seadTaskMgr.h"
click node_controller_mgr "https://github.com/ctrdecomp/sead/blob/master/include/controller/seadControllerMgr.h"
click node_controller "https://github.com/ctrdecomp/sead/blob/master/include/controller/seadControllerBase.h"
click node_ctr_controller "https://github.com/ctrdecomp/sead/blob/master/modules/src/controller/ctr/seadCtrController.cpp"
click node_hid_device "https://github.com/ctrdecomp/sead/blob/master/include/controller/ctr/seadCtrHidDeviceCtr.h"
click node_graphics "https://github.com/ctrdecomp/sead/blob/master/include/gfx/seadGraphics.h"
click node_math "https://github.com/ctrdecomp/sead/blob/master/include/math/seadVector.h"
click node_filedevice "https://github.com/ctrdecomp/sead/blob/master/include/filedevice/seadFileDeviceMgr.h"
click node_streams "https://github.com/ctrdecomp/sead/blob/master/include/stream/seadStream.h"
click node_resources "https://github.com/ctrdecomp/sead/blob/master/include/resource/seadResourceMgr.h"
click node_decompression "https://github.com/ctrdecomp/sead/blob/master/include/resource/seadSZSDecompressor.h"
click node_message "https://github.com/ctrdecomp/sead/blob/master/include/message/seadMessageSet.h"
click node_hostio "https://github.com/ctrdecomp/sead/blob/master/include/hostio/seadHostIOServer.h"
click node_debug "https://github.com/ctrdecomp/sead/blob/master/include/devenv/seadStackTrace.h"
click node_threads "https://github.com/ctrdecomp/sead/blob/master/include/thread/seadThread.h"
click node_heaps "https://github.com/ctrdecomp/sead/blob/master/include/heap/seadHeapMgr.h"
click node_containers "https://github.com/ctrdecomp/sead/blob/master/include/container/seadBuffer.h"
click node_primitives "https://github.com/ctrdecomp/sead/blob/master/include/prim/seadSafeString.h"
click node_codec "https://github.com/ctrdecomp/sead/blob/master/include/codec/seadBase64.h"
click node_random_time "https://github.com/ctrdecomp/sead/blob/master/include/random/seadRandom.h"

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_framework,node_taskmgr,node_controller_mgr,node_controller,node_ctr_controller,node_hid_device,node_graphics,node_game toneBlue
class node_filedevice,node_streams,node_resources,node_decompression,node_message toneAmber
class node_hostio,node_debug,node_threads toneMint
class node_math,node_heaps,node_containers,node_primitives,node_codec,node_random_time toneRose
```

## Components

### Game Runtime

- [Framework and tasks](https://github.com/ctrdecomp/sead/blob/master/include/framework/seadGameFramework.h): `include/framework/seadGameFramework.h`
- [Task manager](https://github.com/ctrdecomp/sead/blob/master/include/framework/seadTaskMgr.h): `include/framework/seadTaskMgr.h`
- [Controller manager](https://github.com/ctrdecomp/sead/blob/master/include/controller/seadControllerMgr.h): `include/controller/seadControllerMgr.h`
- [Controller state](https://github.com/ctrdecomp/sead/blob/master/include/controller/seadControllerBase.h): `include/controller/seadControllerBase.h`
- [CTR controller](https://github.com/ctrdecomp/sead/blob/master/modules/src/controller/ctr/seadCtrController.cpp): `modules/src/controller/ctr/seadCtrController.cpp`
- [CTR HID device](https://github.com/ctrdecomp/sead/blob/master/include/controller/ctr/seadCtrHidDeviceCtr.h): `include/controller/ctr/seadCtrHidDeviceCtr.h`
- [Graphics and rendering](https://github.com/ctrdecomp/sead/blob/master/include/gfx/seadGraphics.h): `include/gfx/seadGraphics.h`

### I/O and Resources

- [File devices](https://github.com/ctrdecomp/sead/blob/master/include/filedevice/seadFileDeviceMgr.h): `include/filedevice/seadFileDeviceMgr.h`
- [Stream I/O](https://github.com/ctrdecomp/sead/blob/master/include/stream/seadStream.h): `include/stream/seadStream.h`
- [Resource loading](https://github.com/ctrdecomp/sead/blob/master/include/resource/seadResourceMgr.h): `include/resource/seadResourceMgr.h`
- [SZS decompression](https://github.com/ctrdecomp/sead/blob/master/include/resource/seadSZSDecompressor.h): `include/resource/seadSZSDecompressor.h`
- [Message Studio](https://github.com/ctrdecomp/sead/blob/master/include/message/seadMessageSet.h): `include/message/seadMessageSet.h`

### Platform Services

- [Host I/O](https://github.com/ctrdecomp/sead/blob/master/include/hostio/seadHostIOServer.h): `include/hostio/seadHostIOServer.h`
- [Debug utilities](https://github.com/ctrdecomp/sead/blob/master/include/devenv/seadStackTrace.h): `include/devenv/seadStackTrace.h`
- [Thread utilities](https://github.com/ctrdecomp/sead/blob/master/include/thread/seadThread.h): `include/thread/seadThread.h`

### Core Facilities

- [Math and geometry](https://github.com/ctrdecomp/sead/blob/master/include/math/seadVector.h): `include/math/seadVector.h`
- [Heap management](https://github.com/ctrdecomp/sead/blob/master/include/heap/seadHeapMgr.h): `include/heap/seadHeapMgr.h`
- [Containers](https://github.com/ctrdecomp/sead/blob/master/include/container/seadBuffer.h): `include/container/seadBuffer.h`
- [Strings and primitives](https://github.com/ctrdecomp/sead/blob/master/include/prim/seadSafeString.h): `include/prim/seadSafeString.h`
- [Encoding and CRC](https://github.com/ctrdecomp/sead/blob/master/include/codec/seadBase64.h): `include/codec/seadBase64.h`
- [Random and time](https://github.com/ctrdecomp/sead/blob/master/include/random/seadRandom.h): `include/random/seadRandom.h`

### Other components

- **Game client**

## Connections

- Game client → Framework and tasks: uses runtime
- Framework and tasks → Task manager: manages tasks
- Game client → Controller manager: uses input
- Controller manager → CTR HID device: calculates device
- Controller manager → CTR controller: calculates controller
- CTR controller → CTR HID device: reads HID state
- CTR controller → Controller state: updates input state
- Game client → Graphics and rendering: uses graphics
- Game client → Resource loading: loads resources
- Resource loading → SZS decompression: decompresses data
- Resource loading → File devices: uses file access
- Stream I/O → File devices: streams file data
