# cotyolmedo/reakt architecture

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

- Interactive diagram: https://gitdiagram.com/cotyolmedo/reakt
- Repository: https://github.com/cotyolmedo/reakt

## Overview

REAKT is an interactive training system: a learner runs reaction sessions in the Android app, which communicates with an ESP32 gateway and one or two ESP32 stimulus nodes; session data can also sync to Supabase. The graph preserves the app, local gateway/radio path, node input/output, shared protocol and scoring logic, and cloud persistence. Firmware sketches and most app implementation were not excerpted, so their internal call relationships are omitted; documented links are cited to the README.

Main entry points: [`app/lib/main.dart`](https://github.com/cotyolmedo/reakt/blob/main/app/lib/main.dart) (Training app), [`firmware/gateway/REAKT_Gateway/REAKT_Gateway.ino`](https://github.com/cotyolmedo/reakt/blob/main/firmware/gateway/REAKT_Gateway/REAKT_Gateway.ino) (ESP32 gateway), [`firmware/nodes/REAKT_Node/REAKT_Node.ino`](https://github.com/cotyolmedo/reakt/blob/main/firmware/nodes/REAKT_Node/REAKT_Node.ino) (ESP32 node), [`app/lib/services/gateway_link.dart`](https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/gateway_link.dart) (Gateway link)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android app"]
  node_mobile["Training app<br/>[main.dart]"]
  node_session["Session UI"]
  node_gateway_link["Gateway link<br/>[gateway_link.dart]"]
  node_local_store[("Local session store<br/>[local_store.dart]")]
  node_cloud_sync["Cloud sync<br/>[cloud_sync.dart]"]
end

subgraph group_gateway["Gateway and radio"]
  node_gateway_fw["ESP32 gateway<br/>[REAKT_Gateway.ino]"]
  node_radio["ESP-NOW radio<br/>[ReaktRadio.h]"]
end

subgraph group_node["Training node"]
  node_node_fw["ESP32 node<br/>[REAKT_Node.ino]"]
  node_button["Button input<br/>[ReaktCore.h]"]
  node_stimulus["LED stimulus<br/>[Stimulus.h]"]
end

subgraph group_shared["Shared protocol"]
  node_protocol["Frame protocol<br/>[ReaktCore.h]"]
  node_score["Reaction scoring<br/>[ReaktCore.h]"]
end

node_learner(("Learner"))
node_supabase[("Supabase")]

node_learner -->|"runs session"| node_mobile
node_mobile -.->|"presents sessions"| node_session
node_mobile -.->|"controls gateway"| node_gateway_link
node_gateway_link -->|"WebSocket"| node_gateway_fw
node_gateway_fw -.->|"uses radio"| node_radio
node_radio -->|"ESP-NOW"| node_node_fw
node_node_fw -.->|"drives output"| node_stimulus
node_node_fw -.->|"reads presses"| node_button
node_button -.->|"reports events"| node_radio
node_gateway_fw -.->|"exchanges frames"| node_protocol
node_node_fw -.->|"exchanges frames"| node_protocol
node_gateway_link -.->|"stores sessions"| node_local_store
node_cloud_sync -->|"syncs results"| node_supabase
node_mobile -->|"syncs sessions"| node_cloud_sync
node_gateway_fw -.->|"tracks results"| node_score

click node_mobile "https://github.com/cotyolmedo/reakt/blob/main/app/lib/main.dart"
click node_session "https://github.com/cotyolmedo/reakt/blob/main/app/lib/presentation/session_record.dart"
click node_gateway_link "https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/gateway_link.dart"
click node_local_store "https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/local_store.dart"
click node_cloud_sync "https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/cloud_sync.dart"
click node_gateway_fw "https://github.com/cotyolmedo/reakt/blob/main/firmware/gateway/REAKT_Gateway/REAKT_Gateway.ino"
click node_radio "https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktRadio.h"
click node_node_fw "https://github.com/cotyolmedo/reakt/blob/main/firmware/nodes/REAKT_Node/REAKT_Node.ino"
click node_button "https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.h"
click node_stimulus "https://github.com/cotyolmedo/reakt/blob/main/firmware/nodes/REAKT_Node/Stimulus.h"
click node_protocol "https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.h"
click node_score "https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.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_mobile,node_session,node_gateway_link,node_local_store,node_cloud_sync toneBlue
class node_gateway_fw,node_radio,node_supabase toneAmber
class node_node_fw,node_button,node_stimulus toneMint
class node_protocol,node_score toneRose
class node_learner toneIndigo
```

## Components

### Android app

- [Training app](https://github.com/cotyolmedo/reakt/blob/main/app/lib/main.dart): `app/lib/main.dart`
- [Session UI](https://github.com/cotyolmedo/reakt/blob/main/app/lib/presentation/session_record.dart): `app/lib/presentation/session_record.dart`
- [Gateway link](https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/gateway_link.dart): `app/lib/services/gateway_link.dart`
- [Local session store](https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/local_store.dart): `app/lib/services/local_store.dart`
- [Cloud sync](https://github.com/cotyolmedo/reakt/blob/main/app/lib/services/cloud_sync.dart): `app/lib/services/cloud_sync.dart`

### Gateway and radio

- [ESP32 gateway](https://github.com/cotyolmedo/reakt/blob/main/firmware/gateway/REAKT_Gateway/REAKT_Gateway.ino): `firmware/gateway/REAKT_Gateway/REAKT_Gateway.ino`
- [ESP-NOW radio](https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktRadio.h): `firmware/libraries/ReaktCore/src/ReaktRadio.h`

### Training node

- [ESP32 node](https://github.com/cotyolmedo/reakt/blob/main/firmware/nodes/REAKT_Node/REAKT_Node.ino): `firmware/nodes/REAKT_Node/REAKT_Node.ino`
- [Button input](https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.h): `firmware/libraries/ReaktCore/src/ReaktCore.h`
- [LED stimulus](https://github.com/cotyolmedo/reakt/blob/main/firmware/nodes/REAKT_Node/Stimulus.h): `firmware/nodes/REAKT_Node/Stimulus.h`

### Shared protocol

- [Frame protocol](https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.h): `firmware/libraries/ReaktCore/src/ReaktCore.h`
- [Reaction scoring](https://github.com/cotyolmedo/reakt/blob/main/firmware/libraries/ReaktCore/src/ReaktCore.h): `firmware/libraries/ReaktCore/src/ReaktCore.h`

### Other components

- **Learner**
- **Supabase**

## Connections

- Learner → Training app: runs session (evidence: `README.md`)
- Training app → Session UI: presents sessions
- Training app → Gateway link: controls gateway
- Gateway link → ESP32 gateway: WebSocket (evidence: `README.md`)
- ESP32 gateway → ESP-NOW radio: uses radio
- ESP-NOW radio → ESP32 node: ESP-NOW (evidence: `README.md`)
- ESP32 node → LED stimulus: drives output
- ESP32 node → Button input: reads presses
- Button input → ESP-NOW radio: reports events (evidence: `firmware/libraries/ReaktCore/src/ReaktRadio.h`)
- ESP32 gateway → Frame protocol: exchanges frames
- ESP32 node → Frame protocol: exchanges frames
- Gateway link → Local session store: stores sessions
- Cloud sync → Supabase: syncs results (evidence: `README.md`)
- Training app → Cloud sync: syncs sessions (evidence: `README.md`)
- ESP32 gateway → Reaction scoring: tracks results
