# nithinrogers/flight-delay-prediction architecture

> Architecture diagram of the GitHub repository nithinrogers/flight-delay-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nithinrogers/flight-delay-prediction
- Repository: https://github.com/nithinrogers/flight-delay-prediction

## Overview

#### 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: [`backend/flight_service.py`](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/flight_service.py) (Prediction service), [`frontend/src/config.js`](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/config.js) (API endpoint config), [`backend/app.py`](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/app.py) (Process-hosted API), [`backend/train_model.py`](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/train_model.py) (Offline training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React dashboard"]
  node_browser_entry["Browser entry<br/>React bootstrap<br/>[index.js]"]
  node_app["Dashboard composition<br/>React application<br/>[App.js]"]
  node_api_config["API endpoint config<br/>frontend configuration<br/>[config.js]"]
  node_dashboard_views["Operational views<br/>React components<br/>[PredictionPanel.js]"]
end

subgraph group_api["Prediction API"]
  node_backend_app["Process-hosted API<br/>Python HTTP entry<br/>[app.py]"]
  node_serverless_api["Serverless API<br/>Python HTTP entry<br/>[index.py]"]
  node_flight_service["Prediction service<br/>inference service<br/>[flight_service.py]"]
  node_weather_service["Weather enrichment<br/>external integration<br/>[weather_service.py]"]
end

subgraph group_ml["Model lifecycle"]
  node_training["Offline training<br/>model training entry<br/>[train_model.py]"]
  node_model_artifacts[("Primary model artifacts<br/>XGBoost model and encoders<br/>[xgb_model.pkl]")]
  node_india_model[("India model variant<br/>regional XGBoost artifacts")]
  node_model_metrics["Model quality metrics<br/>model metadata<br/>[metrics.json]"]
end

subgraph group_deploy["Deployment targets"]
  node_process_deploy{{"PaaS backend<br/>process deployment<br/>[render.yaml]"}}
  node_serverless_deploy{{"Vercel API deployment<br/>serverless deployment<br/>[vercel.json]"}}
  node_static_deploy{{"Vercel frontend deployment<br/>static deployment<br/>[vercel.json]"}}
end

node_weather_provider(("Weather provider<br/>external service"))

node_browser_entry -->|"mounts"| node_app
node_app -->|"uses"| node_api_config
node_app -->|"composes"| node_dashboard_views
node_dashboard_views -->|"resolve API target"| node_api_config
node_api_config -.->|"hosted API option"| node_backend_app
node_api_config -.->|"serverless API option"| node_serverless_api
node_backend_app -->|"dispatches"| node_flight_service
node_serverless_api -->|"dispatches"| node_flight_service
node_flight_service -->|"enriches with weather"| node_weather_service
node_weather_service -->|"retrieves weather"| node_weather_provider
node_flight_service -->|"loads model and schema"| node_model_artifacts
node_flight_service -.->|"selects regional model"| node_india_model
node_backend_app -.->|"serves quality data"| node_model_metrics
node_dashboard_views -.->|"presents metrics"| node_model_metrics
node_training -->|"writes"| node_model_artifacts
node_training -->|"writes variant"| node_india_model
node_training -->|"writes evaluation"| node_model_metrics
node_process_deploy -->|"runs"| node_backend_app
node_serverless_deploy -->|"deploys"| node_serverless_api
node_static_deploy -->|"serves"| node_browser_entry

click node_browser_entry "https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/index.js"
click node_app "https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/App.js"
click node_api_config "https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/config.js"
click node_dashboard_views "https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/components/PredictionPanel.js"
click node_backend_app "https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/app.py"
click node_serverless_api "https://github.com/nithinrogers/flight-delay-prediction/blob/main/api/index.py"
click node_flight_service "https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/flight_service.py"
click node_weather_service "https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/weather_service.py"
click node_training "https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/train_model.py"
click node_model_artifacts "https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/xgb_model.pkl"
click node_india_model "https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/xgb_booster_india.json"
click node_model_metrics "https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/metrics.json"
click node_process_deploy "https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/render.yaml"
click node_serverless_deploy "https://github.com/nithinrogers/flight-delay-prediction/blob/main/vercel.json"
click node_static_deploy "https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser_entry,node_app,node_api_config,node_dashboard_views toneBlue
class node_backend_app,node_serverless_api,node_flight_service,node_weather_service toneAmber
class node_training,node_model_artifacts,node_india_model,node_model_metrics toneMint
class node_process_deploy,node_serverless_deploy,node_static_deploy toneRose
class node_weather_provider toneNeutral
```

## Components

### React dashboard

- [Browser entry](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/index.js): React bootstrap · `frontend/src/index.js`
- [Dashboard composition](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/App.js): React application · Composes operational flight and prediction views. · `frontend/src/App.js`
- [API endpoint config](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/config.js): frontend configuration · `frontend/src/config.js`
- [Operational views](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/src/components/PredictionPanel.js): React components · Prediction, flight board, propagation, booking advice, and metrics panels. · `frontend/src/components/PredictionPanel.js`

### Prediction API

- [Process-hosted API](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/app.py): Python HTTP entry · `backend/app.py`
- [Serverless API](https://github.com/nithinrogers/flight-delay-prediction/blob/main/api/index.py): Python HTTP entry · `api/index.py`
- [Prediction service](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/flight_service.py): inference service · Separates prediction logic from HTTP transport. · `backend/flight_service.py`
- [Weather enrichment](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/weather_service.py): external integration · `backend/weather_service.py`

### Model lifecycle

- [Offline training](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/train_model.py): model training entry · Produces runtime model artifacts; it is not run per request. · `backend/train_model.py`
- [Primary model artifacts](https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/xgb_model.pkl): XGBoost model and encoders · Serialized model, categorical encoders, and feature schema. · `models/xgb_model.pkl`
- [India model variant](https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/xgb_booster_india.json): regional XGBoost artifacts · Alternate regional model and metadata. · `models/xgb_booster_india.json`
- [Model quality metrics](https://github.com/nithinrogers/flight-delay-prediction/blob/main/models/metrics.json): model metadata · Metrics and statistics support quality reporting. · `models/metrics.json`

### Deployment targets

- [PaaS backend](https://github.com/nithinrogers/flight-delay-prediction/blob/main/backend/render.yaml): process deployment · `backend/render.yaml`
- [Vercel API deployment](https://github.com/nithinrogers/flight-delay-prediction/blob/main/vercel.json): serverless deployment · `vercel.json`
- [Vercel frontend deployment](https://github.com/nithinrogers/flight-delay-prediction/blob/main/frontend/vercel.json): static deployment · `frontend/vercel.json`

### Other components

- **Weather provider**: external service

## Connections

- 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
