# sriharichincholi/napier-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/sriharichincholi/napier-frontend
- Repository: https://github.com/sriharichincholi/napier-frontend

## Overview

NAPIER is an airfare-index dashboard backed by a scraping and calculation pipeline. Users select a route and advance-purchase window, the dashboard requests trend data, and the API reads stored index metrics for charting. Separately, the scraper collects fare quotes and the engine computes Jevons metrics for API consumption. The scraper writes a `price` field, while the engine expects `base_fare` and `total_fare`; the sampled code does not establish how that schema difference is resolved. UI-to-summary wiring is not shown in the excerpt.

Main entry points: [`backend/napier_scraper.py`](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_scraper.py) (Route fare scraper), [`backend/main.py`](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/main.py) (Index API), [`src/app/page.tsx`](https://github.com/sriharichincholi/napier-frontend/blob/main/src/app/page.tsx) (Dashboard and charts), [`backend/napier_engine.py`](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_engine.py) (Jevons engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_ui["Dashboard and charts<br/>[page.tsx]"]
  node_app_shell["App shell<br/>[layout.tsx]"]
end

subgraph group_collection["Fare collection"]
  node_scrape_cycle["Scrape cycle<br/>[napier_scraper.py]"]
  node_route_scraper["Route fare scraper<br/>[napier_scraper.py]"]
end

subgraph group_indexing["Index calculation"]
  node_index_engine["Jevons engine<br/>[napier_engine.py]"]
end

subgraph group_service["API and storage"]
  node_api["Index API<br/>[main.py]"]
  node_raw_prices[("Raw fare records")]
  node_index_metrics[("Index metrics")]
end

node_traveler(("Dashboard user"))
node_flight_search{{"Google Flights"}}

node_traveler -->|"uses"| node_dashboard_ui
node_app_shell -->|"renders"| node_dashboard_ui
node_dashboard_ui -->|"requests trends"| node_api
node_api -->|"reads trends"| node_index_metrics
node_scrape_cycle -->|"dispatches routes"| node_route_scraper
node_route_scraper -->|"fetches fares"| node_flight_search
node_route_scraper -->|"writes quotes"| node_raw_prices
node_index_engine -->|"reads fares"| node_raw_prices
node_index_engine -->|"writes metrics"| node_index_metrics
node_api -->|"reads latest snapshot"| node_index_metrics

click node_dashboard_ui "https://github.com/sriharichincholi/napier-frontend/blob/main/src/app/page.tsx"
click node_app_shell "https://github.com/sriharichincholi/napier-frontend/blob/main/src/app/layout.tsx"
click node_scrape_cycle "https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_scraper.py"
click node_route_scraper "https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_scraper.py"
click node_index_engine "https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_engine.py"
click node_api "https://github.com/sriharichincholi/napier-frontend/blob/main/backend/main.py"

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_dashboard_ui,node_app_shell,node_traveler toneBlue
class node_scrape_cycle,node_route_scraper toneAmber
class node_index_engine toneMint
class node_api,node_raw_prices,node_index_metrics toneRose
class node_flight_search toneIndigo
```

## Components

### Dashboard

- [Dashboard and charts](https://github.com/sriharichincholi/napier-frontend/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [App shell](https://github.com/sriharichincholi/napier-frontend/blob/main/src/app/layout.tsx): `src/app/layout.tsx`

### Fare collection

- [Scrape cycle](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_scraper.py): `backend/napier_scraper.py`
- [Route fare scraper](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_scraper.py): `backend/napier_scraper.py`

### Index calculation

- [Jevons engine](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/napier_engine.py): `backend/napier_engine.py`

### API and storage

- [Index API](https://github.com/sriharichincholi/napier-frontend/blob/main/backend/main.py): `backend/main.py`
- **Raw fare records**
- **Index metrics**

### Other components

- **Dashboard user**
- **Google Flights**

## Connections

- Dashboard user → Dashboard and charts: uses
- App shell → Dashboard and charts: renders
- Dashboard and charts → Index API: requests trends
- Index API → Index metrics: reads trends
- Scrape cycle → Route fare scraper: dispatches routes
- Route fare scraper → Google Flights: fetches fares
- Route fare scraper → Raw fare records: writes quotes
- Jevons engine → Raw fare records: reads fares
- Jevons engine → Index metrics: writes metrics
- Index API → Index metrics: reads latest snapshot
