# mkvaraa/ai-voyage architecture

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

- Interactive diagram: https://gitdiagram.com/mkvaraa/ai-voyage
- Repository: https://github.com/mkvaraa/ai-voyage

## Overview

AI-Voyage is a web travel planner: users provide trip details, receive AI-generated itineraries, and can view routes on a map, check forecasts, and replace stops. The React frontend communicates with a FastAPI backend; the backend validates requests, calls Gemini for itinerary content, and stores routes in SQLite. Mapbox and OpenWeather are documented frontend integrations. Source excerpts establish backend orchestration and persistence; frontend interaction details and several integrations are described only at a high level in the README, so those links are kept broad.

Main entry points: [`backend/app/main.py`](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/pages/RoutePage.tsx`](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/pages/RoutePage.tsx) (Route presentation), [`backend/app/routers/routes.py`](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/routers/routes.py) (Route endpoints), [`backend/app/services/route_service.py`](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/services/route_service.py) (Itinerary generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Trip planning frontend"]
  node_app["React application<br/>[App.tsx]"]
  node_trip_form["Trip details form<br/>[TripForm.tsx]"]
  node_route_page["Route presentation<br/>[RoutePage.tsx]"]
  node_itinerary["Itinerary display<br/>[ItineraryCard.tsx]"]
  node_stop_card["Stop display<br/>[StopCard.tsx]"]
  node_map["Route map<br/>[RouteMap.tsx]"]
  node_weather["Weather forecasts<br/>[useWeather.ts]"]
  node_api_client["API client<br/>[axios.ts]"]
end

subgraph group_api["API and domain logic"]
  node_api_app["FastAPI application<br/>[main.py]"]
  node_route_api["Route endpoints<br/>[routes.py]"]
  node_health_api["Health endpoint<br/>[health.py]"]
  node_schemas["Trip and route schemas<br/>[schemas.py]"]
  node_route_service["Itinerary generation<br/>[route_service.py]"]
  node_validation_errors["Validation errors<br/>[errors.py]"]
  node_metrics["Gemini call metrics<br/>[metrics.py]"]
end

subgraph group_storage["Route persistence"]
  node_crud["Route data access<br/>[crud.py]"]
  node_sqlite[("SQLite routes<br/>[connection.py]")]
  node_db_init["Database initialization<br/>[init_db.py]"]
end

subgraph group_integrations["External services"]
  node_gemini["Google Gemini"]
  node_mapbox["Mapbox"]
  node_openweather["OpenWeather"]
end

node_traveler(("Traveler"))

node_traveler -->|"enters trip details"| node_trip_form
node_trip_form -.->|"submits trip"| node_api_client
node_api_client -->|"sends API requests"| node_api_app
node_api_app -->|"routes requests"| node_route_api
node_api_app -->|"routes health checks"| node_health_api
node_api_app -->|"handles validation"| node_validation_errors
node_api_app -->|"initializes database"| node_db_init
node_route_api -->|"validates and returns"| node_schemas
node_route_api -->|"generates or replaces"| node_route_service
node_route_api -->|"loads and saves"| node_crud
node_route_service -->|"builds validated routes"| node_schemas
node_route_service -->|"requests itinerary content"| node_gemini
node_route_service -->|"records API calls"| node_metrics
node_crud -->|"reads and writes"| node_sqlite
node_db_init -->|"creates route table"| node_sqlite
node_api_app -->|"serves API to"| node_app
node_app -.->|"hosts route views"| node_route_page
node_route_page -.->|"presents itinerary"| node_itinerary
node_route_page -.->|"presents stops"| node_stop_card
node_route_page -.->|"shows route map"| node_map
node_map -.->|"renders map with"| node_mapbox
node_weather -.->|"gets forecasts from"| node_openweather

click node_app "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/App.tsx"
click node_trip_form "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/TripForm.tsx"
click node_route_page "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/pages/RoutePage.tsx"
click node_itinerary "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/ItineraryCard.tsx"
click node_stop_card "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/StopCard.tsx"
click node_map "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/RouteMap.tsx"
click node_weather "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/hooks/useWeather.ts"
click node_api_client "https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/lib/axios.ts"
click node_api_app "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/main.py"
click node_route_api "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/routers/routes.py"
click node_health_api "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/routers/health.py"
click node_schemas "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/models/schemas.py"
click node_route_service "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/services/route_service.py"
click node_validation_errors "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/errors.py"
click node_metrics "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/metrics.py"
click node_crud "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/crud.py"
click node_sqlite "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/connection.py"
click node_db_init "https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/init_db.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_app,node_trip_form,node_route_page,node_itinerary,node_stop_card,node_map,node_weather,node_api_client toneBlue
class node_api_app,node_route_api,node_health_api,node_schemas,node_route_service,node_validation_errors,node_metrics toneAmber
class node_crud,node_sqlite,node_db_init toneMint
class node_gemini,node_mapbox,node_openweather toneRose
class node_traveler toneIndigo
```

## Components

### Trip planning frontend

- [React application](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Trip details form](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/TripForm.tsx): `frontend/src/components/TripForm.tsx`
- [Route presentation](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/pages/RoutePage.tsx): `frontend/src/pages/RoutePage.tsx`
- [Itinerary display](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/ItineraryCard.tsx): `frontend/src/components/ItineraryCard.tsx`
- [Stop display](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/StopCard.tsx): `frontend/src/components/StopCard.tsx`
- [Route map](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/components/RouteMap.tsx): `frontend/src/components/RouteMap.tsx`
- [Weather forecasts](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/hooks/useWeather.ts): `frontend/src/hooks/useWeather.ts`
- [API client](https://github.com/mkvaraa/ai-voyage/blob/main/frontend/src/lib/axios.ts): `frontend/src/lib/axios.ts`

### API and domain logic

- [FastAPI application](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/main.py): `backend/app/main.py`
- [Route endpoints](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/routers/routes.py): `backend/app/routers/routes.py`
- [Health endpoint](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/routers/health.py): `backend/app/routers/health.py`
- [Trip and route schemas](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`
- [Itinerary generation](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/services/route_service.py): `backend/app/services/route_service.py`
- [Validation errors](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/errors.py): `backend/app/errors.py`
- [Gemini call metrics](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/metrics.py): `backend/app/metrics.py`

### Route persistence

- [Route data access](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/crud.py): `backend/app/database/crud.py`
- [SQLite routes](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/connection.py): `backend/app/database/connection.py`
- [Database initialization](https://github.com/mkvaraa/ai-voyage/blob/main/backend/app/database/init_db.py): `backend/app/database/init_db.py`

### External services

- **Google Gemini**
- **Mapbox**
- **OpenWeather**

### Other components

- **Traveler**

## Connections

- Traveler → Trip details form: enters trip details (evidence: `README.md`)
- Trip details form → API client: submits trip
- API client → FastAPI application: sends API requests (evidence: `README.md`)
- FastAPI application → Route endpoints: routes requests (evidence: `backend/app/main.py`)
- FastAPI application → Health endpoint: routes health checks (evidence: `backend/app/main.py`)
- FastAPI application → Validation errors: handles validation (evidence: `backend/app/main.py`)
- FastAPI application → Database initialization: initializes database (evidence: `backend/app/main.py`)
- Route endpoints → Trip and route schemas: validates and returns (evidence: `backend/app/routers/routes.py`)
- Route endpoints → Itinerary generation: generates or replaces (evidence: `backend/app/routers/routes.py`)
- Route endpoints → Route data access: loads and saves (evidence: `backend/app/routers/routes.py`)
- Itinerary generation → Trip and route schemas: builds validated routes (evidence: `backend/app/services/route_service.py`)
- Itinerary generation → Google Gemini: requests itinerary content (evidence: `backend/app/services/route_service.py`)
- Itinerary generation → Gemini call metrics: records API calls (evidence: `backend/app/services/route_service.py`)
- Route data access → SQLite routes: reads and writes (evidence: `backend/app/database/crud.py`)
- Database initialization → SQLite routes: creates route table (evidence: `backend/app/database/init_db.py`)
- FastAPI application → React application: serves API to (evidence: `README.md`)
- React application → Route presentation: hosts route views
- Route presentation → Itinerary display: presents itinerary
- Route presentation → Stop display: presents stops
- Route presentation → Route map: shows route map
- Route map → Mapbox: renders map with (evidence: `README.md`)
- Weather forecasts → OpenWeather: gets forecasts from (evidence: `README.md`)
