How muskaanpopat/ev-analytics-bda works
EVInsight is a Washington State EV adoption analytics platform: users explore dashboards and vehicle records, while the REST API returns analytics from MongoDB or falls back to CSV processing. The principal path is dashboard interaction → API client → backend route/controller → analytics service → data source → displayed results. Separate capabilities cover MapReduce results, MongoDB analytics, Spark and Spark SQL, health checks, and exports. The README documents a cleaning/import and batch-processing pipeline, but the sampled code does not establish all operational connections between those batch tools and the backend.
Main entry points: App.tsx Page router · apiRoutes.ts API route dispatch · api.ts API client · mongoService.ts Mongo analytics
Components 34
Web interface
- Page router
frontend/src/App.tsx - Analytics dashboard
frontend/src/pages/Dashboard.tsx - Vehicle explorer
frontend/src/pages/DataExplorerPage.tsx - Insights view
frontend/src/pages/InsightsPage.tsx - MapReduce view
frontend/src/pages/HdfsMapReducePage.tsx - MongoDB view
frontend/src/pages/MongoDbPage.tsx - Spark views
frontend/src/pages/SparkPage.tsx - Spark SQL view
frontend/src/pages/SparkSqlPage.tsx - Pipeline overview
frontend/src/pages/TechPipelinePage.tsx - API client
frontend/src/services/api.ts
REST backend
- Express server
backend/src/server.ts - API route dispatch
backend/src/routes/apiRoutes.ts - Analytics routes
backend/src/routes/analyticsRoutes.ts - Analytics controller
backend/src/controllers/analyticsController.ts - MapReduce controller
backend/src/controllers/mapreduceController.ts - Spark controller
backend/src/controllers/sparkController.ts - Export controller
backend/src/controllers/exportController.ts - Health controller
backend/src/controllers/healthController.ts - Health routes
backend/src/routes/healthRoutes.ts - MapReduce routes
backend/src/routes/mapreduceRoutes.ts - Spark routes
backend/src/routes/sparkRoutes.ts - Export routes
backend/src/routes/exportRoutes.ts
Analytics and data
- Mongo analytics
backend/src/services/mongoService.ts - CSV analytics fallback
backend/src/services/csvDataService.ts - Mongo connection
backend/src/database/mongoClient.ts - EV vehicle collection
- Health service
backend/src/services/healthService.ts
Batch processing
- Spark service
backend/src/services/sparkService.ts - MapReduce service
backend/src/services/mapreduceService.ts - Map stage
mapreduce/ev_mapper.py - Reduce stage
mapreduce/ev_reducer.py - Spark analysis
spark/ev_analysis.py - Spark result saving
spark/ev_save_results.py
Other components
- Dashboard user
Connections 41
- Dashboard user → Page router: uses
- Page router → Analytics dashboard: routes
- Page router → Vehicle explorer: routes
- Page router → Insights view: routes
- Page router → MapReduce view: routes
- Page router → MongoDB view: routes
- Page router → Spark views: routes
- Page router → Spark SQL view: routes
- Page router → Pipeline overview: routes
- Analytics dashboard → API client: requests data
- Vehicle explorer → API client: requests records
- Insights view → API client: requests data
- MapReduce view → API client: requests results
- MongoDB view → API client: requests analytics
- Spark views → API client: requests analytics
- Spark SQL view → API client: submits query
- API client → Express server: sends requests
- Express server → API route dispatch: mounts routes
- API route dispatch → Analytics routes: dispatches
- API route dispatch → Analytics controller: dispatches vehicles
- API route dispatch → MapReduce routes: dispatches
- API route dispatch → Spark routes: dispatches
- API route dispatch → Export routes: dispatches
- API route dispatch → Health routes: dispatches
- Analytics routes → Analytics controller: dispatches
- MapReduce routes → MapReduce controller: dispatches
- Spark routes → Spark controller: dispatches
- Export routes → Export controller: dispatches
- Health routes → Health controller: dispatches
- Analytics controller → Mongo analytics: requests analytics
- Mongo analytics → Mongo connection: gets connection
- Mongo connection → EV vehicle collection: connects
- Mongo analytics → EV vehicle collection: queries
- Mongo analytics → CSV analytics fallback: falls back
- Analytics controller → CSV analytics fallback: requests records
- Spark controller → Spark service: requests execution
- MapReduce controller → MapReduce service: requests results
- Health controller → Health service: checks status
- Export controller → Dashboard user: streams export
- Map stage → Reduce stage: emits pairs
- Spark analysis → Spark result saving: saves results