# lungmen-hkm/argabeacon architecture

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

- Interactive diagram: https://gitdiagram.com/lungmen-hkm/argabeacon
- Repository: https://github.com/lungmen-hkm/argabeacon

## Overview

ArgaBeacon adapts Meshtastic firmware for hiking safety: a hiker’s GPS position or emergency-button event is shared over a LoRa mesh, while Bluetooth and the Meshtastic app provide configuration. A separate ESP32/RFID attendance unit records camp check-ins through a PHP web application. The README documents these product workflows; sampled firmware excerpts confirm startup, routing, and display-management responsibilities, but do not show the full GPS/button dispatch or attendance implementation.

Main entry points: [`src/mesh/MeshService.cpp`](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/MeshService.cpp) (Mesh service), [`src/mesh/Router.cpp`](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/Router.cpp) (Packet routing), [`src/main.cpp`](https://github.com/lungmen-hkm/argabeacon/blob/main/src/main.cpp) (Firmware startup), [`src/mesh/RadioInterface.cpp`](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/RadioInterface.cpp) (LoRa radio)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mesh["Mesh communications"]
  node_position["Position module<br/>[PositionModule.cpp]"]
  node_service["Mesh service<br/>[MeshService.cpp]"]
  node_routing["Packet routing<br/>[Router.cpp]"]
  node_router_module["Routing handler<br/>[RoutingModule.cpp]"]
  node_crypto["Packet cryptography<br/>[CryptoEngine.cpp]"]
  node_radio["LoRa radio<br/>[RadioInterface.cpp]"]
  node_node_db[("Node database<br/>[NodeDB.cpp]")]
end

subgraph group_device["Hiker device"]
  node_gps["GPS tracking"]
  node_emergency["Emergency button<br/>[ButtonThread.cpp]"]
  node_firmware["Firmware startup<br/>[main.cpp]"]
end

subgraph group_ui["Device interface"]
  node_bluetooth["Bluetooth configuration"]
  node_inkhud["InkHUD display<br/>[InkHUD.cpp]"]
  node_window["Applet windows<br/>[WindowManager.cpp]"]
end

subgraph group_attendance["Camp attendance"]
  node_attendance_device["Attendance ESP32<br/>[esp32.cpp]"]
  node_attendance_api["Attendance API<br/>[absensi.php]"]
  node_attendance_site["Attendance website<br/>[index.php]"]
end

node_hiker(("Hiker"))
node_mesh_peers(("Mesh peers"))
node_phone(("Meshtastic app"))
node_rfid(("RFID reader"))
node_database[("Attendance database")]

node_hiker -->|"presses"| node_emergency
node_gps -->|"provides coordinates"| node_position
node_emergency -->|"requests emergency send"| node_service
node_position -->|"provides location data"| node_service
node_service -->|"dispatches packets"| node_routing
node_routing -->|"delivers received packets"| node_router_module
node_routing -->|"encrypts packets"| node_crypto
node_routing -->|"transmits packets"| node_radio
node_radio -->|"sends over LoRa mesh"| node_mesh_peers
node_mesh_peers -->|"forwards mesh packets"| node_radio
node_router_module -->|"delivers to radio handler"| node_service
node_router_module -->|"checks node records"| node_node_db
node_firmware -->|"starts firmware service"| node_service
node_firmware -->|"initializes radio"| node_radio
node_phone -->|"configures device"| node_bluetooth
node_bluetooth -->|"configures device"| node_firmware
node_firmware -->|"starts display"| node_inkhud
node_inkhud -->|"manages applets"| node_window
node_hiker -->|"taps at camp"| node_rfid
node_rfid -->|"provides tag scan"| node_attendance_device
node_attendance_device -->|"submits attendance"| node_attendance_api
node_attendance_site -->|"requests attendance"| node_attendance_api
node_attendance_api -->|"reads and writes records"| node_database

click node_gps "https://github.com/lungmen-hkm/argabeacon/tree/main/src/gps"
click node_emergency "https://github.com/lungmen-hkm/argabeacon/blob/main/src/ButtonThread.cpp"
click node_firmware "https://github.com/lungmen-hkm/argabeacon/blob/main/src/main.cpp"
click node_position "https://github.com/lungmen-hkm/argabeacon/blob/main/src/modules/PositionModule.cpp"
click node_service "https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/MeshService.cpp"
click node_routing "https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/Router.cpp"
click node_router_module "https://github.com/lungmen-hkm/argabeacon/blob/main/src/modules/RoutingModule.cpp"
click node_crypto "https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/CryptoEngine.cpp"
click node_radio "https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/RadioInterface.cpp"
click node_node_db "https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/NodeDB.cpp"
click node_bluetooth "https://github.com/lungmen-hkm/argabeacon/blob/main/src/nimble/NimbleBluetooth.cpp"
click node_inkhud "https://github.com/lungmen-hkm/argabeacon/blob/main/src/graphics/niche/InkHUD/InkHUD.cpp"
click node_window "https://github.com/lungmen-hkm/argabeacon/blob/main/src/graphics/niche/InkHUD/WindowManager.cpp"
click node_attendance_device "https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/esp32.cpp"
click node_attendance_api "https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/api/absensi.php"
click node_attendance_site "https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/index.php"

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_position,node_service,node_routing,node_router_module,node_crypto,node_radio,node_node_db toneBlue
class node_gps,node_emergency,node_firmware,node_database toneAmber
class node_bluetooth,node_inkhud,node_window toneMint
class node_attendance_device,node_attendance_api,node_attendance_site toneRose
class node_hiker,node_mesh_peers,node_phone,node_rfid toneIndigo
```

## Components

### Mesh communications

- [Position module](https://github.com/lungmen-hkm/argabeacon/blob/main/src/modules/PositionModule.cpp): `src/modules/PositionModule.cpp`
- [Mesh service](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/MeshService.cpp): `src/mesh/MeshService.cpp`
- [Packet routing](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/Router.cpp): `src/mesh/Router.cpp`
- [Routing handler](https://github.com/lungmen-hkm/argabeacon/blob/main/src/modules/RoutingModule.cpp): `src/modules/RoutingModule.cpp`
- [Packet cryptography](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/CryptoEngine.cpp): `src/mesh/CryptoEngine.cpp`
- [LoRa radio](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/RadioInterface.cpp): `src/mesh/RadioInterface.cpp`
- [Node database](https://github.com/lungmen-hkm/argabeacon/blob/main/src/mesh/NodeDB.cpp): `src/mesh/NodeDB.cpp`

### Hiker device

- [GPS tracking](https://github.com/lungmen-hkm/argabeacon/tree/main/src/gps): `src/gps`
- [Emergency button](https://github.com/lungmen-hkm/argabeacon/blob/main/src/ButtonThread.cpp): `src/ButtonThread.cpp`
- [Firmware startup](https://github.com/lungmen-hkm/argabeacon/blob/main/src/main.cpp): `src/main.cpp`

### Device interface

- [Bluetooth configuration](https://github.com/lungmen-hkm/argabeacon/blob/main/src/nimble/NimbleBluetooth.cpp): `src/nimble/NimbleBluetooth.cpp`
- [InkHUD display](https://github.com/lungmen-hkm/argabeacon/blob/main/src/graphics/niche/InkHUD/InkHUD.cpp): `src/graphics/niche/InkHUD/InkHUD.cpp`
- [Applet windows](https://github.com/lungmen-hkm/argabeacon/blob/main/src/graphics/niche/InkHUD/WindowManager.cpp): `src/graphics/niche/InkHUD/WindowManager.cpp`

### Camp attendance

- [Attendance ESP32](https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/esp32.cpp): `web-absensi/esp32.cpp`
- [Attendance API](https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/api/absensi.php): `web-absensi/api/absensi.php`
- [Attendance website](https://github.com/lungmen-hkm/argabeacon/blob/main/web-absensi/index.php): `web-absensi/index.php`

### Other components

- **Hiker**
- **Mesh peers**
- **Meshtastic app**
- **RFID reader**
- **Attendance database**

## Connections

- Hiker → Emergency button: presses
- GPS tracking → Position module: provides coordinates
- Emergency button → Mesh service: requests emergency send
- Position module → Mesh service: provides location data
- Mesh service → Packet routing: dispatches packets
- Packet routing → Routing handler: delivers received packets
- Packet routing → Packet cryptography: encrypts packets
- Packet routing → LoRa radio: transmits packets
- LoRa radio → Mesh peers: sends over LoRa mesh
- Mesh peers → LoRa radio: forwards mesh packets
- Routing handler → Mesh service: delivers to radio handler
- Routing handler → Node database: checks node records
- Firmware startup → Mesh service: starts firmware service
- Firmware startup → LoRa radio: initializes radio
- Meshtastic app → Bluetooth configuration: configures device
- Bluetooth configuration → Firmware startup: configures device
- Firmware startup → InkHUD display: starts display
- InkHUD display → Applet windows: manages applets
- Hiker → RFID reader: taps at camp
- RFID reader → Attendance ESP32: provides tag scan
- Attendance ESP32 → Attendance API: submits attendance
- Attendance website → Attendance API: requests attendance
- Attendance API → Attendance database: reads and writes records
