# gokulkrisnaa-n/food-delivery-prediction architecture

> Architecture diagram of the GitHub repository gokulkrisnaa-n/food-delivery-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gokulkrisnaa-n/food-delivery-prediction
- Repository: https://github.com/gokulkrisnaa-n/food-delivery-prediction

## Overview

This repository serves food-delivery-time predictions through a FastAPI endpoint backed by a serialized XGBoost pipeline. The request workflow is order submission, API validation, pipeline inference, and a versioned prediction response; a separate offline workflow cleans training data, engineers features, trains and evaluates the regressor, and saves the pipeline. Optuna tuning informs model parameters. The training, tuning, and artifact-generation links are evidenced by excerpts; deployment details are documented, but deployment infrastructure is not mapped as runtime code.

Main entry points: [`app/model/delivery_time_xgb.py`](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py) (Training workflow), [`app/main.py`](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py) (FastAPI service), [`app/model/delivery_time_pipeline_0.1.0.joblib`](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_pipeline_0.1.0.joblib) (Serialized pipeline), [`app/hyperparameter-tuning/tune_xgb.py`](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/hyperparameter-tuning/tune_xgb.py) (Optuna tuning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Prediction service"]
  node_api["FastAPI service<br/>[main.py]"]
  node_validation["Request validation<br/>[main.py]"]
  node_inference["Prediction handler<br/>[main.py]"]
  node_pipeline[("Serialized pipeline")]
end

subgraph group_ml["Model development"]
  node_training["Training workflow"]
  node_features["Feature engineering"]
  node_regressor["XGBoost regressor"]
  node_tuning["Optuna tuning<br/>[tune_xgb.py]"]
end

subgraph group_data["Model data"]
  node_bestparams["Tuned parameters<br/>[best_params.json]"]
  node_trainingdata["Training data<br/>[train.csv]"]
  node_testdata["Test data<br/>[test.csv]"]
  node_submission["Test predictions<br/>[submission.csv]"]
end

node_client(("Order client"))

node_client -->|"submits order"| node_api
node_api -->|"validates request"| node_validation
node_api -->|"routes prediction"| node_inference
node_inference -->|"loads and predicts"| node_pipeline
node_pipeline -->|"returns estimate"| node_inference
node_training -->|"reads"| node_trainingdata
node_training -->|"reads"| node_testdata
node_training -->|"fits and transforms"| node_features
node_training -->|"trains and evaluates"| node_regressor
node_training -->|"serializes"| node_pipeline
node_training -->|"writes predictions"| node_submission
node_tuning -->|"uses preprocessing"| node_features
node_tuning -->|"writes parameters"| node_bestparams

click node_api "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py"
click node_validation "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py"
click node_inference "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py"
click node_pipeline "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_pipeline_0.1.0.joblib"
click node_training "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py"
click node_features "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py"
click node_regressor "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py"
click node_tuning "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/hyperparameter-tuning/tune_xgb.py"
click node_bestparams "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/hyperparameter-tuning/best_params.json"
click node_trainingdata "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/train.csv"
click node_testdata "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/test.csv"
click node_submission "https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/submission.csv"

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_api,node_validation,node_inference,node_pipeline,node_client toneBlue
class node_training,node_features,node_regressor,node_tuning toneAmber
class node_bestparams,node_trainingdata,node_testdata,node_submission toneMint
```

## Components

### Prediction service

- [FastAPI service](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py): `app/main.py`
- [Request validation](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py): `app/main.py`
- [Prediction handler](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/main.py): `app/main.py`
- [Serialized pipeline](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_pipeline_0.1.0.joblib): `app/model/delivery_time_pipeline_0.1.0.joblib`

### Model development

- [Training workflow](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py): `app/model/delivery_time_xgb.py`
- [Feature engineering](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py): `app/model/delivery_time_xgb.py`
- [XGBoost regressor](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/delivery_time_xgb.py): `app/model/delivery_time_xgb.py`
- [Optuna tuning](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/hyperparameter-tuning/tune_xgb.py): `app/hyperparameter-tuning/tune_xgb.py`

### Model data

- [Tuned parameters](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/hyperparameter-tuning/best_params.json): `app/hyperparameter-tuning/best_params.json`
- [Training data](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/train.csv): `app/model/train.csv`
- [Test data](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/test.csv): `app/model/test.csv`
- [Test predictions](https://github.com/gokulkrisnaa-n/food-delivery-prediction/blob/main/app/model/submission.csv): `app/model/submission.csv`

### Other components

- **Order client**

## Connections

- Order client → FastAPI service: submits order (evidence: `README.md`)
- FastAPI service → Request validation: validates request (evidence: `app/main.py`)
- FastAPI service → Prediction handler: routes prediction (evidence: `app/main.py`)
- Prediction handler → Serialized pipeline: loads and predicts (evidence: `app/main.py`)
- Serialized pipeline → Prediction handler: returns estimate (evidence: `app/main.py`)
- Training workflow → Training data: reads (evidence: `app/model/delivery_time_xgb.py`)
- Training workflow → Test data: reads (evidence: `app/model/delivery_time_xgb.py`)
- Training workflow → Feature engineering: fits and transforms (evidence: `app/model/delivery_time_xgb.py`)
- Training workflow → XGBoost regressor: trains and evaluates (evidence: `app/model/delivery_time_xgb.py`)
- Training workflow → Serialized pipeline: serializes (evidence: `app/model/delivery_time_xgb.py`)
- Training workflow → Test predictions: writes predictions (evidence: `app/model/delivery_time_xgb.py`)
- Optuna tuning → Feature engineering: uses preprocessing (evidence: `app/hyperparameter-tuning/tune_xgb.py`)
- Optuna tuning → Tuned parameters: writes parameters (evidence: `app/hyperparameter-tuning/tune_xgb.py`)
