# x0sa1d/bus architecture

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

- Interactive diagram: https://gitdiagram.com/x0sa1d/bus
- Repository: https://github.com/x0sa1d/bus

## Overview

Smart Bus Management System is a Next.js platform for passengers and bus operators. Passengers search scheduled trips, select seats, book tickets, and use ticketing and tracking features; staff manage the fleet and operating network through role-specific portals. Server Actions provide the backend boundary, with shared authentication and Prisma-backed data access. The README documents payment, analytics, maintenance, GPS, and notification capabilities, but source excerpts do not establish all of their runtime call paths; those links are therefore omitted or marked unverified.

Main entry points: [`src/lib/db.ts`](https://github.com/x0sa1d/bus/blob/main/src/lib/db.ts) (PostgreSQL data), [`src/features/passenger/search-content.tsx`](https://github.com/x0sa1d/bus/blob/main/src/features/passenger/search-content.tsx) (Trip search UI), [`src/actions/passenger-search.actions.ts`](https://github.com/x0sa1d/bus/blob/main/src/actions/passenger-search.actions.ts) (Passenger trip search), [`src/actions/route.actions.ts`](https://github.com/x0sa1d/bus/blob/main/src/actions/route.actions.ts) (Route actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_passenger["Passenger travel"]
  node_trip_search["Trip search UI<br/>[search-content.tsx]"]
  node_search_actions["Passenger trip search"]
  node_transport_queries["Trip availability queries"]
  node_booking_actions["Booking actions<br/>[booking.actions.ts]"]
  node_ticket_service["Ticket service<br/>[ticket-service.ts]"]
  node_ticket_ui["E-ticket and verification"]
  node_tracking_ui["Live bus tracking"]
  node_parcel_ui["Parcel services"]
  node_lost_found["Lost and found"]
end

subgraph group_operations["Bus operations"]
  node_dashboard["Dashboard and analytics"]
  node_fleet["Bus and fleet management"]
  node_routes["Route management<br/>[routes-content.tsx]"]
  node_route_actions["Route actions<br/>[route.actions.ts]"]
  node_schedules["Schedule management"]
  node_drivers["Driver management"]
  node_maintenance["Maintenance management<br/>[page.tsx]"]
  node_payments["Payment processing<br/>[payments-view.tsx]"]
end

subgraph group_platform["Platform services"]
  node_auth_ui["Login and registration"]
  node_auth_actions["Authentication actions<br/>[auth.actions.ts]"]
  node_auth_service["Session and access control<br/>[auth-server.ts]"]
end

subgraph group_data["Data and integrations"]
  node_db[("PostgreSQL data<br/>[db.ts]")]
  node_schemas["Input validation<br/>[index.ts]"]
end

node_passenger(("Passenger"))
node_operator(("Operator staff"))
node_external_payments["Payment gateways"]
node_maps["Google Maps"]
node_notifications["Email, SMS, push"]

node_passenger -->|"registers or logs in"| node_auth_ui
node_operator -->|"registers or logs in"| node_auth_ui
node_auth_ui -.->|"submits credentials"| node_auth_actions
node_auth_actions -->|"uses sessions"| node_auth_service
node_passenger -->|"searches trips"| node_trip_search
node_trip_search -->|"requests availability"| node_search_actions
node_search_actions -->|"fetches trips"| node_transport_queries
node_search_actions -->|"checks configuration"| node_db
node_trip_search -->|"creates seat booking"| node_booking_actions
node_booking_actions -.->|"issues tickets"| node_ticket_service
node_passenger -->|"views e-ticket"| node_ticket_ui
node_passenger -->|"tracks bus"| node_tracking_ui
node_passenger -.->|"tracks parcel"| node_parcel_ui
node_passenger -.->|"uses service"| node_lost_found
node_operator -->|"reviews performance"| node_dashboard
node_dashboard -->|"reads metrics"| node_db
node_operator -->|"manages buses"| node_fleet
node_operator -->|"plans routes"| node_routes
node_routes -->|"creates and edits"| node_route_actions
node_route_actions -->|"persists routes"| node_db
node_operator -->|"assigns trips"| node_schedules
node_operator -->|"manages drivers"| node_drivers
node_operator -->|"schedules service"| node_maintenance
node_operator -->|"reviews payments"| node_payments
node_payments -.->|"processes payments"| node_external_payments
node_tracking_ui -.->|"uses map provider"| node_maps
node_operator -.->|"sends notifications"| node_notifications
node_auth_service -->|"reads user data"| node_db
node_route_actions -->|"validates route input"| node_schemas

click node_auth_ui "https://github.com/x0sa1d/bus/tree/main/src/features/auth"
click node_auth_actions "https://github.com/x0sa1d/bus/blob/main/src/actions/auth.actions.ts"
click node_auth_service "https://github.com/x0sa1d/bus/blob/main/src/lib/auth-server.ts"
click node_trip_search "https://github.com/x0sa1d/bus/blob/main/src/features/passenger/search-content.tsx"
click node_search_actions "https://github.com/x0sa1d/bus/blob/main/src/actions/passenger-search.actions.ts"
click node_transport_queries "https://github.com/x0sa1d/bus/blob/main/src/lib/passenger-transport.ts"
click node_booking_actions "https://github.com/x0sa1d/bus/blob/main/src/actions/booking.actions.ts"
click node_ticket_service "https://github.com/x0sa1d/bus/blob/main/src/lib/ticket-service.ts"
click node_ticket_ui "https://github.com/x0sa1d/bus/tree/main/src/features/tickets"
click node_tracking_ui "https://github.com/x0sa1d/bus/tree/main/src/features/tracking"
click node_parcel_ui "https://github.com/x0sa1d/bus/blob/main/src/features/parcels/parcels-content.tsx"
click node_lost_found "https://github.com/x0sa1d/bus/blob/main/src/features/lost-found/lost-found-content.tsx"
click node_dashboard "https://github.com/x0sa1d/bus/tree/main/src/features/dashboard"
click node_fleet "https://github.com/x0sa1d/bus/tree/main/src/features/buses"
click node_routes "https://github.com/x0sa1d/bus/blob/main/src/features/routes/routes-content.tsx"
click node_route_actions "https://github.com/x0sa1d/bus/blob/main/src/actions/route.actions.ts"
click node_schedules "https://github.com/x0sa1d/bus/tree/main/src/features/schedules"
click node_drivers "https://github.com/x0sa1d/bus/tree/main/src/features/drivers"
click node_maintenance "https://github.com/x0sa1d/bus/blob/main/src/app/(dashboard)/dashboard/maintenance/page.tsx"
click node_payments "https://github.com/x0sa1d/bus/blob/main/src/features/payments/payments-view.tsx"
click node_db "https://github.com/x0sa1d/bus/blob/main/src/lib/db.ts"
click node_schemas "https://github.com/x0sa1d/bus/blob/main/src/schemas/index.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_trip_search,node_search_actions,node_transport_queries,node_booking_actions,node_ticket_service,node_ticket_ui,node_tracking_ui,node_parcel_ui,node_lost_found toneBlue
class node_dashboard,node_fleet,node_routes,node_route_actions,node_schedules,node_drivers,node_maintenance,node_payments toneAmber
class node_auth_ui,node_auth_actions,node_auth_service toneMint
class node_db,node_schemas toneRose
class node_passenger,node_operator,node_external_payments,node_maps,node_notifications toneIndigo
```

## Components

### Passenger travel

- [Trip search UI](https://github.com/x0sa1d/bus/blob/main/src/features/passenger/search-content.tsx): `src/features/passenger/search-content.tsx`
- [Passenger trip search](https://github.com/x0sa1d/bus/blob/main/src/actions/passenger-search.actions.ts): `src/actions/passenger-search.actions.ts`
- [Trip availability queries](https://github.com/x0sa1d/bus/blob/main/src/lib/passenger-transport.ts): `src/lib/passenger-transport.ts`
- [Booking actions](https://github.com/x0sa1d/bus/blob/main/src/actions/booking.actions.ts): `src/actions/booking.actions.ts`
- [Ticket service](https://github.com/x0sa1d/bus/blob/main/src/lib/ticket-service.ts): `src/lib/ticket-service.ts`
- [E-ticket and verification](https://github.com/x0sa1d/bus/tree/main/src/features/tickets): `src/features/tickets`
- [Live bus tracking](https://github.com/x0sa1d/bus/tree/main/src/features/tracking): `src/features/tracking`
- [Parcel services](https://github.com/x0sa1d/bus/blob/main/src/features/parcels/parcels-content.tsx): `src/features/parcels/parcels-content.tsx`
- [Lost and found](https://github.com/x0sa1d/bus/blob/main/src/features/lost-found/lost-found-content.tsx): `src/features/lost-found/lost-found-content.tsx`

### Bus operations

- [Dashboard and analytics](https://github.com/x0sa1d/bus/tree/main/src/features/dashboard): `src/features/dashboard`
- [Bus and fleet management](https://github.com/x0sa1d/bus/tree/main/src/features/buses): `src/features/buses`
- [Route management](https://github.com/x0sa1d/bus/blob/main/src/features/routes/routes-content.tsx): `src/features/routes/routes-content.tsx`
- [Route actions](https://github.com/x0sa1d/bus/blob/main/src/actions/route.actions.ts): `src/actions/route.actions.ts`
- [Schedule management](https://github.com/x0sa1d/bus/tree/main/src/features/schedules): `src/features/schedules`
- [Driver management](https://github.com/x0sa1d/bus/tree/main/src/features/drivers): `src/features/drivers`
- [Maintenance management](https://github.com/x0sa1d/bus/blob/main/src/app/(dashboard)/dashboard/maintenance/page.tsx): `src/app/(dashboard)/dashboard/maintenance/page.tsx`
- [Payment processing](https://github.com/x0sa1d/bus/blob/main/src/features/payments/payments-view.tsx): `src/features/payments/payments-view.tsx`

### Platform services

- [Login and registration](https://github.com/x0sa1d/bus/tree/main/src/features/auth): `src/features/auth`
- [Authentication actions](https://github.com/x0sa1d/bus/blob/main/src/actions/auth.actions.ts): `src/actions/auth.actions.ts`
- [Session and access control](https://github.com/x0sa1d/bus/blob/main/src/lib/auth-server.ts): `src/lib/auth-server.ts`

### Data and integrations

- [PostgreSQL data](https://github.com/x0sa1d/bus/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Input validation](https://github.com/x0sa1d/bus/blob/main/src/schemas/index.ts): `src/schemas/index.ts`

### Other components

- **Passenger**
- **Operator staff**
- **Payment gateways**
- **Google Maps**
- **Email, SMS, push**

## Connections

- Passenger → Login and registration: registers or logs in
- Operator staff → Login and registration: registers or logs in
- Login and registration → Authentication actions: submits credentials
- Authentication actions → Session and access control: uses sessions (evidence: `src/actions/auth.actions.ts`)
- Passenger → Trip search UI: searches trips
- Trip search UI → Passenger trip search: requests availability (evidence: `src/features/passenger/search-content.tsx`)
- Passenger trip search → Trip availability queries: fetches trips (evidence: `src/actions/passenger-search.actions.ts`)
- Passenger trip search → PostgreSQL data: checks configuration (evidence: `src/actions/passenger-search.actions.ts`)
- Trip search UI → Booking actions: creates seat booking (evidence: `src/features/passenger/search-content.tsx`)
- Booking actions → Ticket service: issues tickets
- Passenger → E-ticket and verification: views e-ticket
- Passenger → Live bus tracking: tracks bus
- Passenger → Parcel services: tracks parcel
- Passenger → Lost and found: uses service
- Operator staff → Dashboard and analytics: reviews performance
- Dashboard and analytics → PostgreSQL data: reads metrics
- Operator staff → Bus and fleet management: manages buses
- Operator staff → Route management: plans routes
- Route management → Route actions: creates and edits (evidence: `src/features/routes/routes-content.tsx`)
- Route actions → PostgreSQL data: persists routes (evidence: `src/actions/route.actions.ts`)
- Operator staff → Schedule management: assigns trips
- Operator staff → Driver management: manages drivers
- Operator staff → Maintenance management: schedules service
- Operator staff → Payment processing: reviews payments
- Payment processing → Payment gateways: processes payments
- Live bus tracking → Google Maps: uses map provider
- Operator staff → Email, SMS, push: sends notifications
- Session and access control → PostgreSQL data: reads user data (evidence: `src/lib/auth-server.ts`)
- Route actions → Input validation: validates route input (evidence: `src/actions/route.actions.ts`)
