# rifqi-dermawan/rute-ku architecture

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

- Interactive diagram: https://gitdiagram.com/rifqi-dermawan/rute-ku
- Repository: https://github.com/rifqi-dermawan/rute-ku

## Overview

RuteKu is an intercity bus-ticket booking platform. A traveler searches routes and schedules, selects and atomically holds seats, enters passenger details, reviews the booking, pays by QRIS or Midtrans, then accesses an e-ticket and protected invoice. Booking history supports cancellation and policy-based refunds. The graph includes the documented route map and GTFS export. Several payment and UI modules were not sampled; those branches reflect README capabilities, not inspected implementation details.

Main entry points: [`lib/prisma.ts`](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/prisma.ts) (Application database), [`app/api/bookings/route.ts`](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/route.ts) (Booking API), [`app/api/payment/qris/route.ts`](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/payment/qris/route.ts) (QRIS payment API), [`app/api/bookings/[id]/route.ts`](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/%5Bid%5D/route.ts) (Cancellation API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Search and routes"]
  node_home["Route search<br/>[page.tsx]"]
  node_schedules["Schedule results<br/>[page.tsx]"]
  node_schedule_api["Schedule search API<br/>[route.ts]"]
  node_schedule_detail["Schedule details<br/>[page.tsx]"]
  node_route_map["Route map<br/>[RouteMap.tsx]"]
end

subgraph group_booking["Booking journey"]
  node_seat_ui["Seat selection<br/>[page.tsx]"]
  node_seat_actions["Seat hold actions<br/>[seat-actions.ts]"]
  node_seat_management["Seat management<br/>[seat-management.ts]"]
  node_passengers["Passenger details<br/>[page.tsx]"]
  node_review["Booking review<br/>[page.tsx]"]
  node_booking_api["Booking API<br/>[route.ts]"]
  node_booking_store["Booking store<br/>[booking-store.ts]"]
  node_eticket["E-ticket<br/>[page.tsx]"]
  node_history["Booking history<br/>[page.tsx]"]
  node_invoice["Public invoice<br/>[route.ts]"]
end

subgraph group_commerce["Payments and refunds"]
  node_payment_ui["Payment screen<br/>[page.tsx]"]
  node_qris_api["QRIS payment API<br/>[route.ts]"]
  node_midtrans{{"Midtrans QRIS"}}
  node_payment_hooks["Payment status hooks<br/>[route.ts]"]
  node_cancel_api["Cancellation API<br/>[route.ts]"]
  node_refund_policy["Refund policy<br/>[refund-policy.ts]"]
end

subgraph group_identity["Identity and delivery"]
  node_auth_ui["Booking authentication<br/>[page.tsx]"]
  node_auth_context["Auth context<br/>[auth-context.tsx]"]
  node_auth_api["Auth endpoints<br/>[route.ts]"]
  node_otp_api["OTP endpoints<br/>[route.ts]"]
  node_otp_store["OTP store<br/>[otp-store.ts]"]
  node_email["Email delivery<br/>[email.ts]"]
end

subgraph group_platform["Data and integrations"]
  node_database[("Application database<br/>[prisma.ts]")]
  node_gtfs["GTFS export<br/>[export-gtfs.mjs]"]
  node_routing{{"OSRM routing"}}
end

node_traveler(("Traveler"))

node_traveler -->|"searches"| node_home
node_home -->|"opens results"| node_schedules
node_schedules -->|"loads schedules"| node_schedule_api
node_schedule_api -->|"queries and creates"| node_database
node_traveler -->|"views details"| node_schedule_detail
node_schedule_detail -->|"renders"| node_route_map
node_route_map -.->|"shows route"| node_routing
node_traveler -->|"selects seats"| node_seat_ui
node_seat_ui -->|"requests hold"| node_seat_actions
node_seat_actions -->|"delegates hold"| node_seat_management
node_seat_management -->|"updates seats"| node_database
node_traveler -->|"enters details"| node_passengers
node_passengers -.->|"continues booking"| node_review
node_review -.->|"creates booking"| node_booking_api
node_booking_api -->|"holds seats"| node_seat_management
node_booking_api -->|"writes booking"| node_database
node_booking_store -->|"reads bookings"| node_database
node_traveler -->|"pays"| node_payment_ui
node_payment_ui -.->|"requests QRIS"| node_qris_api
node_qris_api -->|"reads and records"| node_database
node_qris_api -->|"charges"| node_midtrans
node_midtrans -->|"sends status"| node_payment_hooks
node_payment_hooks -.->|"updates payment"| node_database
node_traveler -->|"manages bookings"| node_history
node_history -.->|"requests cancellation"| node_cancel_api
node_cancel_api -->|"calculates refund"| node_refund_policy
node_cancel_api -->|"updates booking"| node_database
node_traveler -->|"authenticates"| node_auth_ui
node_auth_ui -->|"uses session"| node_auth_context
node_auth_context -->|"registers or signs in"| node_auth_api
node_auth_context -->|"requests verification"| node_otp_api
node_otp_api -->|"stores codes"| node_otp_store
node_otp_api -->|"sends code"| node_email
node_traveler -->|"views ticket"| node_eticket
node_traveler -->|"opens invoice"| node_invoice
node_invoice -.->|"reads booking"| node_database
node_email -.->|"delivers e-ticket"| node_traveler
node_gtfs -->|"exports feed"| node_database

click node_home "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/page.tsx"
click node_schedules "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/schedules/page.tsx"
click node_schedule_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/schedules/route.ts"
click node_schedule_detail "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/schedules/%5Bid%5D/page.tsx"
click node_route_map "https://github.com/rifqi-dermawan/rute-ku/blob/main/components/RouteMap.tsx"
click node_seat_ui "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/seat/page.tsx"
click node_seat_actions "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/actions/seat-actions.ts"
click node_seat_management "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/seat-management.ts"
click node_passengers "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/passenger/page.tsx"
click node_review "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/review/page.tsx"
click node_booking_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/route.ts"
click node_booking_store "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/booking-store.ts"
click node_eticket "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/eticket/page.tsx"
click node_history "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/history/page.tsx"
click node_payment_ui "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/payment/page.tsx"
click node_qris_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/payment/qris/route.ts"
click node_payment_hooks "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/payment/midtrans/webhook/route.ts"
click node_cancel_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/%5Bid%5D/route.ts"
click node_refund_policy "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/refund-policy.ts"
click node_auth_ui "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/auth/page.tsx"
click node_auth_context "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/auth-context.tsx"
click node_auth_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/auth/google/url/route.ts"
click node_otp_api "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/auth/send-otp/route.ts"
click node_otp_store "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/otp-store.ts"
click node_email "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/email.ts"
click node_invoice "https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/invoice/%5BpublicToken%5D/route.ts"
click node_database "https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/prisma.ts"
click node_gtfs "https://github.com/rifqi-dermawan/rute-ku/blob/main/scripts/export-gtfs.mjs"

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,node_schedules,node_schedule_api,node_schedule_detail,node_route_map toneBlue
class node_seat_ui,node_seat_actions,node_seat_management,node_passengers,node_review,node_booking_api,node_booking_store,node_eticket,node_history,node_invoice toneAmber
class node_payment_ui,node_qris_api,node_midtrans,node_payment_hooks,node_cancel_api,node_refund_policy toneMint
class node_auth_ui,node_auth_context,node_auth_api,node_otp_api,node_otp_store,node_email toneRose
class node_database,node_gtfs,node_routing,node_traveler toneIndigo
```

## Components

### Search and routes

- [Route search](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/page.tsx): `app/page.tsx`
- [Schedule results](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/schedules/page.tsx): `app/schedules/page.tsx`
- [Schedule search API](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/schedules/route.ts): `app/api/schedules/route.ts`
- [Schedule details](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/schedules/%5Bid%5D/page.tsx): `app/schedules/[id]/page.tsx`
- [Route map](https://github.com/rifqi-dermawan/rute-ku/blob/main/components/RouteMap.tsx): `components/RouteMap.tsx`

### Booking journey

- [Seat selection](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/seat/page.tsx): `app/booking/[scheduleId]/seat/page.tsx`
- [Seat hold actions](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/actions/seat-actions.ts): `app/actions/seat-actions.ts`
- [Seat management](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/seat-management.ts): `lib/seat-management.ts`
- [Passenger details](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/passenger/page.tsx): `app/booking/[scheduleId]/passenger/page.tsx`
- [Booking review](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/review/page.tsx): `app/booking/[scheduleId]/review/page.tsx`
- [Booking API](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/route.ts): `app/api/bookings/route.ts`
- [Booking store](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/booking-store.ts): `lib/booking-store.ts`
- [E-ticket](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/eticket/page.tsx): `app/booking/[scheduleId]/eticket/page.tsx`
- [Booking history](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/history/page.tsx): `app/history/page.tsx`
- [Public invoice](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/invoice/%5BpublicToken%5D/route.ts): `app/api/invoice/[publicToken]/route.ts`

### Payments and refunds

- [Payment screen](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/payment/page.tsx): `app/booking/[scheduleId]/payment/page.tsx`
- [QRIS payment API](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/payment/qris/route.ts): `app/api/payment/qris/route.ts`
- **Midtrans QRIS**
- [Payment status hooks](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/payment/midtrans/webhook/route.ts): `app/api/payment/midtrans/webhook/route.ts`
- [Cancellation API](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/bookings/%5Bid%5D/route.ts): `app/api/bookings/[id]/route.ts`
- [Refund policy](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/refund-policy.ts): `lib/refund-policy.ts`

### Identity and delivery

- [Booking authentication](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/booking/%5BscheduleId%5D/auth/page.tsx): `app/booking/[scheduleId]/auth/page.tsx`
- [Auth context](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/auth-context.tsx): `lib/auth-context.tsx`
- [Auth endpoints](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/auth/google/url/route.ts): `app/api/auth/google/url/route.ts`
- [OTP endpoints](https://github.com/rifqi-dermawan/rute-ku/blob/main/app/api/auth/send-otp/route.ts): `app/api/auth/send-otp/route.ts`
- [OTP store](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/otp-store.ts): `lib/otp-store.ts`
- [Email delivery](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/email.ts): `lib/email.ts`

### Data and integrations

- [Application database](https://github.com/rifqi-dermawan/rute-ku/blob/main/lib/prisma.ts): `lib/prisma.ts`
- [GTFS export](https://github.com/rifqi-dermawan/rute-ku/blob/main/scripts/export-gtfs.mjs): `scripts/export-gtfs.mjs`
- **OSRM routing**

### Other components

- **Traveler**

## Connections

- Traveler → Route search: searches (evidence: `app/page.tsx`)
- Route search → Schedule results: opens results (evidence: `app/page.tsx`)
- Schedule results → Schedule search API: loads schedules (evidence: `app/schedules/page.tsx`)
- Schedule search API → Application database: queries and creates (evidence: `app/api/schedules/route.ts`)
- Traveler → Schedule details: views details
- Schedule details → Route map: renders
- Route map → OSRM routing: shows route
- Traveler → Seat selection: selects seats
- Seat selection → Seat hold actions: requests hold (evidence: `app/booking/[scheduleId]/seat/page.tsx`)
- Seat hold actions → Seat management: delegates hold (evidence: `app/actions/seat-actions.ts`)
- Seat management → Application database: updates seats (evidence: `lib/seat-management.ts`)
- Traveler → Passenger details: enters details
- Passenger details → Booking review: continues booking
- Booking review → Booking API: creates booking
- Booking API → Seat management: holds seats (evidence: `app/api/bookings/route.ts`)
- Booking API → Application database: writes booking (evidence: `app/api/bookings/route.ts`)
- Booking store → Application database: reads bookings (evidence: `lib/booking-store.ts`)
- Traveler → Payment screen: pays
- Payment screen → QRIS payment API: requests QRIS
- QRIS payment API → Application database: reads and records (evidence: `app/api/payment/qris/route.ts`)
- QRIS payment API → Midtrans QRIS: charges
- Midtrans QRIS → Payment status hooks: sends status
- Payment status hooks → Application database: updates payment
- Traveler → Booking history: manages bookings
- Booking history → Cancellation API: requests cancellation
- Cancellation API → Refund policy: calculates refund (evidence: `app/api/bookings/[id]/route.ts`)
- Cancellation API → Application database: updates booking (evidence: `app/api/bookings/[id]/route.ts`)
- Traveler → Booking authentication: authenticates
- Booking authentication → Auth context: uses session (evidence: `app/booking/[scheduleId]/auth/page.tsx`)
- Auth context → Auth endpoints: registers or signs in (evidence: `lib/auth-context.tsx`)
- Auth context → OTP endpoints: requests verification (evidence: `lib/auth-context.tsx`)
- OTP endpoints → OTP store: stores codes (evidence: `app/api/auth/send-otp/route.ts`)
- OTP endpoints → Email delivery: sends code (evidence: `app/api/auth/send-otp/route.ts`)
- Traveler → E-ticket: views ticket
- Traveler → Public invoice: opens invoice
- Public invoice → Application database: reads booking
- Email delivery → Traveler: delivers e-ticket
- GTFS export → Application database: exports feed
