# 2026dts/sea_port architecture

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

- Interactive diagram: https://gitdiagram.com/2026dts/sea_port
- Repository: https://github.com/2026dts/sea_port

## Overview

Sea_port is a crane-control, power-monitoring, and RFID container-tracking system. The main workflow is the Flask backend polling one ESP32 over HTTP, storing telemetry and container data in SQLite, and serving dashboard tabs and widgets; dashboard commands also control the cranes and reader. The README documents container registration, bay assignment, missing-tag alerts, manifest editing, analytics, and reader diagnostics. These are documented capabilities, but the large app.py excerpt is incomplete, so internal links beyond the shown storage and polling behavior rely on the README. The two PC reader scripts are legacy standalone tools, not part of the main workflow.

Main entry points: [`app.py`](https://github.com/2026dts/sea_port/blob/master/app.py) (Flask API), [`Sea_port/Sea_port.ino`](https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino) (ESP32 Firmware), [`sea_port.db`](https://github.com/2026dts/sea_port/blob/master/sea_port.db) (Sea Port Database), [`Reader_Without_RM.py`](https://github.com/2026dts/sea_port/blob/master/Reader_Without_RM.py) (Legacy Reader Tool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Crane Control"]
  node_firmware["ESP32 Firmware<br/>[Sea_port.ino]"]
  node_cranes["Crane Actuators<br/>[Sea_port.ino]"]
  node_power["Power Sensors<br/>[Sea_port.ino]"]
end

subgraph group_tracking["Container Tracking"]
  node_rfid["RFID Inventory<br/>[Sea_port.ino]"]
  node_reader["UHF Reader"]
  node_container_registry["Container Registry<br/>[app.py]"]
  node_bay_plan["Vessel Bay Plan<br/>[app.py]"]
  node_alerts["Missing-Tag Alerts<br/>[app.py]"]
end

subgraph group_backend["Backend and Data"]
  node_dashboard["Dashboard and Widgets<br/>[app.py]"]
  node_poller["ESP32 Poller<br/>[app.py]"]
  node_api["Flask API<br/>[app.py]"]
  node_sqlite[("Sea Port Database<br/>[sea_port.db]")]
  node_analytics["Trends and Analytics<br/>[app.py]"]
end

subgraph group_legacy["Legacy Reader Tools"]
  node_legacy_without["Legacy Reader Tool"]
  node_legacy_with["Legacy Reader Tool<br/>[Reader_with_RM.py]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"requests data"| node_api
node_api -->|"reads and writes"| node_sqlite
node_poller -->|"polls over HTTP"| node_firmware
node_firmware -->|"controls"| node_cranes
node_firmware -->|"reads sensors"| node_power
node_firmware -->|"runs inventory"| node_rfid
node_rfid -->|"reads tags"| node_reader
node_api -->|"registers EPCs"| node_container_registry
node_container_registry -->|"stores manifest"| node_sqlite
node_container_registry -->|"assigns slots"| node_bay_plan
node_api -->|"tracks missing tags"| node_alerts
node_alerts -->|"shows alarms"| node_dashboard
node_api -->|"serves history"| node_analytics
node_analytics -->|"reads telemetry"| node_sqlite
node_operator -.->|"runs separately"| node_legacy_without
node_operator -.->|"runs separately"| node_legacy_with

click node_dashboard "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_poller "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_api "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_sqlite "https://github.com/2026dts/sea_port/blob/master/sea_port.db"
click node_firmware "https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino"
click node_cranes "https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino"
click node_power "https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino"
click node_rfid "https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino"
click node_container_registry "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_bay_plan "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_alerts "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_analytics "https://github.com/2026dts/sea_port/blob/master/app.py"
click node_legacy_without "https://github.com/2026dts/sea_port/blob/master/Reader_Without_RM.py"
click node_legacy_with "https://github.com/2026dts/sea_port/blob/master/Reader_with_RM.py"

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_cranes,node_power toneBlue
class node_rfid,node_reader,node_container_registry,node_bay_plan,node_alerts toneAmber
class node_dashboard,node_poller,node_api,node_sqlite,node_analytics toneMint
class node_legacy_without,node_legacy_with toneRose
class node_operator toneIndigo
```

## Components

### Crane Control

- [ESP32 Firmware](https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino): `Sea_port/Sea_port.ino`
- [Crane Actuators](https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino): `Sea_port/Sea_port.ino`
- [Power Sensors](https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino): `Sea_port/Sea_port.ino`

### Container Tracking

- [RFID Inventory](https://github.com/2026dts/sea_port/blob/master/Sea_port/Sea_port.ino): `Sea_port/Sea_port.ino`
- **UHF Reader**
- [Container Registry](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`
- [Vessel Bay Plan](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`
- [Missing-Tag Alerts](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`

### Backend and Data

- [Dashboard and Widgets](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`
- [ESP32 Poller](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`
- [Flask API](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`
- [Sea Port Database](https://github.com/2026dts/sea_port/blob/master/sea_port.db): `sea_port.db`
- [Trends and Analytics](https://github.com/2026dts/sea_port/blob/master/app.py): `app.py`

### Legacy Reader Tools

- [Legacy Reader Tool](https://github.com/2026dts/sea_port/blob/master/Reader_Without_RM.py): `Reader_Without_RM.py`
- [Legacy Reader Tool](https://github.com/2026dts/sea_port/blob/master/Reader_with_RM.py): `Reader_with_RM.py`

### Other components

- **Operator**

## Connections

- Operator → Dashboard and Widgets: uses (evidence: `README.md`)
- Dashboard and Widgets → Flask API: requests data (evidence: `README.md`)
- Flask API → Sea Port Database: reads and writes (evidence: `app.py`)
- ESP32 Poller → ESP32 Firmware: polls over HTTP (evidence: `README.md`)
- ESP32 Firmware → Crane Actuators: controls (evidence: `README.md`)
- ESP32 Firmware → Power Sensors: reads sensors (evidence: `README.md`)
- ESP32 Firmware → RFID Inventory: runs inventory (evidence: `README.md`)
- RFID Inventory → UHF Reader: reads tags (evidence: `README.md`)
- Flask API → Container Registry: registers EPCs (evidence: `README.md`)
- Container Registry → Sea Port Database: stores manifest (evidence: `README.md`)
- Container Registry → Vessel Bay Plan: assigns slots (evidence: `README.md`)
- Flask API → Missing-Tag Alerts: tracks missing tags (evidence: `README.md`)
- Missing-Tag Alerts → Dashboard and Widgets: shows alarms (evidence: `README.md`)
- Flask API → Trends and Analytics: serves history (evidence: `README.md`)
- Trends and Analytics → Sea Port Database: reads telemetry (evidence: `app.py`)
- Operator → Legacy Reader Tool: runs separately (evidence: `Reader_Without_RM.py`)
- Operator → Legacy Reader Tool: runs separately (evidence: `Reader_with_RM.py`)
