# anzar-hue/sail-sih architecture

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

- Interactive diagram: https://gitdiagram.com/anzar-hue/sail-sih
- Repository: https://github.com/anzar-hue/sail-sih

## Overview

SAIL is a procurement and logistics decision dashboard that combines cargo-price estimates with port weather and demurrage risk. The main user flow is selecting cargo and port in the React terminal, requesting a simulation from Flask, and viewing updated risk, price, chart, and briefing data. The econometric engine separately trains and exports diagnostics for the Flask service to use. README documentation establishes the API and model-to-payload architecture; source excerpts show simulation internals. The V3 advisor is a separate CLI path, not part of the dashboard flow.

Main entry points: [`app.py`](https://github.com/anzar-hue/sail-sih/blob/main/app.py) (Flask API), [`frontend/src/ui.jsx`](https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/ui.jsx) (React Terminal), [`sail_v2_summary.json`](https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_summary.json) (Summary Payload), [`sail_v2_engine.py`](https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_engine.py) (SAIL Price Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_model["Econometric Modeling"]
  node_engine["SAIL Price Engine<br/>[sail_v2_engine.py]"]
  node_historical_data["Historical Datasets"]
end

subgraph group_backend["Risk and Briefing"]
  node_flask_api["Flask API<br/>[app.py]"]
  node_weather_risk["Weather Risk<br/>[app.py]"]
  node_trajectory["Trajectory Renderer<br/>[app.py]"]
  node_briefing["AI Briefing<br/>[app.py]"]
  node_v3_cli["V3 Advisor CLI"]
end

subgraph group_dashboard["Decision Dashboard"]
  node_terminal["React Terminal<br/>[ui.jsx]"]
  node_app_shell["App Shell<br/>[App.jsx]"]
  node_react_entry["React Entry<br/>[main.jsx]"]
end

subgraph group_state["Shared State"]
  node_sqlite_weather[("Weather Observations<br/>[sail_database.db]")]
  node_summary["Summary Payload"]
end

node_operator(("Procurement User"))
node_open_meteo["Open-Meteo"]
node_gemini["Google Gemini"]

node_operator -->|"selects cargo and port"| node_terminal
node_react_entry -->|"renders"| node_app_shell
node_app_shell -->|"renders"| node_terminal
node_terminal -->|"requests simulation"| node_flask_api
node_flask_api -->|"calculates risk"| node_weather_risk
node_weather_risk -->|"fetches forecast"| node_open_meteo
node_weather_risk -->|"reads fallback"| node_sqlite_weather
node_flask_api -->|"reads and updates"| node_summary
node_flask_api -->|"renders chart"| node_trajectory
node_flask_api -->|"requests memo"| node_briefing
node_briefing -.->|"generates briefing"| node_gemini
node_engine -->|"loads datasets"| node_historical_data
node_engine -->|"exports diagnostics"| node_summary
node_v3_cli -->|"loads diagnostics"| node_summary
node_v3_cli -.->|"duplicates risk logic"| node_weather_risk

click node_terminal "https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/ui.jsx"
click node_app_shell "https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/App.jsx"
click node_react_entry "https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/main.jsx"
click node_flask_api "https://github.com/anzar-hue/sail-sih/blob/main/app.py"
click node_weather_risk "https://github.com/anzar-hue/sail-sih/blob/main/app.py"
click node_trajectory "https://github.com/anzar-hue/sail-sih/blob/main/app.py"
click node_briefing "https://github.com/anzar-hue/sail-sih/blob/main/app.py"
click node_sqlite_weather "https://github.com/anzar-hue/sail-sih/blob/main/sail_database.db"
click node_engine "https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_engine.py"
click node_historical_data "https://github.com/anzar-hue/sail-sih/tree/main/data"
click node_summary "https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_summary.json"
click node_v3_cli "https://github.com/anzar-hue/sail-sih/blob/main/sail_v3_orchester.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_engine,node_historical_data,node_operator toneBlue
class node_flask_api,node_weather_risk,node_trajectory,node_briefing,node_v3_cli toneAmber
class node_terminal,node_app_shell,node_react_entry toneMint
class node_sqlite_weather,node_summary toneRose
class node_open_meteo,node_gemini toneIndigo
```

## Components

### Econometric Modeling

- [SAIL Price Engine](https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_engine.py): `sail_v2_engine.py`
- [Historical Datasets](https://github.com/anzar-hue/sail-sih/tree/main/data): `data`

### Risk and Briefing

- [Flask API](https://github.com/anzar-hue/sail-sih/blob/main/app.py): `app.py`
- [Weather Risk](https://github.com/anzar-hue/sail-sih/blob/main/app.py): `app.py`
- [Trajectory Renderer](https://github.com/anzar-hue/sail-sih/blob/main/app.py): `app.py`
- [AI Briefing](https://github.com/anzar-hue/sail-sih/blob/main/app.py): `app.py`
- [V3 Advisor CLI](https://github.com/anzar-hue/sail-sih/blob/main/sail_v3_orchester.py): `sail_v3_orchester.py`

### Decision Dashboard

- [React Terminal](https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/ui.jsx): `frontend/src/ui.jsx`
- [App Shell](https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [React Entry](https://github.com/anzar-hue/sail-sih/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`

### Shared State

- [Weather Observations](https://github.com/anzar-hue/sail-sih/blob/main/sail_database.db): `sail_database.db`
- [Summary Payload](https://github.com/anzar-hue/sail-sih/blob/main/sail_v2_summary.json): `sail_v2_summary.json`

### Other components

- **Procurement User**
- **Open-Meteo**
- **Google Gemini**

## Connections

- Procurement User → React Terminal: selects cargo and port (evidence: `frontend/src/ui.jsx`)
- React Entry → App Shell: renders (evidence: `frontend/src/main.jsx`)
- App Shell → React Terminal: renders (evidence: `frontend/src/App.jsx`)
- React Terminal → Flask API: requests simulation (evidence: `readme.md`)
- Flask API → Weather Risk: calculates risk (evidence: `app.py`)
- Weather Risk → Open-Meteo: fetches forecast (evidence: `app.py`)
- Weather Risk → Weather Observations: reads fallback (evidence: `app.py`)
- Flask API → Summary Payload: reads and updates (evidence: `app.py`)
- Flask API → Trajectory Renderer: renders chart (evidence: `app.py`)
- Flask API → AI Briefing: requests memo (evidence: `app.py`)
- AI Briefing → Google Gemini: generates briefing
- SAIL Price Engine → Historical Datasets: loads datasets (evidence: `readme.md`)
- SAIL Price Engine → Summary Payload: exports diagnostics (evidence: `readme.md`)
- V3 Advisor CLI → Summary Payload: loads diagnostics (evidence: `sail_v3_orchester.py`)
- V3 Advisor CLI → Weather Risk: duplicates risk logic
