# aidanismail/pilog-freight-desk architecture

> Architecture diagram of the GitHub repository aidanismail/pilog-freight-desk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aidanismail/pilog-freight-desk
- Repository: https://github.com/aidanismail/pilog-freight-desk

## Overview

PILOG Freight Desk is a React/FastAPI dry-bulk freight decision tool. Users configure a voyage and commercial inputs, calculate freight, then review market context, risk analysis, spread-matrix results and a commercial brief; completed cases can be retained in browser history or exported as packages. The graph separates UI, API/orchestration, calculation and decision logic, and reporting/data sources. Some backend routes and unsampled modules are represented only where the README or SOURCE INDEX supports them; uncertain wiring is omitted.

Main entry points: [`frontend/src/app/App.tsx`](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/app/App.tsx) (Case Workspace), [`src/pilog_cfr_dss/application/freight_desk.py`](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/application/freight_desk.py) (Case Evaluation), [`src/pilog_cfr_dss/api/main.py`](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/api/main.py) (FastAPI Routes), [`src/pilog_cfr_dss/calculations/freight_desk.py`](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/freight_desk.py) (Freight Calculation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Freight Desk UI"]
  node_app["Case Workspace<br/>[App.tsx]"]
  node_voyage["Voyage Inputs<br/>[inputs.tsx]"]
  node_hire["Hire Inputs<br/>[hire.tsx]"]
  node_riskui["Risk Panel<br/>[panel.tsx]"]
  node_matrixui["Spread Matrix<br/>[matrix.tsx]"]
  node_results["Brief Results<br/>[results.tsx]"]
  node_marketui["Market Context<br/>[context.tsx]"]
  node_history[("Case History<br/>[storage.ts]")]
  node_api_client["API Client<br/>[client.ts]"]
end

subgraph group_backend["API And Workflow"]
  node_api["FastAPI Routes<br/>[main.py]"]
  node_workflow["Case Evaluation<br/>[freight_desk.py]"]
  node_models["Case Models<br/>[freight_desk.py]"]
  node_validation["Numeric Validation<br/>[numbers.py]"]
  node_brief["Commercial Brief"]
  node_reportrisk["Risk Reporting<br/>[risk.py]"]
end

subgraph group_calculation["Freight Analysis"]
  node_freight["Freight Calculation<br/>[freight_desk.py]"]
  node_porttime["Port Time<br/>[port_time.py]"]
  node_riskcalc["Risk Analysis<br/>[risk.py]"]
  node_decisions["Risk Decisions<br/>[risk.py]"]
  node_freightdecision["Freight Recommendation<br/>[freight_desk.py]"]
end

subgraph group_data["Market And Reports"]
  node_baltic["Baltic Profiles<br/>[baltic_profiles.py]"]
  node_fertilizer["Fertilizer Reports"]
  node_routes["Route Distance<br/>[route_distance.py]"]
end

node_user(("Desk User"))

node_user -->|"configures case"| node_app
node_app -->|"renders inputs"| node_voyage
node_app -->|"renders inputs"| node_hire
node_app -->|"renders panel"| node_riskui
node_app -->|"renders matrix"| node_matrixui
node_app -->|"renders results"| node_results
node_app -->|"renders context"| node_marketui
node_app -->|"stores evaluations"| node_history
node_app -->|"requests data"| node_api_client
node_api_client -.->|"calls API"| node_api
node_api -->|"evaluates case"| node_workflow
node_workflow -->|"calculates costs"| node_freight
node_workflow -->|"recommends freight"| node_freightdecision
node_workflow -->|"assesses risk"| node_riskcalc
node_workflow -->|"uses case schema"| node_models
node_workflow -->|"validates inputs"| node_validation
node_workflow -->|"loads profiles"| node_baltic
node_workflow -->|"loads reports"| node_fertilizer
node_workflow -->|"updates route"| node_routes
node_freight -->|"calculates duration"| node_porttime
node_freight -->|"parses numbers"| node_validation
node_riskcalc -->|"uses risk rules"| node_decisions
node_api -->|"builds brief"| node_brief
node_brief -->|"includes risk"| node_reportrisk
node_user -->|"reopens cases"| node_history

click node_app "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/app/App.tsx"
click node_voyage "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/voyage/inputs.tsx"
click node_hire "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/market/hire.tsx"
click node_riskui "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/risk/panel.tsx"
click node_matrixui "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/spread-matrix/matrix.tsx"
click node_results "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/commercial-brief/results.tsx"
click node_marketui "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/market/context.tsx"
click node_history "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/case-history/storage.ts"
click node_api_client "https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/api/client.ts"
click node_api "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/api/main.py"
click node_workflow "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/application/freight_desk.py"
click node_models "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/models/freight_desk.py"
click node_validation "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/validation/numbers.py"
click node_freight "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/freight_desk.py"
click node_porttime "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/port_time.py"
click node_riskcalc "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/risk.py"
click node_decisions "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/decisions/risk.py"
click node_freightdecision "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/decisions/freight_desk.py"
click node_brief "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/reporting/commercial_brief.py"
click node_reportrisk "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/reporting/risk.py"
click node_baltic "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/baltic_profiles.py"
click node_fertilizer "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/fertilizer_reports.py"
click node_routes "https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/route_distance.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_app,node_voyage,node_hire,node_riskui,node_matrixui,node_results,node_marketui,node_history,node_api_client,node_user toneBlue
class node_api,node_workflow,node_models,node_validation,node_brief,node_reportrisk toneAmber
class node_freight,node_porttime,node_riskcalc,node_decisions,node_freightdecision toneMint
class node_baltic,node_fertilizer,node_routes toneRose
```

## Components

### Freight Desk UI

- [Case Workspace](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/app/App.tsx): `frontend/src/app/App.tsx`
- [Voyage Inputs](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/voyage/inputs.tsx): `frontend/src/features/voyage/inputs.tsx`
- [Hire Inputs](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/market/hire.tsx): `frontend/src/features/market/hire.tsx`
- [Risk Panel](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/risk/panel.tsx): `frontend/src/features/risk/panel.tsx`
- [Spread Matrix](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/spread-matrix/matrix.tsx): `frontend/src/features/spread-matrix/matrix.tsx`
- [Brief Results](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/commercial-brief/results.tsx): `frontend/src/features/commercial-brief/results.tsx`
- [Market Context](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/market/context.tsx): `frontend/src/features/market/context.tsx`
- [Case History](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/features/case-history/storage.ts): `frontend/src/features/case-history/storage.ts`
- [API Client](https://github.com/aidanismail/pilog-freight-desk/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### API And Workflow

- [FastAPI Routes](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/api/main.py): `src/pilog_cfr_dss/api/main.py`
- [Case Evaluation](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/application/freight_desk.py): `src/pilog_cfr_dss/application/freight_desk.py`
- [Case Models](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/models/freight_desk.py): `src/pilog_cfr_dss/models/freight_desk.py`
- [Numeric Validation](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/validation/numbers.py): `src/pilog_cfr_dss/validation/numbers.py`
- [Commercial Brief](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/reporting/commercial_brief.py): `src/pilog_cfr_dss/reporting/commercial_brief.py`
- [Risk Reporting](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/reporting/risk.py): `src/pilog_cfr_dss/reporting/risk.py`

### Freight Analysis

- [Freight Calculation](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/freight_desk.py): `src/pilog_cfr_dss/calculations/freight_desk.py`
- [Port Time](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/port_time.py): `src/pilog_cfr_dss/calculations/port_time.py`
- [Risk Analysis](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/calculations/risk.py): `src/pilog_cfr_dss/calculations/risk.py`
- [Risk Decisions](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/decisions/risk.py): `src/pilog_cfr_dss/decisions/risk.py`
- [Freight Recommendation](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/decisions/freight_desk.py): `src/pilog_cfr_dss/decisions/freight_desk.py`

### Market And Reports

- [Baltic Profiles](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/baltic_profiles.py): `src/pilog_cfr_dss/sources/baltic_profiles.py`
- [Fertilizer Reports](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/fertilizer_reports.py): `src/pilog_cfr_dss/sources/fertilizer_reports.py`
- [Route Distance](https://github.com/aidanismail/pilog-freight-desk/blob/main/src/pilog_cfr_dss/sources/route_distance.py): `src/pilog_cfr_dss/sources/route_distance.py`

### Other components

- **Desk User**

## Connections

- Desk User → Case Workspace: configures case
- Case Workspace → Voyage Inputs: renders inputs (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Hire Inputs: renders inputs (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Risk Panel: renders panel (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Spread Matrix: renders matrix (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Brief Results: renders results (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Market Context: renders context (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → Case History: stores evaluations (evidence: `frontend/src/app/App.tsx`)
- Case Workspace → API Client: requests data (evidence: `frontend/src/app/App.tsx`)
- API Client → FastAPI Routes: calls API
- FastAPI Routes → Case Evaluation: evaluates case (evidence: `src/pilog_cfr_dss/api/main.py`)
- Case Evaluation → Freight Calculation: calculates costs (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Freight Recommendation: recommends freight (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Risk Analysis: assesses risk (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Case Models: uses case schema (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Numeric Validation: validates inputs (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Baltic Profiles: loads profiles (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Fertilizer Reports: loads reports (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Case Evaluation → Route Distance: updates route (evidence: `src/pilog_cfr_dss/application/freight_desk.py`)
- Freight Calculation → Port Time: calculates duration (evidence: `src/pilog_cfr_dss/calculations/freight_desk.py`)
- Freight Calculation → Numeric Validation: parses numbers (evidence: `src/pilog_cfr_dss/calculations/freight_desk.py`)
- Risk Analysis → Risk Decisions: uses risk rules (evidence: `src/pilog_cfr_dss/calculations/risk.py`)
- FastAPI Routes → Commercial Brief: builds brief (evidence: `src/pilog_cfr_dss/api/main.py`)
- Commercial Brief → Risk Reporting: includes risk (evidence: `src/pilog_cfr_dss/reporting/commercial_brief.py`)
- Desk User → Case History: reopens cases
