How nakshatra-naksh/ridershipforcast works
1. This repo is a three-tier forecasting system: a React/Vite frontend, a Node.js/Express API layer, and a Python machine-learning engine. The main architectural boundary is between user interaction and model execution; the backend orchestrates the Python process rather than embedding the ML code in Node.
2. The frontend lives under src/ and is a single-page app bootstrapped by src/main.jsx and src/App.jsx. It provides the interactive forecasting workflow: choose route, choose stop, pick a date, submit a forecast request, and display results.
3. The UI is decomposed into focused components:
- RouteSelector and StopSelector handle transit-filter selection.
- DatePicker collects the forecast date.
- ForecastResults renders the returned forecast summary and metrics.
- ModelChart visualizes the predicted hourly series.
This separation suggests a presentation layer built around a single forecast request/response flow.
4. Frontend state and API calls are isolated in src/services/forecastService.js. That service is the client-side integration point with the backend, which keeps request logic out of the UI components and makes the forecast API the main contract between tiers.
5. The static transit reference data is bundled in src/data/routes.js and src/data/stops.js. These files likely drive the selector options and define the routing/stop hierarchy that constrains user input before the forecast request is sent.
6. The backend entry point is server.js, which is the orchestration layer for the application. Based on the README, it exposes an API endpoint such as /api/forecast and invokes the Python forecast script as a subprocess, acting as the bridge between HTTP requests and the ML pipeline.
7. The forecasting engine is forecast.py, which implements the SARIMAX time-series workflow described in the README. Its responsibilities are data loading, stop-level filtering, model training/validation, future hourly prediction, and returning forecast values plus evaluation metrics such as MAE/RMSE and confidence.
8. The core dataset is aggregated_hourly_data.csv, a stop-level hourly passenger-count history. This is the main data source for the ML engine and is the reason the architecture is centered on time-series forecasting rather than transactional or streaming ingestion.
9. The system’s data flow is:
user selection in React → API call via forecastService → Express route in server.js → Python execution in forecast.py → forecast output returned to the frontend → chart/results rendering. This end-to-end path is the most important diagram arrow sequence.
10. The runtime stack is split by responsibility: Vite/React for the browser UI, Node.js for HTTP orchestration, Python with pandas/numpy/statsmodels for forecasting. requirements.txt and package.json confirm the dual-runtime setup, while vite.config.js and index.html support frontend bundling.
11. Styling and presentation are kept in CSS files alongside components, including src/App.css, src/index.css, and component-specific styles such as DatePicker.css, RouteSelector.css, StopSelector.css, and ForecastResults.css. This indicates the visualization layer is self-contained and does not affect the model pipeline.
12. Operationally, start.sh and the README’s run instructions imply the repo is designed to launch both the API and the frontend together. The important deployment boundary is therefore not microservices, but a coordinated local/full-stack startup with a single backend API serving the ML requests.
13. For an architecture diagram, the main boxes should be: Browser UI, React components/services, Express API, Python SARIMAX engine, and CSV dataset. The key external dependency is the Python scientific stack; the key internal dependency is the API contract that carries route/stop/date inputs and forecast outputs across the language boundary.
Main entry points: App.jsx App Shell · forecast.py SARIMAX Engine · server.js Express API · main.jsx Bootstrapped UI
Components 17
Browser UI
React/Vite presentation layer for selecting inputs and showing forecasts.
- Browser · User-facing runtime where the forecast workflow is executed.
- App Shell · Top-level React application composition and forecast flow container.
src/App.jsx - Bootstrapped UI · Client entry point that mounts the React app.
src/main.jsx - Route Selector · Chooses the transit route for forecasting.
src/components/RouteSelector.jsx - Stop Selector · Chooses the stop filtered by the selected route.
src/components/StopSelector.jsx - Date Picker · Collects the forecast date input.
src/components/DatePicker.jsx - Forecast Results · Displays forecast summary and evaluation metrics.
src/components/ForecastResults.jsx - Model Chart · Plots the predicted hourly series.
src/components/ModelChart.jsx - Forecast Service · Client-side contract for sending forecast requests to the backend.
src/services/forecastService.js
API Orchestration
Node/Express layer that receives requests and launches the forecasting engine.
- Express API · HTTP orchestration layer and forecast endpoint boundary.
server.js - Python Bridge · Launches the forecasting script from Node and returns results across the language boundary.
server.js
Forecast Engine
Python SARIMAX workflow and its data source.
- SARIMAX Engine · Time-series forecasting workflow that loads data, trains, predicts, and computes metrics.
forecast.py - Hourly CSV · Aggregated stop-level hourly passenger counts used by the model.
aggregated_hourly_data.csv
Shared Assets
Static inputs and app entry points that support the runtime flow.
- Routes Data · Transit route options used by the selector UI.
src/data/routes.js - Stops Data · Stop options and route-stop relationships used by the selector UI.
src/data/stops.js - UI Styles · Presentation styling for the React components and app shell.
src/App.css - Runtime Configs · Frontend bundling and backend dependency manifests supporting the split runtime.
package.json
Connections 18
- Browser → Bootstrapped UI: loads · The browser loads the React entry point.
- Bootstrapped UI → App Shell: mounts · Bootstraps the top-level app shell.
- App Shell → Route Selector: composes · App shell includes route selection.
- App Shell → Stop Selector: composes · App shell includes stop selection.
- App Shell → Date Picker: composes · App shell includes date input.
- App Shell → Forecast Results: renders · App shell displays forecast output.
- App Shell → Model Chart: renders · App shell displays the prediction chart.
- Route Selector → Routes Data: reads · Route options are sourced from static reference data.
- Stop Selector → Stops Data: reads · Stop options are sourced from static reference data.
- App Shell → Forecast Service: requests · UI workflow submits forecast requests through the client service.
- Forecast Service → Express API: calls · Forecast service sends the HTTP request to the backend API.
- Express API → Python Bridge: orchestrates · Express route delegates model execution to the subprocess bridge.
- Python Bridge → SARIMAX Engine: invokes · Node launches the Python forecasting script.
- SARIMAX Engine → Hourly CSV: trains on · The SARIMAX workflow reads historical hourly passenger data.
- SARIMAX Engine → Forecast Results: returns · Forecast values and metrics are sent back to the API and then the UI.
- SARIMAX Engine → Model Chart: feeds · Predicted series powers the model chart visualization.
- UI Styles → App Shell: styles · Shared CSS supports the React shell and components.
- Runtime Configs → Express API: supports · Project manifests and runtime setup support the server layer.