# justasmit7/india-truck-freight-fleet-estimator architecture

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

- Interactive diagram: https://gitdiagram.com/justasmit7/india-truck-freight-fleet-estimator
- Repository: https://github.com/justasmit7/india-truck-freight-fleet-estimator

## Overview

#### Purpose and Entry Points
This is an AI-assisted freight/dispatch operations application with a React frontend and a separate Python backend for ATC-style telemetry/agent behavior. The browser starts at `src/main.tsx`, renders the application shell in `src/App.tsx`, and calls backend functionality through `src/api/atcClient.ts`. The backend process entry point is `backend/main.py`.

#### Frontend Operations Console
The Vite/TypeScript UI composes fleet, routing, estimating, alerting, and dispatch workflows. `src/App.tsx` coordinates page-level state and operational views; `src/components/Navbar.tsx` provides navigation; `src/components/AtcErrorBoundary.tsx` contains failures from ATC-integrated UI areas.

Core freight interactions are represented by `src/components/FreightEstimatorForm.tsx`, `src/components/CostBreakdownCard.tsx`, and `src/components/RouteMap.tsx`.

#### Fleet and Dispatch Domain
Fleet data is initially represented client-side in `src/data/fleetData.ts`, with shared application/domain types in `src/types.ts` and ATC-specific contracts in `src/types/atc.ts`. Operational workflows include fleet lookup (`src/components/FleetDirectory.tsx`), dispatch-manifest generation (`src/components/DispatchManifestModal.tsx`), and bilty/document generation (`src/components/BiltyGeneratorModal.tsx`).

The frontend also contains deterministic local calculation support in `src/utils/freightCalculator.ts`; this forms a boundary between immediate UI-side estimates and backend/agent-driven telemetry behavior.

#### ATC Telemetry and Agent Boundary
The backend separates its service entry point, agent logic, simulated data source, and data routes: `backend/main.py`, `backend/atc_agent.py`, `backend/telemetry_sim.py`, and `backend/routes_data.py`. The frontend consumes this capability through `src/api/atcClient.ts` and manages live updates in `src/hooks/useAtcTelemetry.ts`.

The intended flow is: UI requests/subscribes through the API client, backend routes provide telemetry/data, the telemetry simulator supplies operational events, and the ATC agent evaluates or enriches those events before the UI presents them in `src/components/LiveTelemetryModal.tsx` and `src/components/AlertPanel.tsx`.

#### AI and External Service Integration
The application requires a Gemini API key, as specified by the README and `.env.example`; Gemini is therefore the material external AI dependency. Backend configuration is centralized in `backend/config.py`, with backend environment expectations documented in `backend/.env.example`. AI/agent calls should remain behind the Python backend rather than being coupled directly to presentation components.

#### Runtime and Deployment Shape
The client is a Node.js/Vite TypeScript application, indicated by `package.json`, `vite.config.ts`, and `src/main.tsx`. The service tier is Python with independently declared dependencies in `backend/requirements.txt`. Local development can run the frontend through the README’s `npm run dev` flow; the repository structure supports deploying the frontend and backend as separate runtime units, connected by the API boundary in `src/api/atcClient.ts`.

Main entry points: [`src/App.tsx`](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/App.tsx) (Operations shell), [`src/hooks/useAtcTelemetry.ts`](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/hooks/useAtcTelemetry.ts) (Live telemetry hook), [`backend/routes_data.py`](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/routes_data.py) (Data routes), [`backend/main.py`](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/main.py) (Service entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend runtime"]
  node_browser(("Browser UI<br/>runtime"))
  node_main["React entry<br/>TypeScript entry<br/>[main.tsx]"]
  node_app["Operations shell<br/>React application<br/>[App.tsx]"]
  node_navbar["Navigation<br/>React component<br/>[Navbar.tsx]"]
  node_atc_boundary["ATC error boundary<br/>React boundary"]
  node_freight_workflow["Freight estimate UI<br/>React components"]
  node_local_calculator["Local freight calculator<br/>TypeScript utility"]
  node_fleet_data["Fleet data and types<br/>client domain model<br/>[fleetData.ts]"]
  node_dispatch_workflow["Dispatch documents<br/>React components"]
  node_atc_client{{"ATC API client<br/>TypeScript API boundary<br/>[atcClient.ts]"}}
  node_telemetry_hook["Live telemetry hook<br/>React hook<br/>[useAtcTelemetry.ts]"]
  node_telemetry_ui["Telemetry and alerts<br/>React components"]
end

subgraph group_backend["Python service"]
  node_backend_main["Service entry<br/>Python entry point<br/>[main.py]"]
  node_data_routes{{"Data routes<br/>Python routes<br/>[routes_data.py]"}}
  node_atc_agent["ATC agent<br/>Python agent<br/>[atc_agent.py]"]
  node_telemetry_sim["Telemetry simulator<br/>Python event source<br/>[telemetry_sim.py]"]
  node_backend_config["Backend configuration<br/>Python configuration<br/>[config.py]"]
end

node_gemini{{"Gemini API<br/>external AI service"}}

node_browser -->|"loads"| node_main
node_main -->|"renders"| node_app
node_app -->|"includes"| node_navbar
node_app -->|"contains ATC areas"| node_atc_boundary
node_app -->|"drives"| node_freight_workflow
node_freight_workflow -->|"calculates locally"| node_local_calculator
node_app -->|"uses"| node_fleet_data
node_app -->|"opens"| node_dispatch_workflow
node_app -->|"uses"| node_telemetry_hook
node_telemetry_hook -->|"requests and subscribes"| node_atc_client
node_telemetry_hook -->|"supplies updates"| node_telemetry_ui
node_atc_client -->|"API boundary"| node_backend_main
node_backend_main -->|"serves"| node_data_routes
node_data_routes -->|"reads events"| node_telemetry_sim
node_data_routes -->|"enriches through"| node_atc_agent
node_atc_agent -->|"AI calls"| node_gemini
node_backend_config -->|"configures"| node_atc_agent
node_backend_config -->|"configures"| node_backend_main

click node_main "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/main.tsx"
click node_app "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/App.tsx"
click node_navbar "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/Navbar.tsx"
click node_atc_boundary "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/AtcErrorBoundary.tsx"
click node_freight_workflow "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/FreightEstimatorForm.tsx"
click node_local_calculator "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/utils/freightCalculator.ts"
click node_fleet_data "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/data/fleetData.ts"
click node_dispatch_workflow "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/DispatchManifestModal.tsx"
click node_atc_client "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/api/atcClient.ts"
click node_telemetry_hook "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/hooks/useAtcTelemetry.ts"
click node_telemetry_ui "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/LiveTelemetryModal.tsx"
click node_backend_main "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/main.py"
click node_data_routes "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/routes_data.py"
click node_atc_agent "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/atc_agent.py"
click node_telemetry_sim "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/telemetry_sim.py"
click node_backend_config "https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/config.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_browser,node_main,node_app,node_navbar,node_atc_boundary,node_freight_workflow,node_local_calculator,node_fleet_data,node_dispatch_workflow,node_atc_client,node_telemetry_hook,node_telemetry_ui toneBlue
class node_backend_main,node_data_routes,node_atc_agent,node_telemetry_sim,node_backend_config toneAmber
class node_gemini toneNeutral
```

## Components

### Frontend runtime

Vite/React operations console.

- **Browser UI**: runtime
- [React entry](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/main.tsx): TypeScript entry · `src/main.tsx`
- [Operations shell](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/App.tsx): React application · Coordinates page state and operational views. · `src/App.tsx`
- [Navigation](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/Navbar.tsx): React component · `src/components/Navbar.tsx`
- [ATC error boundary](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/AtcErrorBoundary.tsx): React boundary · `src/components/AtcErrorBoundary.tsx`
- [Freight estimate UI](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/FreightEstimatorForm.tsx): React components · Estimator, cost breakdown, and route map. · `src/components/FreightEstimatorForm.tsx`
- [Local freight calculator](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/utils/freightCalculator.ts): TypeScript utility · Provides deterministic immediate estimates. · `src/utils/freightCalculator.ts`
- [Fleet data and types](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/data/fleetData.ts): client domain model · Local fleet seed data and shared contracts. · `src/data/fleetData.ts`
- [Dispatch documents](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/DispatchManifestModal.tsx): React components · Creates manifests and bilty documents. · `src/components/DispatchManifestModal.tsx`
- [ATC API client](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/api/atcClient.ts): TypeScript API boundary · `src/api/atcClient.ts`
- [Live telemetry hook](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/hooks/useAtcTelemetry.ts): React hook · `src/hooks/useAtcTelemetry.ts`
- [Telemetry and alerts](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/src/components/LiveTelemetryModal.tsx): React components · Presents live telemetry and operational alerts. · `src/components/LiveTelemetryModal.tsx`

### Python service

Telemetry and AI agent boundary.

- [Service entry](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/main.py): Python entry point · `backend/main.py`
- [Data routes](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/routes_data.py): Python routes · Exposes telemetry and operational data. · `backend/routes_data.py`
- [ATC agent](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/atc_agent.py): Python agent · Evaluates and enriches operational events. · `backend/atc_agent.py`
- [Telemetry simulator](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/telemetry_sim.py): Python event source · `backend/telemetry_sim.py`
- [Backend configuration](https://github.com/justasmit7/india-truck-freight-fleet-estimator/blob/main/backend/config.py): Python configuration · Centralizes service and AI settings. · `backend/config.py`

### Other components

- **Gemini API**: external AI service · AI capability accessed only through the backend.

## Connections

- Browser UI → React entry: loads
- React entry → Operations shell: renders
- Operations shell → Navigation: includes
- Operations shell → ATC error boundary: contains ATC areas
- Operations shell → Freight estimate UI: drives
- Freight estimate UI → Local freight calculator: calculates locally
- Operations shell → Fleet data and types: uses
- Operations shell → Dispatch documents: opens
- Operations shell → Live telemetry hook: uses
- Live telemetry hook → ATC API client: requests and subscribes
- Live telemetry hook → Telemetry and alerts: supplies updates
- ATC API client → Service entry: API boundary
- Service entry → Data routes: serves
- Data routes → Telemetry simulator: reads events
- Data routes → ATC agent: enriches through
- ATC agent → Gemini API: AI calls
- Backend configuration → ATC agent: configures
- Backend configuration → Service entry: configures
