# anrijs/meshlog architecture

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

- Interactive diagram: https://gitdiagram.com/anrijs/meshlog
- Repository: https://github.com/anrijs/meshlog

## Overview

MeshLog Web ingests JSON reports from MeshCore logger firmware, stores decoded mesh activity and reporter observations in MySQL/MariaDB, and exposes it through a web interface and JSON API. The setup path initializes the database and admin account; the operational workflow is logger POST → decode/validate and persist records → browse or retrieve data. The README also documents reporter administration and configurable firmware reporting. Unsampled APIs and page internals are represented only where the README or source index supports their role; arrows reflect shown calls or documented interactions.

Main entry points: [`lib/meshlog.class.php`](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.class.php) (MeshLog service), [`lib/meshlog.entity.class.php`](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.entity.class.php) (Entity persistence), [`setup.php`](https://github.com/anrijs/meshlog/blob/main/setup.php) (Database and account setup), [`admin/api/reporters/index.php`](https://github.com/anrijs/meshlog/blob/main/admin/api/reporters/index.php) (Reporter admin API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Ingestion"]
  node_ingress["Report endpoint<br/>[log.php]"]
  node_service["MeshLog service<br/>[meshlog.class.php]"]
  node_decoder["Packet decoder"]
end

subgraph group_domain["Mesh records"]
  node_entity["Entity persistence"]
  node_mysql[("MySQL database")]
  node_mesh_objects["Mesh activity records"]
  node_contacts["Contacts"]
  node_channels["Channels and messages"]
  node_direct_messages["Direct messages"]
  node_reports["Reception reports"]
  node_reporters["Reporter nodes"]
  node_telemetry["Telemetry"]
end

subgraph group_access["Query interfaces"]
  node_api["Versioned JSON API<br/>[index.php]"]
  node_api_routes["API query routes"]
  node_web["Activity web view<br/>[index.php]"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Reporter administration<br/>[index.php]"]
  node_admin_api["Reporter admin API<br/>[index.php]"]
  node_auth["Session authorization<br/>[loggedin.php]"]
  node_setup["Database and account setup<br/>[setup.php]"]
  node_migrations["Schema migrations"]
end

node_logger(("MeshCore logger"))
node_admin_user(("Administrator"))

node_logger -->|"posts reports"| node_ingress
node_ingress -->|"calls insert"| node_service
node_service -->|"decodes packets"| node_decoder
node_service -->|"creates records"| node_mesh_objects
node_service -->|"creates reports"| node_reports
node_service -->|"uses persistence"| node_entity
node_entity -.->|"reads and writes"| node_mysql
node_mesh_objects -->|"inherits persistence"| node_entity
node_contacts -.->|"inherits persistence"| node_entity
node_channels -.->|"inherits persistence"| node_entity
node_direct_messages -.->|"inherits persistence"| node_entity
node_reports -->|"inherits persistence"| node_entity
node_reporters -.->|"inherits persistence"| node_entity
node_telemetry -.->|"inherits persistence"| node_entity
node_api -->|"queries data"| node_service
node_api_routes -->|"serves queries"| node_service
node_web -.->|"uses service"| node_service
node_admin_user -->|"manages reporters"| node_admin_ui
node_admin_ui -->|"fetches reporter data"| node_admin_api
node_admin_api -->|"checks session"| node_auth
node_admin_api -.->|"uses service"| node_service
node_setup -->|"runs migrations"| node_migrations
node_setup -->|"checks database"| node_service
node_setup -->|"initializes database"| node_mysql

click node_ingress "https://github.com/anrijs/meshlog/blob/main/log.php"
click node_service "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.class.php"
click node_decoder "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.decoder.php"
click node_entity "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.entity.class.php"
click node_mesh_objects "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.advertisement.class.php"
click node_contacts "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.contact.class.php"
click node_channels "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.channel_message.class.php"
click node_direct_messages "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.direct_message.class.php"
click node_reports "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.report.class.php"
click node_reporters "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.reporter.class.php"
click node_telemetry "https://github.com/anrijs/meshlog/blob/main/lib/meshlog.telemetry.class.php"
click node_api "https://github.com/anrijs/meshlog/blob/main/api/v1/all/index.php"
click node_api_routes "https://github.com/anrijs/meshlog/tree/main/api/v1"
click node_web "https://github.com/anrijs/meshlog/blob/main/index.php"
click node_admin_ui "https://github.com/anrijs/meshlog/blob/main/admin/index.php"
click node_admin_api "https://github.com/anrijs/meshlog/blob/main/admin/api/reporters/index.php"
click node_auth "https://github.com/anrijs/meshlog/blob/main/admin/api/loggedin.php"
click node_setup "https://github.com/anrijs/meshlog/blob/main/setup.php"
click node_migrations "https://github.com/anrijs/meshlog/blob/main/lib/migration.class.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_ingress,node_service,node_decoder toneBlue
class node_entity,node_mysql,node_mesh_objects,node_contacts,node_channels,node_direct_messages,node_reports,node_reporters,node_telemetry toneAmber
class node_api,node_api_routes,node_web toneMint
class node_admin_ui,node_admin_api,node_auth,node_setup,node_migrations toneRose
class node_logger,node_admin_user toneIndigo
```

## Components

### Ingestion

- [Report endpoint](https://github.com/anrijs/meshlog/blob/main/log.php): `log.php`
- [MeshLog service](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.class.php): `lib/meshlog.class.php`
- [Packet decoder](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.decoder.php): `lib/meshlog.decoder.php`

### Mesh records

- [Entity persistence](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.entity.class.php): `lib/meshlog.entity.class.php`
- **MySQL database**
- [Mesh activity records](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.advertisement.class.php): `lib/meshlog.advertisement.class.php`
- [Contacts](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.contact.class.php): `lib/meshlog.contact.class.php`
- [Channels and messages](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.channel_message.class.php): `lib/meshlog.channel_message.class.php`
- [Direct messages](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.direct_message.class.php): `lib/meshlog.direct_message.class.php`
- [Reception reports](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.report.class.php): `lib/meshlog.report.class.php`
- [Reporter nodes](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.reporter.class.php): `lib/meshlog.reporter.class.php`
- [Telemetry](https://github.com/anrijs/meshlog/blob/main/lib/meshlog.telemetry.class.php): `lib/meshlog.telemetry.class.php`

### Query interfaces

- [Versioned JSON API](https://github.com/anrijs/meshlog/blob/main/api/v1/all/index.php): `api/v1/all/index.php`
- [API query routes](https://github.com/anrijs/meshlog/tree/main/api/v1): `api/v1`
- [Activity web view](https://github.com/anrijs/meshlog/blob/main/index.php): `index.php`

### Administration

- [Reporter administration](https://github.com/anrijs/meshlog/blob/main/admin/index.php): `admin/index.php`
- [Reporter admin API](https://github.com/anrijs/meshlog/blob/main/admin/api/reporters/index.php): `admin/api/reporters/index.php`
- [Session authorization](https://github.com/anrijs/meshlog/blob/main/admin/api/loggedin.php): `admin/api/loggedin.php`
- [Database and account setup](https://github.com/anrijs/meshlog/blob/main/setup.php): `setup.php`
- [Schema migrations](https://github.com/anrijs/meshlog/blob/main/lib/migration.class.php): `lib/migration.class.php`

### Other components

- **MeshCore logger**
- **Administrator**

## Connections

- MeshCore logger → Report endpoint: posts reports (evidence: `README.md`)
- Report endpoint → MeshLog service: calls insert (evidence: `log.php`)
- MeshLog service → Packet decoder: decodes packets (evidence: `lib/meshlog.class.php`)
- MeshLog service → Mesh activity records: creates records (evidence: `lib/meshlog.class.php`)
- MeshLog service → Reception reports: creates reports (evidence: `lib/meshlog.class.php`)
- MeshLog service → Entity persistence: uses persistence (evidence: `lib/meshlog.class.php`)
- Entity persistence → MySQL database: reads and writes
- Mesh activity records → Entity persistence: inherits persistence (evidence: `lib/meshlog.advertisement.class.php`)
- Contacts → Entity persistence: inherits persistence
- Channels and messages → Entity persistence: inherits persistence
- Direct messages → Entity persistence: inherits persistence
- Reception reports → Entity persistence: inherits persistence (evidence: `lib/meshlog.report.class.php`)
- Reporter nodes → Entity persistence: inherits persistence
- Telemetry → Entity persistence: inherits persistence
- Versioned JSON API → MeshLog service: queries data (evidence: `api/v1/all/index.php`)
- API query routes → MeshLog service: serves queries (evidence: `api/v1/message_ids/index.php`)
- Activity web view → MeshLog service: uses service
- Administrator → Reporter administration: manages reporters (evidence: `README.md`)
- Reporter administration → Reporter admin API: fetches reporter data (evidence: `admin/index.php`)
- Reporter admin API → Session authorization: checks session (evidence: `admin/api/reporters/index.php`)
- Reporter admin API → MeshLog service: uses service
- Database and account setup → Schema migrations: runs migrations (evidence: `setup.php`)
- Database and account setup → MeshLog service: checks database (evidence: `setup.php`)
- Database and account setup → MySQL database: initializes database (evidence: `setup.php`)
