# palak216/skysafe architecture

> Architecture diagram of the GitHub repository palak216/skysafe, 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/palak216/skysafe
- Repository: https://github.com/palak216/skysafe

## Overview

SkySafe is a full-stack flight booking platform. Travelers search in natural language or by route, review offers, prepare a selected offer as inventory, and book or cancel; authenticated users and administrators also use account, booking-history, dashboard, and flight-management flows. The graph preserves those documented capabilities and separates parsing, validation, providers, ranking, booking, and persistence. Some subsystem links rely on README documentation because their implementation files were not excerpted.

Main entry points: [`client/src/App.jsx`](https://github.com/palak216/skysafe/blob/main/client/src/App.jsx) (Route Shell), [`server/controllers/aiFlight.controller.js`](https://github.com/palak216/skysafe/blob/main/server/controllers/aiFlight.controller.js) (AI Search Controller), [`server/app.js`](https://github.com/palak216/skysafe/blob/main/server/app.js) (Express API), [`client/src/services/api.js`](https://github.com/palak216/skysafe/blob/main/client/src/services/api.js) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Traveler and Admin UI"]
  node_app["Route Shell<br/>[App.jsx]"]
  node_home["Search Page<br/>[Home.jsx]"]
  node_search_form["Search Form<br/>[SearchForm.jsx]"]
  node_flight_client["Flight Services<br/>[flightService.js]"]
  node_ai_flight_client["AI Search Service<br/>[aiFlightService.js]"]
  node_booking_page["Booking Page<br/>[Booking.jsx]"]
  node_booking_client["Booking Service<br/>[bookingService.js]"]
  node_my_bookings["Booking History<br/>[MyBookings.jsx]"]
  node_auth_context["Auth Context<br/>[AuthContext.jsx]"]
  node_auth_client["Auth Service<br/>[authService.js]"]
  node_protected["Route Guard<br/>[ProtectedRoute.jsx]"]
  node_admin_dashboard["Admin Dashboard<br/>[AdminDashboard.jsx]"]
  node_flight_management["Flight Management"]
  node_admin_client["Admin Service<br/>[adminService.js]"]
  node_api_client["API Client<br/>[api.js]"]
end

subgraph group_api["API and Identity"]
  node_express_app["Express API<br/>[app.js]"]
  node_auth_routes["Auth Routes<br/>[auth.routes.js]"]
  node_auth_middleware["JWT Middleware<br/>[auth.middleware.js]"]
  node_auth_controller["Account Controller<br/>[auth.controller.js]"]
  node_user_store[("User Records<br/>[User.js]")]
end

subgraph group_search["Flight Search"]
  node_ai_controller["AI Search Controller"]
  node_ai_routes["AI Search Routes<br/>[aiFlight.routes.js]"]
  node_query_parser["Query Parser<br/>[aiFlightHelper.js]"]
  node_airport_codes["Airport Normalizer<br/>[airportCodes.js]"]
  node_query_validator["Query Validator<br/>[queryValidator.js]"]
  node_provider_router["Provider Selector<br/>[index.js]"]
  node_amadeus["Amadeus Provider<br/>[amadeusProvider.js]"]
  node_mock_provider["Mock Provider<br/>[mockProvider.js]"]
  node_ranking["Offer Ranking<br/>[rankingService.js]"]
end

subgraph group_booking["Booking and Inventory"]
  node_flight_routes["Flight Routes<br/>[flight.routes.js]"]
  node_flight_controller["Flight Controller"]
  node_booking_routes["Booking Routes<br/>[booking.routes.js]"]
end

subgraph group_admin["Administration"]
end

node_traveler(("Traveler"))
node_admin_actor(("Administrator"))

node_traveler -.->|"uses"| node_app
node_admin_actor -.->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_booking_page
node_app -->|"routes to"| node_my_bookings
node_app -->|"routes to"| node_admin_dashboard
node_app -->|"routes to"| node_flight_management
node_app -->|"guards routes"| node_protected
node_home -->|"renders"| node_search_form
node_search_form -->|"calls"| node_flight_client
node_search_form -->|"calls"| node_ai_flight_client
node_booking_page -->|"calls"| node_flight_client
node_booking_page -->|"calls"| node_booking_client
node_my_bookings -->|"calls"| node_booking_client
node_auth_context -->|"loads profile"| node_auth_client
node_protected -->|"checks identity"| node_auth_context
node_admin_dashboard -->|"loads metrics"| node_admin_client
node_flight_management -->|"manages flights"| node_admin_client
node_auth_client -->|"sends requests"| node_api_client
node_flight_client -->|"sends requests"| node_api_client
node_ai_flight_client -->|"sends requests"| node_api_client
node_admin_client -->|"sends requests"| node_api_client
node_api_client -.->|"calls API"| node_express_app
node_express_app -->|"mounts"| node_auth_routes
node_express_app -->|"mounts"| node_ai_routes
node_express_app -->|"mounts"| node_flight_routes
node_express_app -->|"mounts"| node_booking_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"protects profile"| node_auth_middleware
node_auth_routes -->|"reads profile"| node_user_store
node_ai_routes -->|"dispatches"| node_ai_controller
node_ai_controller -->|"parses query"| node_query_parser
node_query_parser -->|"normalizes places"| node_airport_codes
node_ai_controller -->|"validates query"| node_query_validator
node_query_validator -->|"resolves codes"| node_airport_codes
node_ai_controller -->|"searches offers"| node_provider_router
node_provider_router -.->|"selects provider"| node_amadeus
node_provider_router -.->|"falls back"| node_mock_provider
node_ai_controller -->|"ranks offers"| node_ranking
node_flight_routes -->|"dispatches"| node_flight_controller
node_flight_routes -->|"bridges offers"| node_ai_controller
node_booking_routes -->|"protects booking"| node_auth_middleware

click node_app "https://github.com/palak216/skysafe/blob/main/client/src/App.jsx"
click node_home "https://github.com/palak216/skysafe/blob/main/client/src/pages/Home.jsx"
click node_search_form "https://github.com/palak216/skysafe/blob/main/client/src/components/SearchForm.jsx"
click node_flight_client "https://github.com/palak216/skysafe/blob/main/client/src/services/flightService.js"
click node_ai_flight_client "https://github.com/palak216/skysafe/blob/main/client/src/services/aiFlightService.js"
click node_booking_page "https://github.com/palak216/skysafe/blob/main/client/src/pages/Booking.jsx"
click node_booking_client "https://github.com/palak216/skysafe/blob/main/client/src/services/bookingService.js"
click node_my_bookings "https://github.com/palak216/skysafe/blob/main/client/src/pages/MyBookings.jsx"
click node_auth_context "https://github.com/palak216/skysafe/blob/main/client/src/context/AuthContext.jsx"
click node_auth_client "https://github.com/palak216/skysafe/blob/main/client/src/services/authService.js"
click node_protected "https://github.com/palak216/skysafe/blob/main/client/src/components/ProtectedRoute.jsx"
click node_admin_dashboard "https://github.com/palak216/skysafe/blob/main/client/src/pages/AdminDashboard.jsx"
click node_flight_management "https://github.com/palak216/skysafe/blob/main/client/src/pages/FlightManagement.jsx"
click node_admin_client "https://github.com/palak216/skysafe/blob/main/client/src/services/adminService.js"
click node_api_client "https://github.com/palak216/skysafe/blob/main/client/src/services/api.js"
click node_express_app "https://github.com/palak216/skysafe/blob/main/server/app.js"
click node_auth_routes "https://github.com/palak216/skysafe/blob/main/server/routes/auth.routes.js"
click node_auth_middleware "https://github.com/palak216/skysafe/blob/main/server/middleware/auth.middleware.js"
click node_auth_controller "https://github.com/palak216/skysafe/blob/main/server/controllers/auth.controller.js"
click node_user_store "https://github.com/palak216/skysafe/blob/main/server/models/User.js"
click node_ai_controller "https://github.com/palak216/skysafe/blob/main/server/controllers/aiFlight.controller.js"
click node_ai_routes "https://github.com/palak216/skysafe/blob/main/server/routes/aiFlight.routes.js"
click node_query_parser "https://github.com/palak216/skysafe/blob/main/server/services/aiFlightHelper.js"
click node_airport_codes "https://github.com/palak216/skysafe/blob/main/server/utils/airportCodes.js"
click node_query_validator "https://github.com/palak216/skysafe/blob/main/server/services/queryValidator.js"
click node_provider_router "https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/index.js"
click node_amadeus "https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/amadeusProvider.js"
click node_mock_provider "https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/mockProvider.js"
click node_ranking "https://github.com/palak216/skysafe/blob/main/server/services/rankingService.js"
click node_flight_routes "https://github.com/palak216/skysafe/blob/main/server/routes/flight.routes.js"
click node_flight_controller "https://github.com/palak216/skysafe/blob/main/server/controllers/flight.controller.js"
click node_booking_routes "https://github.com/palak216/skysafe/blob/main/server/routes/booking.routes.js"

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_home,node_search_form,node_flight_client,node_ai_flight_client,node_booking_page,node_booking_client,node_my_bookings,node_auth_context,node_auth_client,node_protected,node_admin_dashboard,node_flight_management,node_admin_client,node_api_client toneBlue
class node_express_app,node_auth_routes,node_auth_middleware,node_auth_controller,node_user_store toneAmber
class node_ai_controller,node_ai_routes,node_query_parser,node_airport_codes,node_query_validator,node_provider_router,node_amadeus,node_mock_provider,node_ranking toneMint
class node_flight_routes,node_flight_controller,node_booking_routes toneRose
class node_traveler,node_admin_actor toneIndigo
```

## Components

### Traveler and Admin UI

- [Route Shell](https://github.com/palak216/skysafe/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Search Page](https://github.com/palak216/skysafe/blob/main/client/src/pages/Home.jsx): `client/src/pages/Home.jsx`
- [Search Form](https://github.com/palak216/skysafe/blob/main/client/src/components/SearchForm.jsx): `client/src/components/SearchForm.jsx`
- [Flight Services](https://github.com/palak216/skysafe/blob/main/client/src/services/flightService.js): `client/src/services/flightService.js`
- [AI Search Service](https://github.com/palak216/skysafe/blob/main/client/src/services/aiFlightService.js): `client/src/services/aiFlightService.js`
- [Booking Page](https://github.com/palak216/skysafe/blob/main/client/src/pages/Booking.jsx): `client/src/pages/Booking.jsx`
- [Booking Service](https://github.com/palak216/skysafe/blob/main/client/src/services/bookingService.js): `client/src/services/bookingService.js`
- [Booking History](https://github.com/palak216/skysafe/blob/main/client/src/pages/MyBookings.jsx): `client/src/pages/MyBookings.jsx`
- [Auth Context](https://github.com/palak216/skysafe/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Auth Service](https://github.com/palak216/skysafe/blob/main/client/src/services/authService.js): `client/src/services/authService.js`
- [Route Guard](https://github.com/palak216/skysafe/blob/main/client/src/components/ProtectedRoute.jsx): `client/src/components/ProtectedRoute.jsx`
- [Admin Dashboard](https://github.com/palak216/skysafe/blob/main/client/src/pages/AdminDashboard.jsx): `client/src/pages/AdminDashboard.jsx`
- [Flight Management](https://github.com/palak216/skysafe/blob/main/client/src/pages/FlightManagement.jsx): `client/src/pages/FlightManagement.jsx`
- [Admin Service](https://github.com/palak216/skysafe/blob/main/client/src/services/adminService.js): `client/src/services/adminService.js`
- [API Client](https://github.com/palak216/skysafe/blob/main/client/src/services/api.js): `client/src/services/api.js`

### API and Identity

- [Express API](https://github.com/palak216/skysafe/blob/main/server/app.js): `server/app.js`
- [Auth Routes](https://github.com/palak216/skysafe/blob/main/server/routes/auth.routes.js): `server/routes/auth.routes.js`
- [JWT Middleware](https://github.com/palak216/skysafe/blob/main/server/middleware/auth.middleware.js): `server/middleware/auth.middleware.js`
- [Account Controller](https://github.com/palak216/skysafe/blob/main/server/controllers/auth.controller.js): `server/controllers/auth.controller.js`
- [User Records](https://github.com/palak216/skysafe/blob/main/server/models/User.js): `server/models/User.js`

### Flight Search

- [AI Search Controller](https://github.com/palak216/skysafe/blob/main/server/controllers/aiFlight.controller.js): `server/controllers/aiFlight.controller.js`
- [AI Search Routes](https://github.com/palak216/skysafe/blob/main/server/routes/aiFlight.routes.js): `server/routes/aiFlight.routes.js`
- [Query Parser](https://github.com/palak216/skysafe/blob/main/server/services/aiFlightHelper.js): `server/services/aiFlightHelper.js`
- [Airport Normalizer](https://github.com/palak216/skysafe/blob/main/server/utils/airportCodes.js): `server/utils/airportCodes.js`
- [Query Validator](https://github.com/palak216/skysafe/blob/main/server/services/queryValidator.js): `server/services/queryValidator.js`
- [Provider Selector](https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/index.js): `server/services/flightProviders/index.js`
- [Amadeus Provider](https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/amadeusProvider.js): `server/services/flightProviders/amadeusProvider.js`
- [Mock Provider](https://github.com/palak216/skysafe/blob/main/server/services/flightProviders/mockProvider.js): `server/services/flightProviders/mockProvider.js`
- [Offer Ranking](https://github.com/palak216/skysafe/blob/main/server/services/rankingService.js): `server/services/rankingService.js`

### Booking and Inventory

- [Flight Routes](https://github.com/palak216/skysafe/blob/main/server/routes/flight.routes.js): `server/routes/flight.routes.js`
- [Flight Controller](https://github.com/palak216/skysafe/blob/main/server/controllers/flight.controller.js): `server/controllers/flight.controller.js`
- [Booking Routes](https://github.com/palak216/skysafe/blob/main/server/routes/booking.routes.js): `server/routes/booking.routes.js`

### Other components

- **Traveler**
- **Administrator**

## Connections

- Traveler → Route Shell: uses
- Administrator → Route Shell: uses
- Route Shell → Search Page: routes to (evidence: `client/src/App.jsx`)
- Route Shell → Booking Page: routes to (evidence: `client/src/App.jsx`)
- Route Shell → Booking History: routes to (evidence: `client/src/App.jsx`)
- Route Shell → Admin Dashboard: routes to (evidence: `client/src/App.jsx`)
- Route Shell → Flight Management: routes to (evidence: `client/src/App.jsx`)
- Route Shell → Route Guard: guards routes (evidence: `client/src/App.jsx`)
- Search Page → Search Form: renders (evidence: `client/src/pages/Home.jsx`)
- Search Form → Flight Services: calls (evidence: `client/src/components/SearchForm.jsx`)
- Search Form → AI Search Service: calls (evidence: `client/src/components/SearchForm.jsx`)
- Booking Page → Flight Services: calls (evidence: `client/src/pages/Booking.jsx`)
- Booking Page → Booking Service: calls (evidence: `client/src/pages/Booking.jsx`)
- Booking History → Booking Service: calls (evidence: `client/src/pages/MyBookings.jsx`)
- Auth Context → Auth Service: loads profile (evidence: `client/src/context/AuthContext.jsx`)
- Route Guard → Auth Context: checks identity (evidence: `client/src/components/ProtectedRoute.jsx`)
- Admin Dashboard → Admin Service: loads metrics (evidence: `client/src/pages/AdminDashboard.jsx`)
- Flight Management → Admin Service: manages flights (evidence: `client/src/pages/FlightManagement.jsx`)
- Auth Service → API Client: sends requests (evidence: `client/src/services/authService.js`)
- Flight Services → API Client: sends requests (evidence: `client/src/services/flightService.js`)
- AI Search Service → API Client: sends requests (evidence: `client/src/services/aiFlightService.js`)
- Admin Service → API Client: sends requests (evidence: `client/src/services/adminService.js`)
- API Client → Express API: calls API
- Express API → Auth Routes: mounts (evidence: `server/app.js`)
- Express API → AI Search Routes: mounts (evidence: `server/app.js`)
- Express API → Flight Routes: mounts (evidence: `server/app.js`)
- Express API → Booking Routes: mounts (evidence: `server/app.js`)
- Auth Routes → Account Controller: dispatches (evidence: `server/routes/auth.routes.js`)
- Auth Routes → JWT Middleware: protects profile (evidence: `server/routes/auth.routes.js`)
- Auth Routes → User Records: reads profile (evidence: `server/routes/auth.routes.js`)
- AI Search Routes → AI Search Controller: dispatches (evidence: `server/routes/aiFlight.routes.js`)
- AI Search Controller → Query Parser: parses query (evidence: `server/controllers/aiFlight.controller.js`)
- Query Parser → Airport Normalizer: normalizes places (evidence: `server/services/aiFlightHelper.js`)
- AI Search Controller → Query Validator: validates query (evidence: `server/controllers/aiFlight.controller.js`)
- Query Validator → Airport Normalizer: resolves codes (evidence: `server/services/queryValidator.js`)
- AI Search Controller → Provider Selector: searches offers (evidence: `server/controllers/aiFlight.controller.js`)
- Provider Selector → Amadeus Provider: selects provider (evidence: `server/services/flightProviders/index.js`)
- Provider Selector → Mock Provider: falls back (evidence: `server/services/flightProviders/index.js`)
- AI Search Controller → Offer Ranking: ranks offers (evidence: `server/controllers/aiFlight.controller.js`)
- Flight Routes → Flight Controller: dispatches (evidence: `server/routes/flight.routes.js`)
- Flight Routes → AI Search Controller: bridges offers (evidence: `server/routes/flight.routes.js`)
- Booking Routes → JWT Middleware: protects booking (evidence: `server/routes/booking.routes.js`)
