How 23e46pratham-lab/ecu-monitoring works
1. Overall shape
- This is a single-page frontend application built with React + TypeScript + Vite.
- There is no separate backend service in the repo; the app talks directly to external services from the client.
2. App bootstrap and composition
- index.html, src/main.tsx, and src/App.tsx form the runtime entry path.
- App.tsx is the top-level composition layer that likely wires together the main screens/widgets: dashboard, gauges, health monitor, chat, and driver-aura visualization.
3. Presentation layer
- src/components/ contains the UI boundaries:
- Dashboard.tsx for the main status overview
- Gauges.tsx for metric visualization
- HealthMonitor.tsx for vehicle/AI health status
- ChatInterface.tsx for conversational interaction
- DriverAura.tsx for driver-state or behavior visualization
- These components appear to be the main consumer of computed data and service outputs.
4. Domain/analytics logic
- src/logic/ holds the app’s core non-UI computations:
- driverBehavior.ts for driving pattern scoring or classification
- mileage.ts for distance/usage calculations
- mlHealth.ts for model- or health-related scoring
- This is the main boundary where raw telemetry becomes higher-level insights shown in the UI.
5. Vehicle/telemetry simulation
- src/services/ecuSimulator.ts suggests the app can generate or emulate ECU-like vehicle data.
- That simulator is likely the source of the app’s operational signals, feeding the analytics logic and dashboard widgets without requiring a physical vehicle connection.
6. AI integration
- src/services/geminiService.ts is the integration point for Google Gemini.
- The README explicitly requires GEMINI_API_KEY, so the chat/assistant experience is powered directly from the frontend via this service.
- This is a key external boundary: UI requests → Gemini service → model response → chat UI.
7. Firebase boundary
- src/firebase.ts plus firestore.rules indicate Firebase/Firestore is used as a cloud data layer.
- The repo includes Firebase config files (firebase-applet-config.json, firebase-blueprint.json), implying the app may persist or sync state/results through Firestore.
- firestore.rules is the security boundary controlling what client-side writes/reads are allowed.
8. Shared types and utilities
- src/types.ts centralizes the app’s data contracts, which likely connect the simulator, logic layer, and UI components.
- src/lib/utils.ts provides shared helper behavior used across components or calculations.
- These files reduce coupling between the UI and the telemetry/AI logic.
9. Data flow through the app
- The typical flow is:
- simulated or stored vehicle data originates from the ECU simulator or Firestore,
- domain logic transforms it into mileage, behavior, and health metrics,
- UI components render those metrics in dashboard/gauge/monitor views,
- the chat interface sends prompts to Gemini and displays responses,
- Firebase may persist or retrieve state depending on the feature.
10. Runtime and deployment assumptions
- The app runs in the browser and is started locally with npm run dev.
- vite.config.ts and package-lock.json indicate a standard Vite-based frontend build/development workflow.
- public/ is the static asset boundary for files served directly by the app.
11. What to draw in an architecture diagram
- A clean diagram would show:
- React UI shell at the center
- UI components on one side
- Logic layer between UI and data sources
- ECU simulator as a local data source
- Gemini API as an external AI service
- Firebase/Firestore as a cloud persistence layer with rules as the security boundary
- The main architectural distinction is between presentation, pure computation, and external service integrations.
Main entry points: App.tsx App · types.ts types.ts · ecuSimulator.ts ECU Simulator · firebase.ts firebase.ts
Components 18
Bootstrap
Browser entry and application root
- index.html · Browser document that loads the app
index.html - main.tsx · Bootstraps the React application
src/main.tsx - App · Top-level UI composition and wiring
src/App.tsx - public · Static files served directly by Vite
public
UI
Presentation components and screens
- Dashboard · Main status and summary view
src/components/Dashboard.tsx - Gauges · Metric and gauge visualization
src/components/Gauges.tsx - Health Monitor · Vehicle and AI health display
src/components/HealthMonitor.tsx - Chat · Conversational interaction surface
src/components/ChatInterface.tsx - Driver Aura · Driver-state or behavior visualization
src/components/DriverAura.tsx
Logic
Domain calculations and derived insights
- driverBehavior · Driving pattern analysis and classification
src/logic/driverBehavior.ts - mileage · Distance and usage calculations
src/logic/mileage.ts - mlHealth · Model or health-related scoring
src/logic/mlHealth.ts
Services
Local simulators and external API adapters
- ECU Simulator · Generates or emulates vehicle signals
src/services/ecuSimulator.ts - Gemini Service · Frontend integration for Gemini requests
src/services/geminiService.ts
Cloud
Firebase and Firestore boundary
- firebase.ts · Firebase client setup and access layer
src/firebase.ts - firestore.rules · Firestore read/write access rules
firestore.rules
Connections 27
- index.html → main.tsx: loads · Browser document loads the React entry
- main.tsx → App: mounts · React mounts the application root
- App → Dashboard: composes · Top-level screen composition
- App → Gauges: composes · Renders metric widgets
- App → Health Monitor: composes · Renders health status view
- App → Chat: composes · Renders assistant chat UI
- App → Driver Aura: composes · Renders driver-state visualization
- App → ECU Simulator: consumes · Uses simulated telemetry as an input source
- App → firebase.ts: syncs · Connects to Firebase-backed state or data
- App → types.ts: shares · Uses shared contracts across features
- Dashboard → mileage: renders · Displays usage and distance derived metrics
- Dashboard → mlHealth: renders · Displays health-derived insights
- Gauges → mileage: visualizes · Turns computed metrics into gauges
- Health Monitor → mlHealth: visualizes · Shows health scoring and diagnostics
- Driver Aura → driverBehavior: visualizes · Shows behavior scoring and classification
- driverBehavior → types.ts: uses · Relies on shared telemetry and result shapes
- mileage → types.ts: uses · Uses shared measurement contracts
- mlHealth → types.ts: uses · Uses shared health data contracts
- ECU Simulator → types.ts: produces · Emits telemetry-shaped app data
- ECU Simulator → driverBehavior: feeds · Supplies inputs for behavioral analysis
- ECU Simulator → mileage: feeds · Supplies inputs for usage calculations
- ECU Simulator → mlHealth: feeds · Supplies inputs for health scoring
- Chat → Gemini Service: calls · Sends prompts to the AI adapter
- Gemini Service → firebase.ts: may persist · Can coordinate with app data or stored state
- firebase.ts → firestore.rules: governed by · Firestore access is constrained by rules
- firebase.ts → types.ts: uses · Firebase-bound data is typed through shared contracts
- utils.ts → App: supports · Shared helper behavior used across the app