# deke21/cantina-4-twomonth-embeded architecture

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

- Interactive diagram: https://gitdiagram.com/deke21/cantina-4-twomonth-embeded
- Repository: https://github.com/deke21/cantina-4-twomonth-embeded

## Overview

Cantina is embedded flight-control firmware for a rocket-like vehicle. Its main workflow polls flight sensors, advances a flight-state machine, responds to ground commands by operating release and solar mechanisms, assembles telemetry, and transmits it over ESP-NOW or a serial link. The graph includes the documented-by-source telemetry data model and CSV writer as separate capabilities. Edges are limited to relationships visible in the sampled main loop or source index; unsampled implementation details are not inferred.

Main entry points: [`Cantina/src/main.cpp`](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp) (Firmware Loop), [`Cantina/src/Telemetry/TelemetryDispatcher.cpp`](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Telemetry/TelemetryDispatcher.cpp) (Telemetry Dispatcher), [`Cantina/src/Hardware/Input/Barometer.cpp`](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/Barometer.cpp) (Barometer), [`Cantina/src/Hardware/Input/GPS.cpp`](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/GPS.cpp) (GPS)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_flight["Flight Control"]
  node_firmware["Firmware Loop<br/>[main.cpp]"]
  node_flightstate["Flight State Logic<br/>[main.cpp]"]
  node_espnow["ESP-NOW Link<br/>[main.cpp]"]
  node_serial["Serial Link<br/>[main.cpp]"]
end

subgraph group_sensing["Sensor Inputs"]
  node_barometer["Barometer<br/>[Barometer.cpp]"]
  node_battery["Battery Voltage<br/>[BatteryVoltage.cpp]"]
  node_gps["GPS<br/>[GPS.cpp]"]
  node_ins["Inertial Sensor<br/>[INS.cpp]"]
  node_solarpanel["Solar Panel Sensing<br/>[SolarPanel.cpp]"]
end

subgraph group_actuation["Mechanisms"]
  node_release["Release Mechanism"]
  node_solar["Solar Mechanism<br/>[SolarMechansim.cpp]"]
  node_recovery["Recovery System<br/>[RecoverySystem.cpp]"]
end

subgraph group_telemetry["Telemetry"]
  node_dispatcher["Telemetry Dispatcher"]
  node_telemetrydata["Telemetry Data Model<br/>[DataStructure.hpp]"]
  node_csvwriter["CSV Writer<br/>[CSVFilewriter.cpp]"]
end

node_ground(("Ground Station"))

node_firmware -->|"advances states"| node_flightstate
node_firmware -->|"polls and reads"| node_barometer
node_firmware -->|"polls and reads"| node_battery
node_firmware -->|"updates and reads"| node_gps
node_firmware -->|"polls and reads"| node_ins
node_firmware -->|"polls and reads"| node_solarpanel
node_flightstate -->|"reads altitude"| node_barometer
node_flightstate -->|"reads velocity"| node_gps
node_flightstate -->|"triggers release"| node_release
node_flightstate -->|"deploys mechanism"| node_solar
node_flightstate -->|"steps recovery"| node_recovery
node_ground -->|"sends commands"| node_espnow
node_espnow -->|"dispatches callback"| node_firmware
node_firmware -->|"applies commands"| node_release
node_firmware -->|"applies commands"| node_solar
node_firmware -->|"updates and serializes"| node_dispatcher
node_firmware -->|"fills telemetry fields"| node_telemetrydata
node_firmware -->|"sends telemetry"| node_espnow
node_firmware -->|"writes telemetry"| node_serial
node_dispatcher -->|"uses data model"| node_telemetrydata

click node_firmware "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp"
click node_flightstate "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp"
click node_barometer "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/Barometer.cpp"
click node_battery "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/BatteryVoltage.cpp"
click node_gps "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/GPS.cpp"
click node_ins "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/INS.cpp"
click node_solarpanel "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/SolarPanel.cpp"
click node_release "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/ReleaseMechanism.cpp"
click node_solar "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/SolarMechansim.cpp"
click node_recovery "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/RecoverySystem.cpp"
click node_dispatcher "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Telemetry/TelemetryDispatcher.cpp"
click node_telemetrydata "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/include/Utils/DataStructure.hpp"
click node_csvwriter "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Telemetry/CSVFilewriter.cpp"
click node_espnow "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp"
click node_serial "https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.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_firmware,node_flightstate,node_espnow,node_serial toneBlue
class node_barometer,node_battery,node_gps,node_ins,node_solarpanel toneAmber
class node_release,node_solar,node_recovery toneMint
class node_dispatcher,node_telemetrydata,node_csvwriter toneRose
class node_ground toneIndigo
```

## Components

### Flight Control

- [Firmware Loop](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp): `Cantina/src/main.cpp`
- [Flight State Logic](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp): `Cantina/src/main.cpp`
- [ESP-NOW Link](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp): `Cantina/src/main.cpp`
- [Serial Link](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/main.cpp): `Cantina/src/main.cpp`

### Sensor Inputs

- [Barometer](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/Barometer.cpp): `Cantina/src/Hardware/Input/Barometer.cpp`
- [Battery Voltage](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/BatteryVoltage.cpp): `Cantina/src/Hardware/Input/BatteryVoltage.cpp`
- [GPS](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/GPS.cpp): `Cantina/src/Hardware/Input/GPS.cpp`
- [Inertial Sensor](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/INS.cpp): `Cantina/src/Hardware/Input/INS.cpp`
- [Solar Panel Sensing](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Input/SolarPanel.cpp): `Cantina/src/Hardware/Input/SolarPanel.cpp`

### Mechanisms

- [Release Mechanism](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/ReleaseMechanism.cpp): `Cantina/src/Hardware/Output/ReleaseMechanism.cpp`
- [Solar Mechanism](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/SolarMechansim.cpp): `Cantina/src/Hardware/Output/SolarMechansim.cpp`
- [Recovery System](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Hardware/Output/RecoverySystem.cpp): `Cantina/src/Hardware/Output/RecoverySystem.cpp`

### Telemetry

- [Telemetry Dispatcher](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Telemetry/TelemetryDispatcher.cpp): `Cantina/src/Telemetry/TelemetryDispatcher.cpp`
- [Telemetry Data Model](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/include/Utils/DataStructure.hpp): `Cantina/include/Utils/DataStructure.hpp`
- [CSV Writer](https://github.com/deke21/cantina-4-twomonth-embeded/blob/main/Cantina/src/Telemetry/CSVFilewriter.cpp): `Cantina/src/Telemetry/CSVFilewriter.cpp`

### Other components

- **Ground Station**

## Connections

- Firmware Loop → Flight State Logic: advances states (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Barometer: polls and reads (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Battery Voltage: polls and reads (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → GPS: updates and reads (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Inertial Sensor: polls and reads (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Solar Panel Sensing: polls and reads (evidence: `Cantina/src/main.cpp`)
- Flight State Logic → Barometer: reads altitude (evidence: `Cantina/src/main.cpp`)
- Flight State Logic → GPS: reads velocity (evidence: `Cantina/src/main.cpp`)
- Flight State Logic → Release Mechanism: triggers release (evidence: `Cantina/src/main.cpp`)
- Flight State Logic → Solar Mechanism: deploys mechanism (evidence: `Cantina/src/main.cpp`)
- Flight State Logic → Recovery System: steps recovery (evidence: `Cantina/src/main.cpp`)
- Ground Station → ESP-NOW Link: sends commands (evidence: `Cantina/src/main.cpp`)
- ESP-NOW Link → Firmware Loop: dispatches callback (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Release Mechanism: applies commands (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Solar Mechanism: applies commands (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Telemetry Dispatcher: updates and serializes (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Telemetry Data Model: fills telemetry fields (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → ESP-NOW Link: sends telemetry (evidence: `Cantina/src/main.cpp`)
- Firmware Loop → Serial Link: writes telemetry (evidence: `Cantina/src/main.cpp`)
- Telemetry Dispatcher → Telemetry Data Model: uses data model
