# animesh4956/bus-ticket-booking-system architecture

> Architecture diagram of the GitHub repository animesh4956/bus-ticket-booking-system, 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/animesh4956/bus-ticket-booking-system
- Repository: https://github.com/animesh4956/bus-ticket-booking-system

## Overview

BusGo is a full-stack bus ticket booking platform. Travelers search routes, choose seats, book tickets, view confirmations and download PDFs; users can also manage accounts and verify tickets, while administrators manage buses, bookings, users and promotions. The Next.js app calls a Spring Boot REST API backed by PostgreSQL. The README documents Redis seat locking, but the sampled source does not show its runtime wiring; several backend details are likewise represented only by documented capabilities and directory paths.

Main entry points: [`frontend/src/lib/api.ts`](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/lib/api.ts) (REST API client), [`src/main/java/com/example/demo/controller/api`](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/controller/api) (Spring REST API), [`src/main/java/com/example/demo/service/BookingService.java`](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/service/BookingService.java) (Booking services), [`src/main/java/com/example/demo/repository`](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/repository) (Data repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_home["Route search<br/>[page.tsx]"]
  node_results["Bus results<br/>[page.tsx]"]
  node_seatselect["Seat selection<br/>[page.tsx]"]
  node_confirmation["Booking confirmation<br/>[page.tsx]"]
  node_dashboard["User dashboard<br/>[page.tsx]"]
  node_verification["Ticket verification<br/>[page.tsx]"]
  node_adminui["Admin console<br/>[page.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_authpages["Login and registration<br/>[page.tsx]"]
  node_authcontext["Auth context<br/>[useAuth.tsx]"]
  node_api["REST API client<br/>[api.ts]"]
  node_auth_backend["JWT security"]
end

subgraph group_booking["Booking domain"]
  node_api_backend["Spring REST API"]
  node_booking_logic["Booking services"]
  node_ticket_pdf["PDF ticket generation"]
  node_redis[("Redis seat locking")]
end

subgraph group_operations["Operations and persistence"]
  node_admin_backend["Admin management"]
  node_entities["Domain entities"]
  node_repositories["Data repositories"]
  node_postgres[("PostgreSQL")]
  node_migrations["Schema migrations"]
end

node_traveler(("Traveler"))

node_traveler -->|"searches routes"| node_home
node_home -->|"opens results"| node_results
node_results -->|"chooses bus"| node_seatselect
node_seatselect -->|"views booking"| node_confirmation
node_traveler -->|"signs in"| node_authpages
node_authpages -->|"calls login"| node_authcontext
node_authcontext -->|"requests identity"| node_api
node_api -->|"calls REST API"| node_api_backend
node_seatselect -->|"requests booking"| node_api
node_confirmation -->|"loads ticket"| node_api
node_dashboard -->|"manages bookings"| node_api
node_verification -->|"verifies PNR"| node_api
node_adminui -->|"manages platform"| node_api
node_api_backend -->|"secures routes"| node_auth_backend
node_api_backend -->|"delegates booking"| node_booking_logic
node_booking_logic -->|"generates PDF"| node_ticket_pdf
node_api_backend -->|"routes admin"| node_admin_backend
node_booking_logic -->|"persists bookings"| node_repositories
node_admin_backend -->|"manages records"| node_repositories
node_repositories -->|"maps entities"| node_entities
node_repositories -->|"reads and writes"| node_postgres
node_migrations -->|"creates schema"| node_postgres
node_booking_logic -.->|"locks seats"| node_redis

click node_home "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/page.tsx"
click node_results "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/buses/page.tsx"
click node_seatselect "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/book/%5BbusId%5D/page.tsx"
click node_confirmation "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/booking/%5Breference%5D/page.tsx"
click node_dashboard "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/dashboard/page.tsx"
click node_verification "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/verify/%5Bpnr%5D/page.tsx"
click node_adminui "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/admin/page.tsx"
click node_authpages "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/login/page.tsx"
click node_authcontext "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/hooks/useAuth.tsx"
click node_api "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/lib/api.ts"
click node_api_backend "https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/controller/api"
click node_booking_logic "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/service/BookingService.java"
click node_ticket_pdf "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/service/PdfTicketService.java"
click node_auth_backend "https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/security"
click node_admin_backend "https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/controller/api/AdminController.java"
click node_entities "https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/model"
click node_repositories "https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/repository"
click node_migrations "https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/resources/db/migration"

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_results,node_seatselect,node_confirmation,node_dashboard,node_verification,node_adminui toneBlue
class node_authpages,node_authcontext,node_api,node_auth_backend toneAmber
class node_api_backend,node_booking_logic,node_ticket_pdf,node_redis toneMint
class node_admin_backend,node_entities,node_repositories,node_postgres,node_migrations toneRose
class node_traveler toneIndigo
```

## Components

### Web experience

- [Route search](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Bus results](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/buses/page.tsx): `frontend/src/app/buses/page.tsx`
- [Seat selection](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/book/%5BbusId%5D/page.tsx): `frontend/src/app/book/[busId]/page.tsx`
- [Booking confirmation](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/booking/%5Breference%5D/page.tsx): `frontend/src/app/booking/[reference]/page.tsx`
- [User dashboard](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`
- [Ticket verification](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/verify/%5Bpnr%5D/page.tsx): `frontend/src/app/verify/[pnr]/page.tsx`
- [Admin console](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/admin/page.tsx): `frontend/src/app/admin/page.tsx`

### Identity and access

- [Login and registration](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/app/login/page.tsx): `frontend/src/app/login/page.tsx`
- [Auth context](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/hooks/useAuth.tsx): `frontend/src/hooks/useAuth.tsx`
- [REST API client](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`
- [JWT security](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/security): `src/main/java/com/example/demo/security`

### Booking domain

- [Spring REST API](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/controller/api): `src/main/java/com/example/demo/controller/api`
- [Booking services](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/service/BookingService.java): `src/main/java/com/example/demo/service/BookingService.java`
- [PDF ticket generation](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/service/PdfTicketService.java): `src/main/java/com/example/demo/service/PdfTicketService.java`
- **Redis seat locking**

### Operations and persistence

- [Admin management](https://github.com/animesh4956/bus-ticket-booking-system/blob/main/src/main/java/com/example/demo/controller/api/AdminController.java): `src/main/java/com/example/demo/controller/api/AdminController.java`
- [Domain entities](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/model): `src/main/java/com/example/demo/model`
- [Data repositories](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/java/com/example/demo/repository): `src/main/java/com/example/demo/repository`
- **PostgreSQL**
- [Schema migrations](https://github.com/animesh4956/bus-ticket-booking-system/tree/main/src/main/resources/db/migration): `src/main/resources/db/migration`

### Other components

- **Traveler**

## Connections

- Traveler → Route search: searches routes (evidence: `README.md`)
- Route search → Bus results: opens results (evidence: `frontend/src/app/page.tsx`)
- Bus results → Seat selection: chooses bus (evidence: `frontend/src/app/buses/page.tsx`)
- Seat selection → Booking confirmation: views booking (evidence: `README.md`)
- Traveler → Login and registration: signs in (evidence: `README.md`)
- Login and registration → Auth context: calls login (evidence: `frontend/src/app/login/page.tsx`)
- Auth context → REST API client: requests identity (evidence: `frontend/src/hooks/useAuth.tsx`)
- REST API client → Spring REST API: calls REST API (evidence: `README.md`)
- Seat selection → REST API client: requests booking (evidence: `README.md`)
- Booking confirmation → REST API client: loads ticket (evidence: `README.md`)
- User dashboard → REST API client: manages bookings (evidence: `README.md`)
- Ticket verification → REST API client: verifies PNR (evidence: `README.md`)
- Admin console → REST API client: manages platform (evidence: `README.md`)
- Spring REST API → JWT security: secures routes (evidence: `README.md`)
- Spring REST API → Booking services: delegates booking (evidence: `README.md`)
- Booking services → PDF ticket generation: generates PDF (evidence: `README.md`)
- Spring REST API → Admin management: routes admin (evidence: `README.md`)
- Booking services → Data repositories: persists bookings (evidence: `README.md`)
- Admin management → Data repositories: manages records (evidence: `README.md`)
- Data repositories → Domain entities: maps entities (evidence: `README.md`)
- Data repositories → PostgreSQL: reads and writes (evidence: `README.md`)
- Schema migrations → PostgreSQL: creates schema (evidence: `README.md`)
- Booking services → Redis seat locking: locks seats (evidence: `README.md`)
