# lukalomadze1/morrow architecture

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

- Interactive diagram: https://gitdiagram.com/lukalomadze1/morrow
- Repository: https://github.com/lukalomadze1/morrow

## Overview

Morrow is a sleeper-train booking and operations demo. Travellers search direct journeys, inspect berth availability, hold places, confirm a booking and access a ticket; staff can manage departures and bookings. The domain is split between network/timetable logic, availability and pricing, holds/bookings, and operations, backed by SQLite/libSQL. The README also describes the departure board and the animated night journey. Some pages and routes were not sampled, so their connections are shown only where the README or source index supports them.

Main entry points: [`src/lib/search.ts`](https://github.com/lukalomadze1/morrow/blob/main/src/lib/search.ts) (Offer search), [`src/lib/db/client.ts`](https://github.com/lukalomadze1/morrow/blob/main/src/lib/db/client.ts) (LibSQL database), [`src/app/book/[departureId]/page.tsx`](https://github.com/lukalomadze1/morrow/blob/main/src/app/book/%5BdepartureId%5D/page.tsx) (Berth selection), [`src/lib/holds.ts`](https://github.com/lukalomadze1/morrow/blob/main/src/lib/holds.ts) (Berth holds)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_journey["Journey discovery"]
  node_search_page["Journey search<br/>[page.tsx]"]
  node_search_logic["Offer search<br/>[search.ts]"]
  node_network["Lines and stations<br/>[network.ts]"]
  node_time["Journey timing<br/>[time.ts]"]
  node_departures["Departure inventory<br/>[departures.ts]"]
  node_board["Departure board<br/>[route.ts]"]
end

subgraph group_booking["Booking lifecycle"]
  node_book_page["Berth selection<br/>[page.tsx]"]
  node_formation["Train formation<br/>[formation.ts]"]
  node_places_api["Place availability API<br/>[route.ts]"]
  node_holds_api["Hold API<br/>[route.ts]"]
  node_holds["Berth holds<br/>[holds.ts]"]
  node_checkout["Booking checkout<br/>[page.tsx]"]
  node_bookings_api["Booking API<br/>[route.ts]"]
  node_bookings["Booking and tickets<br/>[bookings.ts]"]
  node_ticket_page["Ticket access<br/>[page.tsx]"]
  node_ticket_actions["Ticket actions<br/>[TicketActions.tsx]"]
end

subgraph group_operations["Operations"]
  node_ops_page["Operations dashboard<br/>[page.tsx]"]
  node_ops_logic["Operations logic<br/>[ops.ts]"]
  node_ops_api["Operations API<br/>[route.ts]"]
  node_auth["Operations sessions<br/>[auth.ts]"]
end

subgraph group_platform["Domain platform"]
  node_pricing["Fare calculation<br/>[pricing.ts]"]
  node_database[("LibSQL database<br/>[client.ts]")]
  node_schema["Booking data model<br/>[schema.ts]"]
  node_api_helpers["API validation<br/>[api.ts]"]
end

subgraph group_experience["Site experience"]
  node_night_story["Animated night journey<br/>[NightStory.tsx]"]
  node_scenery["Scenery generation<br/>[scenery.ts]"]
  node_train_art["Train illustration<br/>[Train.tsx]"]
  node_posters["Line posters<br/>[Posters.tsx]"]
end

node_traveller(("Traveller"))

node_traveller -->|"searches"| node_search_page
node_search_page -->|"requests offers"| node_search_logic
node_search_logic -->|"finds connections"| node_network
node_search_logic -->|"builds journeys"| node_time
node_search_logic -->|"ensures and loads"| node_departures
node_search_logic -->|"prices offers"| node_pricing
node_traveller -->|"chooses berth"| node_book_page
node_book_page -.->|"checks places"| node_places_api
node_book_page -->|"shows floor plan"| node_formation
node_places_api -->|"validates requests"| node_api_helpers
node_traveller -->|"holds places"| node_holds_api
node_holds_api -->|"creates hold"| node_holds
node_holds -->|"writes claims"| node_database
node_holds -->|"sets fare"| node_pricing
node_traveller -->|"enters details"| node_checkout
node_checkout -.->|"confirms booking"| node_bookings_api
node_bookings_api -->|"confirms booking"| node_bookings
node_bookings -->|"persists booking"| node_database
node_traveller -->|"opens ticket"| node_ticket_page
node_ticket_page -.->|"loads ticket"| node_bookings
node_ticket_page -.->|"offers ticket actions"| node_ticket_actions
node_ops_page -->|"loads dashboard data"| node_ops_logic
node_ops_page -->|"checks session"| node_auth
node_ops_api -->|"checks session"| node_auth
node_ops_api -->|"updates departure"| node_ops_logic
node_ops_logic -->|"reads and writes"| node_database
node_database -->|"uses schema"| node_schema
node_night_story -->|"renders scenery"| node_scenery
node_night_story -->|"renders train"| node_train_art
node_posters -->|"uses line data"| node_network
node_board -.->|"serves board data"| node_departures

click node_search_page "https://github.com/lukalomadze1/morrow/blob/main/src/app/search/page.tsx"
click node_search_logic "https://github.com/lukalomadze1/morrow/blob/main/src/lib/search.ts"
click node_network "https://github.com/lukalomadze1/morrow/blob/main/src/lib/network.ts"
click node_time "https://github.com/lukalomadze1/morrow/blob/main/src/lib/time.ts"
click node_departures "https://github.com/lukalomadze1/morrow/blob/main/src/lib/departures.ts"
click node_board "https://github.com/lukalomadze1/morrow/blob/main/src/app/api/board/route.ts"
click node_book_page "https://github.com/lukalomadze1/morrow/blob/main/src/app/book/%5BdepartureId%5D/page.tsx"
click node_formation "https://github.com/lukalomadze1/morrow/blob/main/src/lib/formation.ts"
click node_places_api "https://github.com/lukalomadze1/morrow/blob/main/src/app/api/departures/%5Bid%5D/places/route.ts"
click node_holds_api "https://github.com/lukalomadze1/morrow/blob/main/src/app/api/holds/route.ts"
click node_holds "https://github.com/lukalomadze1/morrow/blob/main/src/lib/holds.ts"
click node_checkout "https://github.com/lukalomadze1/morrow/blob/main/src/app/book/checkout/%5BholdId%5D/page.tsx"
click node_bookings_api "https://github.com/lukalomadze1/morrow/blob/main/src/app/api/bookings/route.ts"
click node_bookings "https://github.com/lukalomadze1/morrow/blob/main/src/lib/bookings.ts"
click node_ticket_page "https://github.com/lukalomadze1/morrow/blob/main/src/app/ticket/%5Btoken%5D/page.tsx"
click node_ticket_actions "https://github.com/lukalomadze1/morrow/blob/main/src/components/booking/TicketActions.tsx"
click node_ops_page "https://github.com/lukalomadze1/morrow/blob/main/src/app/ops/page.tsx"
click node_ops_logic "https://github.com/lukalomadze1/morrow/blob/main/src/lib/ops.ts"
click node_ops_api "https://github.com/lukalomadze1/morrow/blob/main/src/app/api/ops/departures/%5Bid%5D/route.ts"
click node_auth "https://github.com/lukalomadze1/morrow/blob/main/src/lib/auth.ts"
click node_pricing "https://github.com/lukalomadze1/morrow/blob/main/src/lib/pricing.ts"
click node_database "https://github.com/lukalomadze1/morrow/blob/main/src/lib/db/client.ts"
click node_schema "https://github.com/lukalomadze1/morrow/blob/main/src/lib/db/schema.ts"
click node_api_helpers "https://github.com/lukalomadze1/morrow/blob/main/src/lib/api.ts"
click node_night_story "https://github.com/lukalomadze1/morrow/blob/main/src/components/home/NightStory.tsx"
click node_scenery "https://github.com/lukalomadze1/morrow/blob/main/src/lib/scenery.ts"
click node_train_art "https://github.com/lukalomadze1/morrow/blob/main/src/components/art/Train.tsx"
click node_posters "https://github.com/lukalomadze1/morrow/blob/main/src/components/art/Posters.tsx"

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_search_page,node_search_logic,node_network,node_time,node_departures,node_board toneBlue
class node_book_page,node_formation,node_places_api,node_holds_api,node_holds,node_checkout,node_bookings_api,node_bookings,node_ticket_page,node_ticket_actions toneAmber
class node_ops_page,node_ops_logic,node_ops_api,node_auth toneMint
class node_pricing,node_database,node_schema,node_api_helpers toneRose
class node_night_story,node_scenery,node_train_art,node_posters,node_traveller toneIndigo
```

## Components

### Journey discovery

- [Journey search](https://github.com/lukalomadze1/morrow/blob/main/src/app/search/page.tsx): `src/app/search/page.tsx`
- [Offer search](https://github.com/lukalomadze1/morrow/blob/main/src/lib/search.ts): `src/lib/search.ts`
- [Lines and stations](https://github.com/lukalomadze1/morrow/blob/main/src/lib/network.ts): `src/lib/network.ts`
- [Journey timing](https://github.com/lukalomadze1/morrow/blob/main/src/lib/time.ts): `src/lib/time.ts`
- [Departure inventory](https://github.com/lukalomadze1/morrow/blob/main/src/lib/departures.ts): `src/lib/departures.ts`
- [Departure board](https://github.com/lukalomadze1/morrow/blob/main/src/app/api/board/route.ts): `src/app/api/board/route.ts`

### Booking lifecycle

- [Berth selection](https://github.com/lukalomadze1/morrow/blob/main/src/app/book/%5BdepartureId%5D/page.tsx): `src/app/book/[departureId]/page.tsx`
- [Train formation](https://github.com/lukalomadze1/morrow/blob/main/src/lib/formation.ts): `src/lib/formation.ts`
- [Place availability API](https://github.com/lukalomadze1/morrow/blob/main/src/app/api/departures/%5Bid%5D/places/route.ts): `src/app/api/departures/[id]/places/route.ts`
- [Hold API](https://github.com/lukalomadze1/morrow/blob/main/src/app/api/holds/route.ts): `src/app/api/holds/route.ts`
- [Berth holds](https://github.com/lukalomadze1/morrow/blob/main/src/lib/holds.ts): `src/lib/holds.ts`
- [Booking checkout](https://github.com/lukalomadze1/morrow/blob/main/src/app/book/checkout/%5BholdId%5D/page.tsx): `src/app/book/checkout/[holdId]/page.tsx`
- [Booking API](https://github.com/lukalomadze1/morrow/blob/main/src/app/api/bookings/route.ts): `src/app/api/bookings/route.ts`
- [Booking and tickets](https://github.com/lukalomadze1/morrow/blob/main/src/lib/bookings.ts): `src/lib/bookings.ts`
- [Ticket access](https://github.com/lukalomadze1/morrow/blob/main/src/app/ticket/%5Btoken%5D/page.tsx): `src/app/ticket/[token]/page.tsx`
- [Ticket actions](https://github.com/lukalomadze1/morrow/blob/main/src/components/booking/TicketActions.tsx): `src/components/booking/TicketActions.tsx`

### Operations

- [Operations dashboard](https://github.com/lukalomadze1/morrow/blob/main/src/app/ops/page.tsx): `src/app/ops/page.tsx`
- [Operations logic](https://github.com/lukalomadze1/morrow/blob/main/src/lib/ops.ts): `src/lib/ops.ts`
- [Operations API](https://github.com/lukalomadze1/morrow/blob/main/src/app/api/ops/departures/%5Bid%5D/route.ts): `src/app/api/ops/departures/[id]/route.ts`
- [Operations sessions](https://github.com/lukalomadze1/morrow/blob/main/src/lib/auth.ts): `src/lib/auth.ts`

### Domain platform

- [Fare calculation](https://github.com/lukalomadze1/morrow/blob/main/src/lib/pricing.ts): `src/lib/pricing.ts`
- [LibSQL database](https://github.com/lukalomadze1/morrow/blob/main/src/lib/db/client.ts): `src/lib/db/client.ts`
- [Booking data model](https://github.com/lukalomadze1/morrow/blob/main/src/lib/db/schema.ts): `src/lib/db/schema.ts`
- [API validation](https://github.com/lukalomadze1/morrow/blob/main/src/lib/api.ts): `src/lib/api.ts`

### Site experience

- [Animated night journey](https://github.com/lukalomadze1/morrow/blob/main/src/components/home/NightStory.tsx): `src/components/home/NightStory.tsx`
- [Scenery generation](https://github.com/lukalomadze1/morrow/blob/main/src/lib/scenery.ts): `src/lib/scenery.ts`
- [Train illustration](https://github.com/lukalomadze1/morrow/blob/main/src/components/art/Train.tsx): `src/components/art/Train.tsx`
- [Line posters](https://github.com/lukalomadze1/morrow/blob/main/src/components/art/Posters.tsx): `src/components/art/Posters.tsx`

### Other components

- **Traveller**

## Connections

- Traveller → Journey search: searches (evidence: `README.md`)
- Journey search → Offer search: requests offers (evidence: `src/app/search/page.tsx`)
- Offer search → Lines and stations: finds connections (evidence: `src/lib/search.ts`)
- Offer search → Journey timing: builds journeys (evidence: `src/lib/search.ts`)
- Offer search → Departure inventory: ensures and loads (evidence: `src/lib/search.ts`)
- Offer search → Fare calculation: prices offers (evidence: `src/lib/search.ts`)
- Traveller → Berth selection: chooses berth (evidence: `README.md`)
- Berth selection → Place availability API: checks places
- Berth selection → Train formation: shows floor plan
- Place availability API → API validation: validates requests (evidence: `src/app/api/departures/[id]/places/route.ts`)
- Traveller → Hold API: holds places (evidence: `README.md`)
- Hold API → Berth holds: creates hold (evidence: `src/app/api/holds/route.ts`)
- Berth holds → LibSQL database: writes claims (evidence: `src/lib/holds.ts`)
- Berth holds → Fare calculation: sets fare (evidence: `src/lib/holds.ts`)
- Traveller → Booking checkout: enters details (evidence: `README.md`)
- Booking checkout → Booking API: confirms booking
- Booking API → Booking and tickets: confirms booking (evidence: `src/app/api/bookings/route.ts`)
- Booking and tickets → LibSQL database: persists booking (evidence: `src/lib/bookings.ts`)
- Traveller → Ticket access: opens ticket (evidence: `README.md`)
- Ticket access → Booking and tickets: loads ticket
- Ticket access → Ticket actions: offers ticket actions
- Operations dashboard → Operations logic: loads dashboard data (evidence: `src/app/ops/page.tsx`)
- Operations dashboard → Operations sessions: checks session (evidence: `src/app/ops/page.tsx`)
- Operations API → Operations sessions: checks session (evidence: `src/app/api/ops/departures/[id]/route.ts`)
- Operations API → Operations logic: updates departure (evidence: `src/app/api/ops/departures/[id]/route.ts`)
- Operations logic → LibSQL database: reads and writes (evidence: `src/lib/ops.ts`)
- LibSQL database → Booking data model: uses schema (evidence: `src/lib/db/client.ts`)
- Animated night journey → Scenery generation: renders scenery (evidence: `src/components/home/NightStory.tsx`)
- Animated night journey → Train illustration: renders train (evidence: `src/components/home/NightStory.tsx`)
- Line posters → Lines and stations: uses line data (evidence: `src/components/art/Posters.tsx`)
- Departure board → Departure inventory: serves board data
