# surajj7/voc-chidambaram-port architecture

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

- Interactive diagram: https://gitdiagram.com/surajj7/voc-chidambaram-port
- Repository: https://github.com/surajj7/voc-chidambaram-port

## Overview

This is a port container operations command center: stakeholder and simulated sensor events advance containers from inbound manifest through inspection, clearance and escrow release to departure. The backend serves the dashboard and APIs, maintains shipment state and a hash-chained ledger, and exposes dwell predictions and delay advice. Documented capabilities also include a GIS radar and Solidity escrow contract. Source excerpts establish the HTTP/backend, lifecycle, ledger and prediction connections; links to unsampled UI or contract behavior are shown only when documented.

Main entry points: [`backend/app.py`](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/app.py) (HTTP API), [`backend/core.py`](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py) (Event lifecycle), [`backend/static/dashboard.html`](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/static/dashboard.html) (Command dashboard), [`ml/train_model.py`](https://github.com/surajj7/voc-chidambaram-port/blob/main/ml/train_model.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Port Operations"]
  node_simulator["Lifecycle simulator<br/>[simulate.py]"]
  node_http["HTTP API<br/>[app.py]"]
  node_lifecycle["Event lifecycle<br/>[core.py]"]
  node_categories["Operational stages<br/>[core.py]"]
  node_gis["GIS radar<br/>[dashboard.html]"]
  node_shipmentfile[("Shipment state<br/>[state.json]")]
end

subgraph group_intelligence["Delay Intelligence"]
  node_prediction["Dwell prediction<br/>[core.py]"]
  node_mitigation["Delay mitigation<br/>[core.py]"]
  node_model["Random forest model<br/>[delay_model.joblib]"]
  node_training["Model training<br/>[train_model.py]"]
  node_dataset["Dwell dataset"]
end

subgraph group_integrity["Ledger and Escrow"]
  node_ledger[("Hash-chain ledger<br/>[core.py]")]
  node_ledgerfile[("Ledger state<br/>[ledger.json]")]
  node_contract["Escrow contract"]
end

subgraph group_interfaces["User Interfaces"]
  node_dashboard["Command dashboard<br/>[dashboard.html]"]
end

node_shipping(("Port stakeholders"))
node_users(("Port dashboard users"))

node_shipping -->|"supplies events"| node_simulator
node_simulator -->|"posts lifecycle events"| node_http
node_users -.->|"requests operations"| node_http
node_http -->|"serves dashboard"| node_dashboard
node_dashboard -.->|"uses API"| node_http
node_http -->|"processes events"| node_lifecycle
node_http -->|"requests predictions"| node_prediction
node_http -->|"enriches advice"| node_mitigation
node_http -->|"groups shipments"| node_categories
node_lifecycle -->|"sets stage"| node_categories
node_lifecycle -->|"forecasts inbound"| node_prediction
node_prediction -->|"predicts dwell"| node_model
node_prediction -.->|"assesses delay"| node_mitigation
node_training -->|"trains from"| node_dataset
node_training -->|"saves pipeline"| node_model
node_lifecycle -->|"appends events"| node_ledger
node_http -->|"verifies chain"| node_ledger
node_ledger -.->|"persists chain"| node_ledgerfile
node_http -.->|"loads and saves state"| node_shipmentfile
node_lifecycle -.->|"mirrors escrow rules"| node_contract
node_dashboard -.->|"displays harbor map"| node_gis

click node_simulator "https://github.com/surajj7/voc-chidambaram-port/blob/main/iot_simulator/simulate.py"
click node_http "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/app.py"
click node_lifecycle "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py"
click node_categories "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py"
click node_gis "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/static/dashboard.html"
click node_dashboard "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/static/dashboard.html"
click node_prediction "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py"
click node_mitigation "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py"
click node_model "https://github.com/surajj7/voc-chidambaram-port/blob/main/ml/model/delay_model.joblib"
click node_training "https://github.com/surajj7/voc-chidambaram-port/blob/main/ml/train_model.py"
click node_dataset "https://github.com/surajj7/voc-chidambaram-port/blob/main/data/voc_port_dwell_dataset.csv"
click node_ledger "https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py"
click node_ledgerfile "https://github.com/surajj7/voc-chidambaram-port/blob/main/runtime/ledger.json"
click node_shipmentfile "https://github.com/surajj7/voc-chidambaram-port/blob/main/runtime/state.json"
click node_contract "https://github.com/surajj7/voc-chidambaram-port/blob/main/contracts/ContainerTracker.sol"

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_simulator,node_http,node_lifecycle,node_categories,node_gis,node_shipmentfile,node_users toneBlue
class node_prediction,node_mitigation,node_model,node_training,node_dataset toneAmber
class node_ledger,node_ledgerfile,node_contract toneMint
class node_dashboard toneRose
class node_shipping toneIndigo
```

## Components

### Port Operations

- [Lifecycle simulator](https://github.com/surajj7/voc-chidambaram-port/blob/main/iot_simulator/simulate.py): `iot_simulator/simulate.py`
- [HTTP API](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/app.py): `backend/app.py`
- [Event lifecycle](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py): `backend/core.py`
- [Operational stages](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py): `backend/core.py`
- [GIS radar](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/static/dashboard.html): `backend/static/dashboard.html`
- [Shipment state](https://github.com/surajj7/voc-chidambaram-port/blob/main/runtime/state.json): `runtime/state.json`

### Delay Intelligence

- [Dwell prediction](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py): `backend/core.py`
- [Delay mitigation](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py): `backend/core.py`
- [Random forest model](https://github.com/surajj7/voc-chidambaram-port/blob/main/ml/model/delay_model.joblib): `ml/model/delay_model.joblib`
- [Model training](https://github.com/surajj7/voc-chidambaram-port/blob/main/ml/train_model.py): `ml/train_model.py`
- [Dwell dataset](https://github.com/surajj7/voc-chidambaram-port/blob/main/data/voc_port_dwell_dataset.csv): `data/voc_port_dwell_dataset.csv`

### Ledger and Escrow

- [Hash-chain ledger](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/core.py): `backend/core.py`
- [Ledger state](https://github.com/surajj7/voc-chidambaram-port/blob/main/runtime/ledger.json): `runtime/ledger.json`
- [Escrow contract](https://github.com/surajj7/voc-chidambaram-port/blob/main/contracts/ContainerTracker.sol): `contracts/ContainerTracker.sol`

### User Interfaces

- [Command dashboard](https://github.com/surajj7/voc-chidambaram-port/blob/main/backend/static/dashboard.html): `backend/static/dashboard.html`

### Other components

- **Port stakeholders**
- **Port dashboard users**

## Connections

- Port stakeholders → Lifecycle simulator: supplies events (evidence: `iot_simulator/simulate.py`)
- Lifecycle simulator → HTTP API: posts lifecycle events (evidence: `iot_simulator/simulate.py`)
- Port dashboard users → HTTP API: requests operations
- HTTP API → Command dashboard: serves dashboard (evidence: `backend/app.py`)
- Command dashboard → HTTP API: uses API
- HTTP API → Event lifecycle: processes events (evidence: `backend/app.py`)
- HTTP API → Dwell prediction: requests predictions (evidence: `backend/app.py`)
- HTTP API → Delay mitigation: enriches advice (evidence: `backend/app.py`)
- HTTP API → Operational stages: groups shipments (evidence: `backend/app.py`)
- Event lifecycle → Operational stages: sets stage (evidence: `backend/core.py`)
- Event lifecycle → Dwell prediction: forecasts inbound (evidence: `backend/core.py`)
- Dwell prediction → Random forest model: predicts dwell (evidence: `backend/core.py`)
- Dwell prediction → Delay mitigation: assesses delay (evidence: `backend/core.py`)
- Model training → Dwell dataset: trains from (evidence: `ml/train_model.py`)
- Model training → Random forest model: saves pipeline (evidence: `ml/train_model.py`)
- Event lifecycle → Hash-chain ledger: appends events (evidence: `backend/core.py`)
- HTTP API → Hash-chain ledger: verifies chain (evidence: `backend/app.py`)
- Hash-chain ledger → Ledger state: persists chain
- HTTP API → Shipment state: loads and saves state
- Event lifecycle → Escrow contract: mirrors escrow rules (evidence: `README.md`)
- Command dashboard → GIS radar: displays harbor map (evidence: `README.md`)
