# esraa-elgebaly/uber-fare-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/esraa-elgebaly/uber-fare-prediction
- Repository: https://github.com/esraa-elgebaly/uber-fare-prediction

## Overview

This repository is an Uber-fare prediction project with Flask interfaces around a saved scikit-learn pipeline. The main workflow accepts trip details, validates them, predicts a base fare, and applies ride-type, surge, and promo rules to produce a final estimate. It also exposes activity and pickup-heat data, and includes a separate JSON endpoint implementation. Task3 contains a parallel app and pipeline. The overview README is brief; connections for unsampled UI behavior and model loading are therefore limited to what the excerpts show.

Main entry points: [`app.py`](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py) (Web app), [`Task3/app.py`](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/app.py) (Task3 web app), [`app_predict_endpoint.py`](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app_predict_endpoint.py) (JSON prediction), [`Task3/mobile.html`](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/mobile.html) (Mobile form)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_web_app["Web app<br/>[app.py]"]
  node_main_form["Fare form"]
  node_mobile_form["Mobile form<br/>[mobile.html]"]
  node_task3_app["Task3 web app<br/>[app.py]"]
  node_json_endpoint["JSON prediction"]
end

subgraph group_pricing["Fare estimation"]
  node_request_checks["Input validation<br/>[app.py]"]
  node_price_rules["Fare rules<br/>[app.py]"]
  node_model_pipeline["Fare pipeline<br/>[fare_pipeline.py]"]
  node_trained_model["Saved model"]
  node_task3_pipeline["Task3 pipeline<br/>[fare_pipeline.py]"]
end

subgraph group_support["Trip support"]
  node_activity_store[("Activity history<br/>[activity.json]")]
  node_pickup_data["Pickup data"]
end

node_rider(("Rider"))

node_rider -->|"submits trip"| node_web_app
node_web_app -->|"renders"| node_main_form
node_web_app -->|"validates"| node_request_checks
node_request_checks -->|"passes valid trip"| node_price_rules
node_price_rules -->|"requests prediction"| node_model_pipeline
node_price_rules -.->|"returns estimate"| node_rider
node_task3_app -->|"imports utilities"| node_task3_pipeline
node_task3_app -.->|"renders mobile page"| node_mobile_form
node_json_endpoint -->|"loads pipeline"| node_trained_model
node_web_app -->|"reads and writes"| node_activity_store
node_web_app -.->|"serves pickup points"| node_pickup_data

click node_web_app "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py"
click node_mobile_form "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/mobile.html"
click node_request_checks "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py"
click node_price_rules "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py"
click node_model_pipeline "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/fare_pipeline.py"
click node_trained_model "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/final_pipeline.joblib"
click node_task3_app "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/app.py"
click node_task3_pipeline "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/fare_pipeline.py"
click node_json_endpoint "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app_predict_endpoint.py"
click node_activity_store "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/activity.json"
click node_pickup_data "https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/final_internship_data.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_web_app,node_main_form,node_mobile_form,node_task3_app,node_json_endpoint toneBlue
class node_request_checks,node_price_rules,node_model_pipeline,node_trained_model,node_task3_pipeline toneAmber
class node_activity_store,node_pickup_data toneMint
class node_rider toneIndigo
```

## Components

### User interfaces

- [Web app](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py): `app.py`
- **Fare form**
- [Mobile form](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/mobile.html): `Task3/mobile.html`
- [Task3 web app](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/app.py): `Task3/app.py`
- [JSON prediction](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app_predict_endpoint.py): `app_predict_endpoint.py`

### Fare estimation

- [Input validation](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py): `app.py`
- [Fare rules](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/app.py): `app.py`
- [Fare pipeline](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/fare_pipeline.py): `fare_pipeline.py`
- [Saved model](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/final_pipeline.joblib): `final_pipeline.joblib`
- [Task3 pipeline](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/Task3/fare_pipeline.py): `Task3/fare_pipeline.py`

### Trip support

- [Activity history](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/activity.json): `activity.json`
- [Pickup data](https://github.com/esraa-elgebaly/uber-fare-prediction/blob/main/final_internship_data.csv): `final_internship_data.csv`

### Other components

- **Rider**

## Connections

- Rider → Web app: submits trip (evidence: `app.py`)
- Web app → Fare form: renders (evidence: `app.py`)
- Web app → Input validation: validates (evidence: `app.py`)
- Input validation → Fare rules: passes valid trip (evidence: `app.py`)
- Fare rules → Fare pipeline: requests prediction (evidence: `app.py`)
- Fare rules → Rider: returns estimate
- Task3 web app → Task3 pipeline: imports utilities (evidence: `Task3/app.py`)
- Task3 web app → Mobile form: renders mobile page
- JSON prediction → Saved model: loads pipeline (evidence: `app_predict_endpoint.py`)
- Web app → Activity history: reads and writes (evidence: `app.py`)
- Web app → Pickup data: serves pickup points
