# lumateam/luma3ds architecture

> Architecture diagram of the GitHub repository lumateam/luma3ds, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lumateam/luma3ds
- Repository: https://github.com/lumateam/luma3ds

## Overview

##### Project’s primary purpose and type
- Luma3DS is a custom firmware for Nintendo 3DS. It patches and augments the official system software, enabling homebrew support, game modding, an overlay menu (Rosalina), and various system module reimplementations.
- It is structured as a low-level system project with multiple components (boot loaders, kernel extensions, and reimplemented OS modules) that work together to modify system behavior at boot and runtime.

##### Break down the main components and their relationships
– Bootloaders and Firmware Loaders:
- Two directories (arm9 and arm11) house the essential boot code. The arm9 part is responsible for the baremetal boot settings, chainloading of homebrew firmware, patching the official firmware, and initial code injection.
- The arm11 folder contains similar low-level loader functionality that works in tandem with arm9 to enable system modifications.
– Kernel Extensions:
- The k11_extension directory contains the code injected into the Arm11 kernel (Kernel11). This module hooks system calls (SVCs), extends IPC, and essentially allows for features like pausing other processes when the Rosalina menu is activated.
– System Modules (sysmodules):
- This component is subdivided into:
▪ Loader – loads non-KIP processes from storage and performs patches, including homebrew 3DSX loading.
▪ Rosalina – the overlay menu that provides the user interface for settings, debugging (via GDB), and various system patches.
▪ PXI – manages communication between Arm11 and Arm9.
▪ SM (Service Manager) – reimplements service control by removing access restrictions.
▪ PM (Process Manager) – refines process launching/termination, handles GDB “break-on-start” features, and lifts FS access control restrictions.
– External Dependencies and Build Tools:
- The Makefiles, configuration files, and additional directories (like .github for issues, Makefiles, and config templates) indicate how the project is built and deployed.
- The compiled output (boot.firm) is placed on the SD card and bootstrapped via boot9strap.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Build Environment / Toolchain"]:::Build

    subgraph "Boot Layer"
        B["arm9 Bootloader"]:::Boot
        C["arm11 Bootloader"]:::Boot
    end

    D["Kernel Extension"]:::Kernel

    subgraph "System Modules"
        E["Loader Module"]:::SysModule
        F["Rosalina Module"]:::SysModule
        G["PXI Module"]:::SysModule
        H["Service Manager"]:::SysModule
        I["Process Manager"]:::SysModule
    end

    A --> B
    A --> C
    B -->|"chainload"| D
    C -->|"chainload"| D
    D -->|"injects"| E
    E -->|"loads"| F
    E -->|"loads"| G
    E -->|"loads"| H
    E -->|"loads"| I

    %% Click Events
    click B "https://github.com/lumateam/luma3ds/tree/master/arm9/"
    click C "https://github.com/lumateam/luma3ds/tree/master/arm11/"
    click D "https://github.com/lumateam/luma3ds/tree/master/k11_extension/"
    click E "https://github.com/lumateam/luma3ds/tree/master/sysmodules/loader/"
    click F "https://github.com/lumateam/luma3ds/tree/master/sysmodules/rosalina/"
    click G "https://github.com/lumateam/luma3ds/tree/master/sysmodules/pxi/"
    click H "https://github.com/lumateam/luma3ds/tree/master/sysmodules/sm/"
    click I "https://github.com/lumateam/luma3ds/tree/master/sysmodules/pm/"

    %% Styles
    classDef Boot fill:#1E3A8A,stroke:#000,stroke-width:2px,color:#ffffff;
    classDef Kernel fill:#10B981,stroke:#000,stroke-width:2px,color:#ffffff;
    classDef SysModule fill:#F59E0B,stroke:#000,stroke-width:2px,color:#000000;
    classDef Build fill:#6B7280,stroke:#000,stroke-width:2px,color:#ffffff;
```
