How nithinrogers/flight-delay-prediction works
Purpose and Entrypoints
SkyPredict is a flight-delay prediction system with a React dashboard, Python prediction APIs, and persisted XGBoost model artifacts. Main server entry candidates are backend/app.py for the backend service and api/index.py for a serverless/API deployment. The browser application starts at frontend/src/index.js and composes its UI from frontend/src/App.js.
Frontend Application
The React frontend presents operational flight, delay-prediction, propagation, and booking-advice views. frontend/src/App.js is the application composition boundary; frontend/src/config.js likely centralizes API endpoint selection. Core user-facing stages are represented by:
• frontend/src/components/PredictionPanel.js
• frontend/src/components/FlightBoard.js
• frontend/src/components/PropagationView.js
• frontend/src/components/BookingAdvisor.js
• frontend/src/components/ModelMetrics.js
The separately committed public/ directory is a built static bundle, while frontend/ is the editable source application.
Prediction API and Service Boundary
Python HTTP handling is split between backend/app.py and api/index.py, suggesting support for conventional process-hosted and serverless deployment targets. Prediction-specific logic is separated from transport concerns in backend/flight_service.py; weather enrichment is isolated in backend/weather_service.py. This establishes an API boundary between browser requests and model/scoring dependencies.
Model Inference Assets
Inference depends on checked-in serialized model and feature-preparation artifacts under models/. Primary assets include:
• models/xgb_model.pkl
• models/xgb_booster.json
• models/encoders.pkl
• models/feature_cols.json
• models/metrics.json
There is also a distinct India-oriented model set (models/xgb_booster_india.json, models/model_india_metadata.json, models/encoders_india.json), indicating model selection or alternate regional inference behavior. API/service code must preserve the feature schema and categorical encodings expected by these artifacts.
Training and Data Lifecycle
backend/train_model.py is the offline training entry point. Its output boundary is the versioned-on-disk models/ directory, consumed later by runtime inference rather than retrained per request. models/stats.json and models/metrics.json support presentation or validation of model quality in the backend and frontend.
External Dependencies and Runtime
The backend is Python-based, with dependencies declared in backend/requirements.txt; the API deployment has its own api/requirements.txt. Weather retrieval is an external-service integration behind backend/weather_service.py, and environment-provided secrets/configuration are indicated by backend/.env.example. The frontend is Node/React-based via frontend/package.json.
Deployment Topology
Multiple deployment descriptors support different hosting modes: backend/Procfile and backend/render.yaml target a process/PaaS backend, while frontend/vercel.json and root vercel.json support Vercel deployment. Root Procfile, run.sh, and start.bat provide process or local-launch entry paths. The architecture therefore permits a static/frontend deployment calling either a separately hosted backend or the api/index.py serverless endpoint.
Main entry points: flight_service.py Prediction service · config.js API endpoint config · app.py Process-hosted API · train_model.py Offline training
Components 16
React dashboard
- Browser entry
frontend/src/index.js - Dashboard composition · Composes operational flight and prediction views.
frontend/src/App.js - API endpoint config
frontend/src/config.js - Operational views · Prediction, flight board, propagation, booking advice, and metrics panels.
frontend/src/components/PredictionPanel.js
Prediction API
- Process-hosted API
backend/app.py - Serverless API
api/index.py - Prediction service · Separates prediction logic from HTTP transport.
backend/flight_service.py - Weather enrichment
backend/weather_service.py
Model lifecycle
- Offline training · Produces runtime model artifacts; it is not run per request.
backend/train_model.py - Primary model artifacts · Serialized model, categorical encoders, and feature schema.
models/xgb_model.pkl - India model variant · Alternate regional model and metadata.
models/xgb_booster_india.json - Model quality metrics · Metrics and statistics support quality reporting.
models/metrics.json
Deployment targets
- PaaS backend
backend/render.yaml - Vercel API deployment
vercel.json - Vercel frontend deployment
frontend/vercel.json
Other components
- Weather provider
Connections 20
- Browser entry → Dashboard composition: mounts
- Dashboard composition → API endpoint config: uses
- Dashboard composition → Operational views: composes
- Operational views → API endpoint config: resolve API target
- API endpoint config → Process-hosted API: hosted API option
- API endpoint config → Serverless API: serverless API option
- Process-hosted API → Prediction service: dispatches
- Serverless API → Prediction service: dispatches
- Prediction service → Weather enrichment: enriches with weather
- Weather enrichment → Weather provider: retrieves weather
- Prediction service → Primary model artifacts: loads model and schema
- Prediction service → India model variant: selects regional model
- Process-hosted API → Model quality metrics: serves quality data
- Operational views → Model quality metrics: presents metrics
- Offline training → Primary model artifacts: writes
- Offline training → India model variant: writes variant
- Offline training → Model quality metrics: writes evaluation
- PaaS backend → Process-hosted API: runs
- Vercel API deployment → Serverless API: deploys
- Vercel frontend deployment → Browser entry: serves