# ericstoneking/42 architecture

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

- Interactive diagram: https://gitdiagram.com/ericstoneking/42
- Repository: https://github.com/ericstoneking/42

## Overview

42 is a spacecraft attitude-and-orbit dynamics simulator. The principal workflow is: an operator supplies simulation inputs, the runtime initializes state and models, advances coupled spacecraft/environment dynamics, runs flight software and actuators, then emits reports, visualization, and optional IPC results. The graph preserves orbital, environmental, multi-body, sensing/control, visualization, communications, and tooling capabilities. Several relationships are inferred from module roles and declarations because sampled excerpts omit the main orchestration bodies.

Main entry points: [`Source/42exec.c`](https://github.com/ericstoneking/42/blob/master/Source/42exec.c) (Simulation Executive), [`Kit/Source/orbkit.c`](https://github.com/ericstoneking/42/blob/master/Kit/Source/orbkit.c) (Orbital Math Kit), [`Source/42main.c`](https://github.com/ericstoneking/42/blob/master/Source/42main.c) (Runtime Entry), [`Source/42dynamics.c`](https://github.com/ericstoneking/42/blob/master/Source/42dynamics.c) (Spacecraft Dynamics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Simulation Runtime"]
  node_main["Runtime Entry<br/>[42main.c]"]
  node_init["Simulation Initialization<br/>[42init.c]"]
  node_exec["Simulation Executive<br/>[42exec.c]"]
  node_report["Reports And Output<br/>[42report.c]"]
end

subgraph group_models["Dynamics Models"]
  node_dynamics["Spacecraft Dynamics<br/>[42dynamics.c]"]
  node_ephem["Orbit Ephemerides<br/>[42ephem.c]"]
  node_environs["Environment Models<br/>[42environs.c]"]
  node_perturb["Force Perturbations<br/>[42perturb.c]"]
  node_orbkit["Orbital Math Kit<br/>[orbkit.c]"]
  node_msis["Atmosphere Models<br/>[val_atm_msis00.cpp]"]
end

subgraph group_control["Control And IPC"]
  node_fsw["Flight Software<br/>[42fsw.c]"]
  node_sensors["Sensor Simulation<br/>[42sensors.c]"]
  node_actuators["Actuator Simulation<br/>[42actuators.c]"]
  node_commands["Command Handling<br/>[42cmd.c]"]
  node_ipc["IPC Interface<br/>[42ipc.c]"]
  node_autocode_ipc["Autocode IPC<br/>[ScIPC.c]"]
  node_commlink["Spacecraft Links<br/>[42commlink.c]"]
end

subgraph group_visual["Visualization"]
  node_graphics["Graphics Renderer<br/>[42gl.c]"]
  node_glkit["Graphics Support Kit<br/>[glkit.c]"]
end

subgraph group_tools["Analysis Tools"]
  node_two_impulse["Transfer Analysis<br/>[TwoImpulse.c]"]
  node_tle_converter["TLE Conversion<br/>[Tle2Kep.c]"]
  node_world_builder["World Asset Builder<br/>[DEMToBumpCube.c]"]
end

node_operator(("Simulation Operator"))
node_input_files["Input Files"]
node_output_files["Output Files"]
node_ipc_client(("IPC Client"))

node_operator -->|"starts run"| node_main
node_input_files -->|"provides inputs"| node_init
node_main -->|"initializes"| node_init
node_main -->|"enters loop"| node_exec
node_init -->|"initializes orbits"| node_orbkit
node_exec -->|"advances state"| node_dynamics
node_exec -->|"propagates ephemerides"| node_ephem
node_exec -->|"updates environment"| node_environs
node_exec -->|"runs flight software"| node_fsw
node_exec -->|"applies actuators"| node_actuators
node_exec -->|"writes results"| node_report
node_dynamics -->|"computes perturbations"| node_perturb
node_dynamics -->|"uses orbital math"| node_orbkit
node_environs -.->|"queries atmosphere"| node_msis
node_fsw -->|"reads sensors"| node_sensors
node_fsw -->|"processes commands"| node_commands
node_ipc_client -->|"exchanges messages"| node_ipc
node_ipc -->|"packs state"| node_autocode_ipc
node_exec -->|"dispatches IPC"| node_ipc
node_exec -->|"updates links"| node_commlink
node_exec -.->|"updates display"| node_graphics
node_graphics -->|"renders scene"| node_glkit
node_report -->|"writes outputs"| node_output_files
node_two_impulse -->|"uses orbit math"| node_orbkit
node_tle_converter -->|"uses orbit math"| node_orbkit
node_world_builder -->|"writes assets"| node_output_files

click node_main "https://github.com/ericstoneking/42/blob/master/Source/42main.c"
click node_init "https://github.com/ericstoneking/42/blob/master/Source/42init.c"
click node_exec "https://github.com/ericstoneking/42/blob/master/Source/42exec.c"
click node_report "https://github.com/ericstoneking/42/blob/master/Source/42report.c"
click node_dynamics "https://github.com/ericstoneking/42/blob/master/Source/42dynamics.c"
click node_ephem "https://github.com/ericstoneking/42/blob/master/Source/42ephem.c"
click node_environs "https://github.com/ericstoneking/42/blob/master/Source/42environs.c"
click node_perturb "https://github.com/ericstoneking/42/blob/master/Source/42perturb.c"
click node_orbkit "https://github.com/ericstoneking/42/blob/master/Kit/Source/orbkit.c"
click node_msis "https://github.com/ericstoneking/42/blob/master/World/Downing%20Models/val_atm_msis00.cpp"
click node_fsw "https://github.com/ericstoneking/42/blob/master/Source/42fsw.c"
click node_sensors "https://github.com/ericstoneking/42/blob/master/Source/42sensors.c"
click node_actuators "https://github.com/ericstoneking/42/blob/master/Source/42actuators.c"
click node_commands "https://github.com/ericstoneking/42/blob/master/Source/42cmd.c"
click node_ipc "https://github.com/ericstoneking/42/blob/master/Source/42ipc.c"
click node_autocode_ipc "https://github.com/ericstoneking/42/blob/master/Source/AutoCode/ScIPC.c"
click node_commlink "https://github.com/ericstoneking/42/blob/master/Source/42commlink.c"
click node_graphics "https://github.com/ericstoneking/42/blob/master/Source/42gl.c"
click node_glkit "https://github.com/ericstoneking/42/blob/master/Kit/Source/glkit.c"
click node_two_impulse "https://github.com/ericstoneking/42/blob/master/Development/TwoImpulse.c"
click node_tle_converter "https://github.com/ericstoneking/42/blob/master/Utilities/Tle2Kep.c"
click node_world_builder "https://github.com/ericstoneking/42/blob/master/World/DEMToBumpCube.c"

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_main,node_init,node_exec,node_report,node_ipc_client toneBlue
class node_dynamics,node_ephem,node_environs,node_perturb,node_orbkit,node_msis toneAmber
class node_fsw,node_sensors,node_actuators,node_commands,node_ipc,node_autocode_ipc,node_commlink toneMint
class node_graphics,node_glkit toneRose
class node_two_impulse,node_tle_converter,node_world_builder,node_operator,node_input_files,node_output_files toneIndigo
```

## Components

### Simulation Runtime

- [Runtime Entry](https://github.com/ericstoneking/42/blob/master/Source/42main.c): `Source/42main.c`
- [Simulation Initialization](https://github.com/ericstoneking/42/blob/master/Source/42init.c): `Source/42init.c`
- [Simulation Executive](https://github.com/ericstoneking/42/blob/master/Source/42exec.c): `Source/42exec.c`
- [Reports And Output](https://github.com/ericstoneking/42/blob/master/Source/42report.c): `Source/42report.c`

### Dynamics Models

- [Spacecraft Dynamics](https://github.com/ericstoneking/42/blob/master/Source/42dynamics.c): `Source/42dynamics.c`
- [Orbit Ephemerides](https://github.com/ericstoneking/42/blob/master/Source/42ephem.c): `Source/42ephem.c`
- [Environment Models](https://github.com/ericstoneking/42/blob/master/Source/42environs.c): `Source/42environs.c`
- [Force Perturbations](https://github.com/ericstoneking/42/blob/master/Source/42perturb.c): `Source/42perturb.c`
- [Orbital Math Kit](https://github.com/ericstoneking/42/blob/master/Kit/Source/orbkit.c): `Kit/Source/orbkit.c`
- [Atmosphere Models](https://github.com/ericstoneking/42/blob/master/World/Downing%20Models/val_atm_msis00.cpp): `World/Downing Models/val_atm_msis00.cpp`

### Control And IPC

- [Flight Software](https://github.com/ericstoneking/42/blob/master/Source/42fsw.c): `Source/42fsw.c`
- [Sensor Simulation](https://github.com/ericstoneking/42/blob/master/Source/42sensors.c): `Source/42sensors.c`
- [Actuator Simulation](https://github.com/ericstoneking/42/blob/master/Source/42actuators.c): `Source/42actuators.c`
- [Command Handling](https://github.com/ericstoneking/42/blob/master/Source/42cmd.c): `Source/42cmd.c`
- [IPC Interface](https://github.com/ericstoneking/42/blob/master/Source/42ipc.c): `Source/42ipc.c`
- [Autocode IPC](https://github.com/ericstoneking/42/blob/master/Source/AutoCode/ScIPC.c): `Source/AutoCode/ScIPC.c`
- [Spacecraft Links](https://github.com/ericstoneking/42/blob/master/Source/42commlink.c): `Source/42commlink.c`

### Visualization

- [Graphics Renderer](https://github.com/ericstoneking/42/blob/master/Source/42gl.c): `Source/42gl.c`
- [Graphics Support Kit](https://github.com/ericstoneking/42/blob/master/Kit/Source/glkit.c): `Kit/Source/glkit.c`

### Analysis Tools

- [Transfer Analysis](https://github.com/ericstoneking/42/blob/master/Development/TwoImpulse.c): `Development/TwoImpulse.c`
- [TLE Conversion](https://github.com/ericstoneking/42/blob/master/Utilities/Tle2Kep.c): `Utilities/Tle2Kep.c`
- [World Asset Builder](https://github.com/ericstoneking/42/blob/master/World/DEMToBumpCube.c): `World/DEMToBumpCube.c`

### Other components

- **Simulation Operator**
- **Input Files**
- **Output Files**
- **IPC Client**

## Connections

- Simulation Operator → Runtime Entry: starts run
- Input Files → Simulation Initialization: provides inputs
- Runtime Entry → Simulation Initialization: initializes
- Runtime Entry → Simulation Executive: enters loop
- Simulation Initialization → Orbital Math Kit: initializes orbits
- Simulation Executive → Spacecraft Dynamics: advances state
- Simulation Executive → Orbit Ephemerides: propagates ephemerides
- Simulation Executive → Environment Models: updates environment
- Simulation Executive → Flight Software: runs flight software
- Simulation Executive → Actuator Simulation: applies actuators
- Simulation Executive → Reports And Output: writes results
- Spacecraft Dynamics → Force Perturbations: computes perturbations
- Spacecraft Dynamics → Orbital Math Kit: uses orbital math
- Environment Models → Atmosphere Models: queries atmosphere
- Flight Software → Sensor Simulation: reads sensors
- Flight Software → Command Handling: processes commands
- IPC Client → IPC Interface: exchanges messages
- IPC Interface → Autocode IPC: packs state
- Simulation Executive → IPC Interface: dispatches IPC
- Simulation Executive → Spacecraft Links: updates links
- Simulation Executive → Graphics Renderer: updates display
- Graphics Renderer → Graphics Support Kit: renders scene
- Reports And Output → Output Files: writes outputs
- Transfer Analysis → Orbital Math Kit: uses orbit math
- TLE Conversion → Orbital Math Kit: uses orbit math
- World Asset Builder → Output Files: writes assets
