How supratim-2006/traffic-website works
1. Overall shape
This is a TanStack Start application: a React 19 UI with SSR via Nitro, built and served as a full-stack web app rather than a purely client-side SPA. The main user experience is a traffic operations dashboard for incident management.
2. Request and render entry points
The app boots through src/start.ts and src/server.ts, which define the client/server execution boundary. src/router.tsx plus the generated src/routeTree.gen.ts wire up the TanStack Router tree, while src/routes/__root.tsx provides the shared layout shell and src/routes/index.tsx is the primary dashboard route.
3. Primary domain surface
The core product area lives under src/components/dashboard/. These components form the command-center workflow: incident intake, location selection, live detection, congestion analysis, map-based diversion routing, dispatch recommendations, and results summaries. The dashboard is decomposed into many focused panels rather than one monolith.
4. Data flow through the dashboard
A typical flow is: incident input / location selection → analysis modules (emergency detection, congestion scoring, predictions, detected objects, heatmap) → recommendations and dispatch → route diversion visualization. Components like IncidentInput, LocationPicker, CongestionAnalysis, Predictions, Recommendations, DispatchPanel, and RoutingDiversions suggest the UI is organized around this operational pipeline.
5. Map and geospatial layer
Geospatial rendering is a major subsystem. TrafficHeatmap, DiversionRouteMap, and RoutingDiversions indicate the app uses Leaflet and Leaflet.heat to show incident locations, congestion intensity, and alternative routes. The custom type declaration in src/types/leaflet-heat.d.ts exists to support the heatmap integration cleanly in TypeScript.
6. API and integration boundary
src/lib/traffic-api.ts is the likely integration layer for traffic-related data and analysis. The README also calls out TanStack Query, so the app probably treats external or server-backed traffic data as queryable resources rather than embedding fetch logic in UI components. This keeps network concerns separated from presentation.
7. Shared UI system
src/components/ui/ contains the reusable design-system primitives, likely generated from shadcn/ui and built on Radix UI. These are the low-level building blocks used across the dashboard for dialogs, tabs, sheets, tables, buttons, inputs, etc., while the dashboard-specific components compose those primitives into operational screens.
8. Layout, navigation, and responsiveness
DashboardLayout, TopBar, WorkflowSidebar, TabContent, and SectionHeader define the app shell and navigation hierarchy. src/hooks/use-mobile.tsx suggests responsive behavior is centralized so the dashboard can adapt between desktop control-room layouts and smaller screens.
9. Error handling and resilience
src/lib/error-capture.ts, src/lib/error-page.ts, and src/lib/lovable-error-reporting.ts indicate explicit error boundary/reporting support. This matters because the app likely depends on live data and map rendering, both of which need graceful failure states.
10. Styling and global assets
Global styling is driven by src/styles.css with Tailwind CSS v4. Static assets live in public/, and the components.json configuration confirms the shadcn/ui pipeline. The repo is optimized for a design-system-driven UI rather than custom CSS per component.
11. Type and build-time boundaries
src/types/ holds shared TypeScript definitions, while src/routeTree.gen.ts is generated and should be treated as build output, not source of truth. The build setup (vite.config.ts, bunfig.toml, package.json) is oriented around Bun for install/run and Vite/TanStack Start for bundling.
12. Deployment model
The README states deployment targets Vercel using the TanStack Start preset. In architecture terms, that means the app is shipped as an SSR-capable web service with static asset delivery and server-side rendering managed by the framework/runtime, not a separate backend repository.
Main entry points: DashboardLayout.tsx Dashboard shell · traffic-api.ts Traffic API · CongestionAnalysis.tsx Congestion analysis · ui UI primitives
Components 26
Runtime & entry
SSR app bootstrap, router wiring, and server/client boundary.
- App start · Client-side TanStack Start bootstrap entry.
src/start.ts - Server entry · Server-side runtime entry for Nitro/SSR.
src/server.ts - Router · TanStack Router configuration and route wiring.
src/router.tsx - Route tree · Generated TanStack route tree.
src/routeTree.gen.ts - Root layout · Shared app shell and global route wrapper.
src/routes/__root.tsx - Dashboard route · Primary dashboard screen entry route.
src/routes/index.tsx
Dashboard domain
Traffic operations workflow and map-centered incident handling UI.
- Dashboard shell · Top-level dashboard layout and page framing.
src/components/dashboard/DashboardLayout.tsx - Top bar · Global header and top-level controls.
src/components/dashboard/TopBar.tsx - Sidebar · Navigation and workflow staging for the dashboard.
src/components/dashboard/WorkflowSidebar.tsx - Tab content · Panel container for dashboard sections.
src/components/dashboard/TabContent.tsx - Incident input · Incident intake and initial case details.
src/components/dashboard/IncidentInput.tsx - Location picker · Incident location selection and geospatial targeting.
src/components/dashboard/LocationPicker.tsx - Congestion analysis · Traffic congestion scoring and operational analysis.
src/components/dashboard/CongestionAnalysis.tsx - Detection · Emergency detection and incident recognition logic in the UI flow.
src/components/dashboard/EmergencyDetection.tsx - Predictions · Forward-looking traffic or incident predictions.
src/components/dashboard/Predictions.tsx - Diversions · Route diversion orchestration and guidance output.
src/components/dashboard/RoutingDiversions.tsx - Dispatch panel · Dispatch recommendations and response actions.
src/components/dashboard/DispatchPanel.tsx - Recommendations · Recommended operational actions derived from analysis.
src/components/dashboard/Recommendations.tsx - Heatmap · Traffic intensity visualization using Leaflet heatmap integration.
src/components/dashboard/TrafficHeatmap.tsx - Route map · Map-based visualization of diversion routes.
src/components/dashboard/DiversionRouteMap.tsx
Shared UI system
Reusable design-system primitives and general-purpose UI helpers.
- UI primitives · Reusable shadcn/Radix-style components used throughout the app.
src/components/ui
Infra & integration
Data access, error handling, styling, and type/runtime support.
- Traffic API · Integration layer for traffic-related data and analysis.
src/lib/traffic-api.ts - Error support · Error capture, reporting, and error page utilities.
src/lib/error-capture.ts - Global styles · Global stylesheet and theme layer.
src/styles.css - Leaflet types · TypeScript declaration for Leaflet heatmap support.
src/types/leaflet-heat.d.ts - Mobile hook · Centralized responsive behavior for smaller screens.
src/hooks/use-mobile.tsx
Connections 29
- App start → Router: boots · Client bootstrap enters routing stack.
- Server entry → Router: serves · Server runtime serves the routed app.
- Router → Route tree: uses · Router consumes generated route tree.
- Route tree → Root layout: includes · Generated tree includes the root route.
- Root layout → Dashboard route: nests · Root layout wraps the dashboard page route.
- Dashboard route → Dashboard shell: renders · Main route composes dashboard shell.
- Dashboard shell → Top bar: contains · Layout includes the top-level header.
- Dashboard shell → Sidebar: contains · Layout includes workflow navigation.
- Dashboard shell → Tab content: contains · Layout hosts tabbed dashboard content.
- Tab content → Incident input: starts · Incident intake begins the workflow.
- Incident input → Location picker: feeds · Incident details lead into location selection.
- Location picker → Detection: initiates · Location/context feeds detection stage.
- Detection → Congestion analysis: updates · Detection informs congestion analysis.
- Congestion analysis → Predictions: feeds · Analysis results drive predictions.
- Congestion analysis → Heatmap: visualizes · Congestion intensity is shown on the heatmap.
- Predictions → Recommendations: drives · Forecasts inform recommended actions.
- Recommendations → Dispatch panel: prompts · Recommendations surface dispatch actions.
- Dispatch panel → Diversions: coordinates · Dispatch decisions coordinate diversions.
- Diversions → Route map: renders · Diversion workflow is visualized on the map.
- Traffic API → Congestion analysis: supplies data · Analysis pulls traffic data from the integration layer.
- Traffic API → Predictions: supplies data · Prediction stage can query traffic data.
- Traffic API → Diversions: supplies data · Diversion planning can use external traffic data.
- Error support → Dashboard shell: guards · App shell can present resilient error states.
- Error support → Traffic API: reports · Integration errors are captured and reported.
- Global styles → UI primitives: styles · Global styling supports the shared component system.
- UI primitives → Dashboard shell: builds · Layout uses shared primitives.
- UI primitives → Incident input: builds · Form and input widgets are composed from primitives.
- Mobile hook → Dashboard shell: adapts · Responsive behavior shapes the dashboard shell.
- Leaflet types → Heatmap: supports · Type declaration supports heatmap integration.