# johanohly/airtrail architecture

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

- Interactive diagram: https://gitdiagram.com/johanohly/airtrail
- Repository: https://github.com/johanohly/airtrail

## Overview

AirTrail is a flight-history web application. The principal workflow is: a traveler authenticates, the home route preloads authorized flights and tracks, the map and detail views present them, and users add or import flights that become available for history and statistics. The graph also preserves administration, OAuth, sharing-oriented authorization, airline assets, and map integrations. Several UI and server modules were not sampled, so some documented capabilities are represented without speculative call edges.

Main entry points: [`src/lib/db/index.ts`](https://github.com/johanohly/airtrail/blob/main/src/lib/db/index.ts) (PostgreSQL), [`src/routes/api/oauth/callback/+server.ts`](https://github.com/johanohly/airtrail/blob/main/src/routes/api/oauth/callback/%2Bserver.ts) (OAuth Callback), [`src/routes/+page.server.ts`](https://github.com/johanohly/airtrail/blob/main/src/routes/%2Bpage.server.ts) (Home Loader), [`src/lib/components/map/Map.svelte`](https://github.com/johanohly/airtrail/blob/main/src/lib/components/map/Map.svelte) (Flight Map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Flight Experience"]
  node_home_ssr["Home Loader<br/>[+page.server.ts]"]
  node_flight_map["Flight Map<br/>[Map.svelte]"]
  node_map_camera["Map Camera"]
  node_flight_details["Flight Details"]
  node_flight_forms["Flight Forms<br/>[FlightForm.svelte]"]
  node_statistics["Statistics Views"]
  node_login["Login Page<br/>[+page.server.ts]"]
end

subgraph group_domain["Flight Domain"]
  node_flight_service["Flight Service<br/>[flight.ts]"]
  node_save_flight["Flight Save API<br/>[+server.ts]"]
  node_track_service["Track Routes<br/>[flight-track.ts]"]
  node_import_pipeline["Import Pipeline<br/>[index.ts]"]
  node_flight_scope["Flight Scope<br/>[flight-scope.ts]"]
  node_airport_catalog["Airport Catalog<br/>[airport.ts]"]
  node_stats_api["Statistics API<br/>[+server.ts]"]
end

subgraph group_platform["Platform Services"]
  node_auth_gateway["Auth Gateway<br/>[auth.ts]"]
  node_oauth_callback["OAuth Callback<br/>[+server.ts]"]
  node_authorization["Authorization<br/>[authorize.ts]"]
  node_user_admin["User Administration<br/>[+server.ts]"]
  node_airline_assets["Airline Assets<br/>[+server.ts]"]
  node_database[("PostgreSQL<br/>[index.ts]")]
  node_file_storage[("File Storage<br/>[uploads.ts]")]
end

subgraph group_integrations["External Integrations"]
end

node_traveler(("Traveler"))
node_api_client(("API Client"))
node_oauth_provider["OAuth Provider"]
node_map_services["Map Services"]
node_weather_service["Weather Service"]

node_traveler -->|"signs in"| node_login
node_traveler -->|"opens history"| node_home_ssr
node_home_ssr -->|"lists flights"| node_flight_service
node_home_ssr -->|"lists tracks"| node_track_service
node_home_ssr -->|"preloads data"| node_flight_map
node_flight_map -->|"opens details"| node_flight_details
node_flight_map -->|"controls view"| node_map_camera
node_map_camera -.->|"uses map"| node_map_services
node_flight_map -.->|"loads weather"| node_weather_service
node_traveler -->|"enters flight"| node_flight_forms
node_api_client -->|"submits flight"| node_save_flight
node_save_flight -->|"resolves airports"| node_airport_catalog
node_save_flight -->|"validates and saves"| node_flight_service
node_flight_service -->|"reads and writes"| node_database
node_track_service -->|"reads tracks"| node_database
node_traveler -->|"imports flights"| node_import_pipeline
node_traveler -->|"views statistics"| node_statistics
node_stats_api -->|"resolves scope"| node_flight_scope
node_stats_api -->|"lists flights"| node_flight_service
node_stats_api -->|"reads data"| node_database
node_login -->|"loads auth"| node_auth_gateway
node_oauth_callback -.->|"gets profile"| node_oauth_provider
node_oauth_callback -->|"resolves role"| node_authorization
node_oauth_callback -->|"links user"| node_database
node_oauth_callback -->|"creates session"| node_auth_gateway
node_user_admin -->|"checks permissions"| node_authorization
node_user_admin -->|"updates users"| node_database
node_airline_assets -->|"stores icons"| node_file_storage
node_airline_assets -->|"updates icon path"| node_database

click node_home_ssr "https://github.com/johanohly/airtrail/blob/main/src/routes/%2Bpage.server.ts"
click node_flight_map "https://github.com/johanohly/airtrail/blob/main/src/lib/components/map/Map.svelte"
click node_map_camera "https://github.com/johanohly/airtrail/blob/main/src/lib/map/camera-controller.ts"
click node_flight_details "https://github.com/johanohly/airtrail/blob/main/src/lib/components/map-details/MapDetailsPane.svelte"
click node_flight_forms "https://github.com/johanohly/airtrail/blob/main/src/lib/components/modals/flight-form/FlightForm.svelte"
click node_statistics "https://github.com/johanohly/airtrail/blob/main/src/lib/components/modals/statistics/StatisticsModal.svelte"
click node_login "https://github.com/johanohly/airtrail/blob/main/src/routes/(auth)/login/%2Bpage.server.ts"
click node_flight_service "https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/flight.ts"
click node_save_flight "https://github.com/johanohly/airtrail/blob/main/src/routes/api/flight/save/%2Bserver.ts"
click node_track_service "https://github.com/johanohly/airtrail/blob/main/src/lib/server/routes/flight-track.ts"
click node_import_pipeline "https://github.com/johanohly/airtrail/blob/main/src/lib/import/index.ts"
click node_flight_scope "https://github.com/johanohly/airtrail/blob/main/src/lib/flight-scope.ts"
click node_airport_catalog "https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/airport.ts"
click node_stats_api "https://github.com/johanohly/airtrail/blob/main/src/routes/api/stats/%2Bserver.ts"
click node_auth_gateway "https://github.com/johanohly/airtrail/blob/main/src/lib/server/auth.ts"
click node_oauth_callback "https://github.com/johanohly/airtrail/blob/main/src/routes/api/oauth/callback/%2Bserver.ts"
click node_authorization "https://github.com/johanohly/airtrail/blob/main/src/lib/server/authorization/authorize.ts"
click node_user_admin "https://github.com/johanohly/airtrail/blob/main/src/routes/api/users/admin-edit/%2Bserver.ts"
click node_airline_assets "https://github.com/johanohly/airtrail/blob/main/src/routes/api/airline/icon/%2Bserver.ts"
click node_database "https://github.com/johanohly/airtrail/blob/main/src/lib/db/index.ts"
click node_file_storage "https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/uploads.ts"

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_home_ssr,node_flight_map,node_map_camera,node_flight_details,node_flight_forms,node_statistics,node_login,node_api_client toneBlue
class node_flight_service,node_save_flight,node_track_service,node_import_pipeline,node_flight_scope,node_airport_catalog,node_stats_api toneAmber
class node_auth_gateway,node_oauth_callback,node_authorization,node_user_admin,node_airline_assets,node_database,node_file_storage toneMint
class node_traveler,node_oauth_provider,node_map_services,node_weather_service toneIndigo
```

## Components

### Flight Experience

- [Home Loader](https://github.com/johanohly/airtrail/blob/main/src/routes/%2Bpage.server.ts): `src/routes/+page.server.ts`
- [Flight Map](https://github.com/johanohly/airtrail/blob/main/src/lib/components/map/Map.svelte): `src/lib/components/map/Map.svelte`
- [Map Camera](https://github.com/johanohly/airtrail/blob/main/src/lib/map/camera-controller.ts): `src/lib/map/camera-controller.ts`
- [Flight Details](https://github.com/johanohly/airtrail/blob/main/src/lib/components/map-details/MapDetailsPane.svelte): `src/lib/components/map-details/MapDetailsPane.svelte`
- [Flight Forms](https://github.com/johanohly/airtrail/blob/main/src/lib/components/modals/flight-form/FlightForm.svelte): `src/lib/components/modals/flight-form/FlightForm.svelte`
- [Statistics Views](https://github.com/johanohly/airtrail/blob/main/src/lib/components/modals/statistics/StatisticsModal.svelte): `src/lib/components/modals/statistics/StatisticsModal.svelte`
- [Login Page](https://github.com/johanohly/airtrail/blob/main/src/routes/(auth)/login/%2Bpage.server.ts): `src/routes/(auth)/login/+page.server.ts`

### Flight Domain

- [Flight Service](https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/flight.ts): `src/lib/server/utils/flight.ts`
- [Flight Save API](https://github.com/johanohly/airtrail/blob/main/src/routes/api/flight/save/%2Bserver.ts): `src/routes/api/flight/save/+server.ts`
- [Track Routes](https://github.com/johanohly/airtrail/blob/main/src/lib/server/routes/flight-track.ts): `src/lib/server/routes/flight-track.ts`
- [Import Pipeline](https://github.com/johanohly/airtrail/blob/main/src/lib/import/index.ts): `src/lib/import/index.ts`
- [Flight Scope](https://github.com/johanohly/airtrail/blob/main/src/lib/flight-scope.ts): `src/lib/flight-scope.ts`
- [Airport Catalog](https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/airport.ts): `src/lib/server/utils/airport.ts`
- [Statistics API](https://github.com/johanohly/airtrail/blob/main/src/routes/api/stats/%2Bserver.ts): `src/routes/api/stats/+server.ts`

### Platform Services

- [Auth Gateway](https://github.com/johanohly/airtrail/blob/main/src/lib/server/auth.ts): `src/lib/server/auth.ts`
- [OAuth Callback](https://github.com/johanohly/airtrail/blob/main/src/routes/api/oauth/callback/%2Bserver.ts): `src/routes/api/oauth/callback/+server.ts`
- [Authorization](https://github.com/johanohly/airtrail/blob/main/src/lib/server/authorization/authorize.ts): `src/lib/server/authorization/authorize.ts`
- [User Administration](https://github.com/johanohly/airtrail/blob/main/src/routes/api/users/admin-edit/%2Bserver.ts): `src/routes/api/users/admin-edit/+server.ts`
- [Airline Assets](https://github.com/johanohly/airtrail/blob/main/src/routes/api/airline/icon/%2Bserver.ts): `src/routes/api/airline/icon/+server.ts`
- [PostgreSQL](https://github.com/johanohly/airtrail/blob/main/src/lib/db/index.ts): `src/lib/db/index.ts`
- [File Storage](https://github.com/johanohly/airtrail/blob/main/src/lib/server/utils/uploads.ts): `src/lib/server/utils/uploads.ts`

### Other components

- **Traveler**
- **API Client**
- **OAuth Provider**
- **Map Services**
- **Weather Service**

## Connections

- Traveler → Login Page: signs in
- Traveler → Home Loader: opens history
- Home Loader → Flight Service: lists flights
- Home Loader → Track Routes: lists tracks
- Home Loader → Flight Map: preloads data
- Flight Map → Flight Details: opens details
- Flight Map → Map Camera: controls view
- Map Camera → Map Services: uses map
- Flight Map → Weather Service: loads weather
- Traveler → Flight Forms: enters flight
- API Client → Flight Save API: submits flight
- Flight Save API → Airport Catalog: resolves airports
- Flight Save API → Flight Service: validates and saves
- Flight Service → PostgreSQL: reads and writes
- Track Routes → PostgreSQL: reads tracks
- Traveler → Import Pipeline: imports flights
- Traveler → Statistics Views: views statistics
- Statistics API → Flight Scope: resolves scope
- Statistics API → Flight Service: lists flights
- Statistics API → PostgreSQL: reads data
- Login Page → Auth Gateway: loads auth
- OAuth Callback → OAuth Provider: gets profile
- OAuth Callback → Authorization: resolves role
- OAuth Callback → PostgreSQL: links user
- OAuth Callback → Auth Gateway: creates session
- User Administration → Authorization: checks permissions
- User Administration → PostgreSQL: updates users
- Airline Assets → File Storage: stores icons
- Airline Assets → PostgreSQL: updates icon path
