How hostel1359-source/trustos works
TRUSTOS is a Vizag urban-flooding digital twin: operators run a deterministic scenario or adjust simulated conditions, then follow source trust, detected conflicts, flood predictions and recommended actions on a live map. The React client combines backend event updates with city intelligence and presents them through map, alert, camera and analysis panels; route planning assesses exposure to scenario incidents. The FastAPI service exposes REST and WebSocket interfaces, while its documented intelligence stages cover trust, conflict, prediction and explanation. Backend orchestration details are only partly sampled, so links between those stages follow the documented architecture; optional live weather is separate from simulated telemetry.
Main entry points: MapPage.tsx City dashboard · demo_scenario.py Demo scenario · main.py FastAPI service · useDemoMode.ts Demo control hook
Components 27
Operator interface
- App shell
frontend/src/App.tsx - City dashboard
frontend/src/components/MapPage.tsx - City map
frontend/src/components/CityMap.tsx - 3D map
frontend/src/components/CesiumMap.tsx - Camera panel
frontend/src/components/CameraPanel.tsx - City alerts
frontend/src/components/CityAlerts.tsx - Prediction panel
frontend/src/components/PredictionPanel.tsx - Reality conflicts
frontend/src/components/RealityConflict.tsx - Trust scores
frontend/src/components/TrustScorePanel.tsx - Route planner
frontend/src/components/RoutePlanner.tsx - Scenario controls
frontend/src/components/SimulationControls.tsx
Client state and feeds
- Demo control hook
frontend/src/hooks/useDemoMode.ts - WebSocket hook
frontend/src/hooks/useWebSocket.ts - City intelligence hook
frontend/src/hooks/useCityIntelligence.ts - Client state
frontend/src/store/useTrustosStore.ts - Route exposure
frontend/src/utils/routeRisk.ts
Backend intelligence
- FastAPI service
backend/main.py - Mobile API
backend/routes/mobile_api.py - Demo scenario
backend/services/demo_scenario.py - Trust scoring
backend/services/trust_engine.py - Conflict detection
backend/services/conflict_detector.py - Flood prediction
backend/services/prediction_engine.py - Situation explanation
backend/services/llm_reasoning.py - WebSocket broadcast
backend/websocket/manager.py
City context
- Vizag context data
backend/data
Other components
- City operator
- Open-Meteo
Connections 35
- City operator → City dashboard: uses dashboard
- App shell → City dashboard: renders
- App shell → WebSocket hook: opens stream
- City dashboard → City map: presents map
- City dashboard → 3D map: presents 3D
- City dashboard → Camera panel: presents cameras
- City dashboard → City alerts: presents alerts
- City dashboard → Prediction panel: presents forecast
- City dashboard → Reality conflicts: presents conflicts
- City dashboard → Trust scores: presents scores
- City dashboard → Route planner: offers routing
- City dashboard → Scenario controls: offers controls
- Scenario controls → Demo control hook: controls scenario
- Demo control hook → FastAPI service: starts or stops
- Demo control hook → FastAPI service: posts changes
- Demo control hook → Client state: updates local state
- WebSocket hook → FastAPI service: connects stream
- FastAPI service → WebSocket broadcast: registers and broadcasts
- WebSocket hook → Client state: dispatches messages
- City intelligence hook → Client state: reads intelligence
- City intelligence hook → Mobile API: fetches zones
- Mobile API → Vizag context data: reads city context
- City intelligence hook → Open-Meteo: fetches weather
- Route planner → Route exposure: assesses exposure
- Route exposure → Vizag context data: uses incident context
- FastAPI service → Demo scenario: starts scenario
- Demo scenario → WebSocket broadcast: broadcasts updates
- Demo scenario → Trust scoring: scores sources
- Demo scenario → Conflict detection: checks conflicts
- Demo scenario → Flood prediction: predicts flooding
- Demo scenario → Situation explanation: explains situation
- FastAPI service → Trust scoring: recalculates trust
- Trust scoring → Conflict detection: provides trust scores
- Conflict detection → Flood prediction: provides conflict state
- Flood prediction → Situation explanation: provides prediction