How justasmit7/india-truck-freight-fleet-estimator works
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: App.tsx Operations shell · useAtcTelemetry.ts Live telemetry hook · routes_data.py Data routes · main.py Service entry
Components 18
Frontend runtime
Vite/React operations console.
- Browser UI
- React entry
src/main.tsx - Operations shell · Coordinates page state and operational views.
src/App.tsx - Navigation
src/components/Navbar.tsx - ATC error boundary
src/components/AtcErrorBoundary.tsx - Freight estimate UI · Estimator, cost breakdown, and route map.
src/components/FreightEstimatorForm.tsx - Local freight calculator · Provides deterministic immediate estimates.
src/utils/freightCalculator.ts - Fleet data and types · Local fleet seed data and shared contracts.
src/data/fleetData.ts - Dispatch documents · Creates manifests and bilty documents.
src/components/DispatchManifestModal.tsx - ATC API client
src/api/atcClient.ts - Live telemetry hook
src/hooks/useAtcTelemetry.ts - Telemetry and alerts · Presents live telemetry and operational alerts.
src/components/LiveTelemetryModal.tsx
Python service
Telemetry and AI agent boundary.
- Service entry
backend/main.py - Data routes · Exposes telemetry and operational data.
backend/routes_data.py - ATC agent · Evaluates and enriches operational events.
backend/atc_agent.py - Telemetry simulator
backend/telemetry_sim.py - Backend configuration · Centralizes service and AI settings.
backend/config.py
Other components
- Gemini API · AI capability accessed only through the backend.
Connections 18
- 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