# vivekv81/flightz architecture

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

- Interactive diagram: https://gitdiagram.com/vivekv81/flightz
- Repository: https://github.com/vivekv81/flightz

## Overview

Flightz is a Flask flight-fare comparison app. A user searches by route and date in the web interface; the frontend requests the Flask search endpoint, which checks SQLite, then falls back to an external flight API and local JSON data. Available results are validated, may be cached, and receive an ML fare estimate before being returned for display. The README also documents database statistics and benchmarking. The excerpts do not show all route wiring, validation code, or benchmark internals, so those links are omitted where evidence is unavailable.

Main entry points: [`app.py`](https://github.com/vivekv81/flightz/blob/main/app.py) (Search orchestration), [`static/script.js`](https://github.com/vivekv81/flightz/blob/main/static/script.js) (Search interface), [`templates/index.html`](https://github.com/vivekv81/flightz/blob/main/templates/index.html) (Search page), [`ml/train_model.py`](https://github.com/vivekv81/flightz/blob/main/ml/train_model.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_browser["Browser"]
  node_login["Login and search pages<br/>[home.html]"]
  node_searchpage["Search page<br/>[index.html]"]
  node_frontend["Search interface<br/>[script.js]"]
end

subgraph group_search["Flight search"]
  node_flask["Flask application<br/>[app.py]"]
  node_searchflow["Search orchestration<br/>[app.py]"]
  node_validation["Flight validation<br/>[app.py]"]
  node_statistics["Database statistics<br/>[app.py]"]
  node_benchmark["Search benchmark<br/>[benchmark.py]"]
end

subgraph group_sources["Flight sources"]
  node_sqlite[("Flight database<br/>[app.py]")]
  node_externalapi["Flight API"]
  node_jsondata["JSON fallback data<br/>[flights.json]"]
end

subgraph group_ml["Fare estimation"]
  node_predict["Fare prediction<br/>[app.py]"]
  node_modeltraining["Model training<br/>[train_model.py]"]
  node_deploymenttraining["Deployment model training"]
  node_trainingdata["Training dataset<br/>[Data_Train.xlsx]"]
end

node_traveler(("Traveler"))

node_traveler -->|"uses"| node_browser
node_browser -.->|"opens"| node_login
node_browser -.->|"opens"| node_searchpage
node_searchpage -.->|"uses"| node_frontend
node_frontend -->|"requests flights"| node_flask
node_flask -.->|"routes search"| node_searchflow
node_searchflow -->|"queries first"| node_sqlite
node_searchflow -->|"fetches fallback"| node_externalapi
node_searchflow -->|"searches fallback"| node_jsondata
node_searchflow -->|"validates results"| node_validation
node_searchflow -->|"adds estimates"| node_predict
node_searchflow -->|"caches API results"| node_sqlite
node_predict -.->|"loads model"| node_modeltraining
node_modeltraining -->|"trains on"| node_trainingdata
node_deploymenttraining -->|"trains on"| node_trainingdata
node_searchflow -->|"returns results"| node_frontend
node_flask -.->|"serves statistics"| node_statistics
node_benchmark -.->|"benchmarks searches"| node_sqlite

click node_login "https://github.com/vivekv81/flightz/blob/main/templates/home.html"
click node_searchpage "https://github.com/vivekv81/flightz/blob/main/templates/index.html"
click node_frontend "https://github.com/vivekv81/flightz/blob/main/static/script.js"
click node_flask "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_searchflow "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_validation "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_sqlite "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_jsondata "https://github.com/vivekv81/flightz/blob/main/flights.json"
click node_statistics "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_benchmark "https://github.com/vivekv81/flightz/blob/main/benchmark.py"
click node_predict "https://github.com/vivekv81/flightz/blob/main/app.py"
click node_modeltraining "https://github.com/vivekv81/flightz/blob/main/ml/train_model.py"
click node_deploymenttraining "https://github.com/vivekv81/flightz/blob/main/ml/train_deployment_model.py"
click node_trainingdata "https://github.com/vivekv81/flightz/blob/main/data/Data_Train.xlsx"

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,node_login,node_searchpage,node_frontend toneBlue
class node_flask,node_searchflow,node_validation,node_statistics,node_benchmark toneAmber
class node_sqlite,node_externalapi,node_jsondata toneMint
class node_predict,node_modeltraining,node_deploymenttraining,node_trainingdata toneRose
class node_traveler toneIndigo
```

## Components

### Web interface

- **Browser**
- [Login and search pages](https://github.com/vivekv81/flightz/blob/main/templates/home.html): `templates/home.html`
- [Search page](https://github.com/vivekv81/flightz/blob/main/templates/index.html): `templates/index.html`
- [Search interface](https://github.com/vivekv81/flightz/blob/main/static/script.js): `static/script.js`

### Flight search

- [Flask application](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- [Search orchestration](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- [Flight validation](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- [Database statistics](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- [Search benchmark](https://github.com/vivekv81/flightz/blob/main/benchmark.py): `benchmark.py`

### Flight sources

- [Flight database](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- **Flight API**
- [JSON fallback data](https://github.com/vivekv81/flightz/blob/main/flights.json): `flights.json`

### Fare estimation

- [Fare prediction](https://github.com/vivekv81/flightz/blob/main/app.py): `app.py`
- [Model training](https://github.com/vivekv81/flightz/blob/main/ml/train_model.py): `ml/train_model.py`
- [Deployment model training](https://github.com/vivekv81/flightz/blob/main/ml/train_deployment_model.py): `ml/train_deployment_model.py`
- [Training dataset](https://github.com/vivekv81/flightz/blob/main/data/Data_Train.xlsx): `data/Data_Train.xlsx`

### Other components

- **Traveler**

## Connections

- Traveler → Browser: uses (evidence: `README.md`)
- Browser → Login and search pages: opens
- Browser → Search page: opens
- Search page → Search interface: uses
- Search interface → Flask application: requests flights (evidence: `static/script.js`)
- Flask application → Search orchestration: routes search (evidence: `app.py`)
- Search orchestration → Flight database: queries first (evidence: `app.py`)
- Search orchestration → Flight API: fetches fallback (evidence: `app.py`)
- Search orchestration → JSON fallback data: searches fallback (evidence: `app.py`)
- Search orchestration → Flight validation: validates results (evidence: `README.md`)
- Search orchestration → Fare prediction: adds estimates (evidence: `app.py`)
- Search orchestration → Flight database: caches API results (evidence: `app.py`)
- Fare prediction → Model training: loads model
- Model training → Training dataset: trains on (evidence: `ml/train_model.py`)
- Deployment model training → Training dataset: trains on (evidence: `ml/train_deployment_model.py`)
- Search orchestration → Search interface: returns results (evidence: `static/script.js`)
- Flask application → Database statistics: serves statistics (evidence: `app.py`)
- Search benchmark → Flight database: benchmarks searches
