Full-stack bus ticket booking platform with microservices architecture
Features β’ Tech Stack β’ Architecture β’ Getting Started
A complete bus ticket booking solution built with microservices architecture. The platform includes customer-facing features for searching and booking tickets, alongside a comprehensive admin dashboard for fleet management, analytics, and operations.
Tech Highlights: 11 microservices β’ Next.js 16 β’ NestJS β’ PostgreSQL β’ Redis β’ PayOS Integration
- Smart Trip Search - Filter by price, time, amenities with real-time availability
- Interactive Seat Selection - Visual picker with multi-floor support for double-decker buses
- Payment Integration - PayOS for QR payments, bank transfers, and credit cards
- E-Tickets - QR-coded tickets with PDF export
- Booking Management - View history, request cancellations, track status
- 360Β° Bus Preview - Panoramic interior views
- Reviews & Ratings - Post-trip feedback system
- Email Notifications - Booking confirmations and updates
- Internationalization - Vietnamese and English support
- Dark Mode - Theme persistence across sessions
- Fleet Management - Manage buses with custom seat layouts and amenities
- Trip Scheduling - Create recurring trips with dynamic pricing
- Seat Layout Editor - Drag-and-drop designer with multi-floor support
- Analytics - Revenue tracking, booking trends, route performance
- Customer Management - User profiles and payment history
- Refund Processing - Handle cancellation requests
- Reviews Management - Monitor and respond to feedback
- Company Settings - Branding, policies, and configurations
- Driver Assignment - Manage driver schedules
- Knowledge Base - Help articles with markdown editor
- Multi-Provider Auth - Email/password and Google OAuth via Firebase
- JWT Sessions - Access + Refresh token pattern with auto-refresh
- RBAC - Role-based access control (User, Admin, Business)
- Route Protection - Client and server-side guards
- Payment Security - PayOS webhook verification and signature validation
- Framework: Next.js 16 (App Router, React Server Components)
- State Management: Redux Toolkit + Redux Persist
- Data Fetching: RTK Query with auto-retry and caching
- Styling: Tailwind CSS 4 with custom design tokens
- UI Libraries: Recharts, Lottie, Pannellum, React Day Picker, React Markdown, SweetAlert2
- Internationalization: i18next
- Testing: Jest + React Testing Library
- Framework: NestJS 11 (Microservices architecture)
- ORM: TypeORM with PostgreSQL
- Caching: Redis for sessions and rate limiting
- API Gateway: Nginx reverse proxy
- Authentication: Firebase Admin SDK
- Image Storage: Cloudinary
- Payments: PayOS integration
- Email: Nodemailer
- Containerization: Docker + Docker Compose
- CI/CD: GitHub Actions (12 automated workflows)
- Package Manager: pnpm with workspace support
- Code Quality: ESLint + Prettier + Husky + lint-staged
- Commit Standards: Commitlint (Conventional Commits)
- Deployment: Portainer (Frontend), Digital Ocean (Backend)
graph TB
Client[Next.js Client]
Gateway[Nginx API Gateway :8080]
Auth[Auth Service :3001]
User[User Service :3002]
Trip[Trip Service :3003]
Vehicle[Vehicle Service :3004]
Reservation[Reservation Service :3005]
Payment[Payment Service :3006]
Ticket[Ticket Service :3007]
Location[Location Service :3008]
Noti[Notification Service :3009]
AI[AI Service :3010]
DB[(PostgreSQL)]
Cache[(Redis)]
Firebase[Firebase Auth]
PayOS[PayOS Gateway]
Cloudinary[Cloudinary]
Client -->|HTTP/HTTPS| Gateway
Gateway --> Auth
Gateway --> User
Gateway --> Trip
Gateway --> Vehicle
Gateway --> Reservation
Gateway --> Payment
Gateway --> Ticket
Gateway --> Location
Gateway --> Noti
Gateway --> AI
Auth --> DB
User --> DB
Trip --> DB
Vehicle --> DB
Reservation --> DB
Payment --> DB
Ticket --> DB
Location --> DB
Auth --> Cache
Auth --> Firebase
Payment --> PayOS
Vehicle --> Cloudinary
style Client fill:#61dafb
style Gateway fill:#009639
style DB fill:#336791
style Cache fill:#dc382d
style Firebase fill:#ffca28
style PayOS fill:#0080ff
style Cloudinary fill:#3448c5
| Service | Port | Responsibility |
|---|---|---|
| bso-auth-svc | 8081 | Authentication, JWT, Google OAuth |
| bso-user-svc | 8080 | User profiles and preferences |
| bso-trip-svc | 3002 | Trip scheduling and search |
| bso-vehicle-svc | 3001 | Fleet management, seat layouts |
| bso-reservation-svc | 3003 | Bookings, seat locking, analytics |
| bso-payment-svc | 8083 | PayOS integration, refunds |
| bso-ticket-svc | 3004 | E-tickets, QR codes, cancellations |
| bso-location-svc | 3000 | Locations and routes |
| bso-noti-svc | 9000 | Email notifications |
| bso-ai-svc | 7000 | AI chatbot support |
sequenceDiagram
participant C as Client
participant G as API Gateway
participant A as Auth Service
participant T as Trip Service
participant R as Reservation Service
participant P as Payment Service
participant TK as Ticket Service
participant N as Notification Service
C->>G: Search trips (date, route)
G->>T: GET /trips/search
T-->>C: Available trips
C->>G: Select seats
G->>A: Validate auth token
A-->>G: User authenticated
G->>R: POST /reservations/create
R->>R: Lock seats (15 min)
R-->>C: Reservation created
C->>G: Initiate payment
G->>P: POST /payments/payos/create
P->>PayOS: Create payment link
PayOS-->>C: QR code / payment URL
C->>PayOS: Complete payment
PayOS->>P: Payment webhook
P->>R: Confirm reservation
R->>TK: Generate e-ticket
TK->>N: Send confirmation email
N-->>C: Email with ticket PDF
- Node.js 18+
- pnpm 9+
- Docker & Docker Compose
- PostgreSQL 15+
- Redis 7+
git clone https://github.com/ntkwan/csc13114-busio.git
cd csc13114-busio# Install root dependencies
npm install
# Install client dependencies
cd client
pnpm install
# Install backend dependencies (each service)
cd ../server/bso-auth-svc
npm install
# Repeat for other services...NEXT_PUBLIC_BACKEND_URL=http://localhost:8080
NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=your_measurement_id
NEXT_PUBLIC_GEOAPIFY_API_KEY=your_geoapify_keyPORT=3000
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=your_password
DB_NAME=busio_db
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_USERNAME=
REDIS_PASSWORD=
JWT_SECRET=your_super_secret_key
JWT_EXPIRES_IN=15m
JWT_REFRESH_SECRET=your_refresh_secret
JWT_REFRESH_EXPIRES_IN=7d
FIREBASE_SERVICE_ACCOUNT_PATH=./bso-service-account-key.json
FIREBASE_API_KEY=your_firebase_api_key
FIREBASE_TOKEN_VALIDATION_URL=
SENDGRID_API_KEY=your_sendgrid_key
PAYOS_CLIENT_ID=your_payos_client_id
PAYOS_API_KEY=your_payos_api_key
PAYOS_CHECKSUM_KEY=your_checksum_key
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# Inter-service URLs
SVC_USER_URL=http://bso-user-svc:8080
SVC_RESERVATION_URL=http://bso-reservation-svc:3003
SVC_TRIP_URL=http://bso-trip-svc:3002
SVC_NOTIFICATION_URL=http://bso-noti-svc:9000# Using Docker Compose
cd server
docker-compose up -d postgres redis
# Run migrations (TypeORM)
cd bso-auth-svc
pnpm migration:runDevelopment Mode:
# Terminal 1: Start backend services
cd server/bso-api-gateway
docker-compose up
# Terminal 2: Start auth service
cd server/bso-auth-svc
pnpm start:dev
# Terminal 3: Start other services (repeat for each)
cd server/bso-user-svc
pnpm start:dev
# Terminal 4: Start frontend
cd client
pnpm devProduction Mode (Docker):
# Build and run all services
docker-compose up --build -dAccess the application:
- Frontend: http://localhost:3000
- API Gateway: http://localhost:8080
- Admin Panel: http://localhost:3000/admin
Admin Account:
Email: [email protected]
Password: 12345678
The project leverages GitHub Actions for CI and ArgoCD for GitOps-based CD:
- β Code Quality: ESLint and Prettier enforcement
- β Security: Commit linting and build validation
- β Artifacts: Automated Docker image builds pushed to Docker Hub
- π Automated Sync: Infrastructure updates triggered by GitHub Actions
- π Branch-based Environments: Helm chart values managed in an
infrastructurebranch - π Rollbacks: Easy version management and rollbacks via Git history
For initial server setup and manual deployments, specialized playbooks are available in client/playbook:
- π Server Setup: Automated Docker installation and configuration
- π Service Deployment: Ansible playbooks for client and gateway services
- π Inventory Management: Centralized server management via
inventory.ini
Image Tagging Strategy:
Images are tagged with the short Git SHA (e.g., latest-a3f5c2b) for precise version tracking and auditability.
π URL: http://152.42.195.211:3000
- 11 independent microservices with clear separation of concerns
- Nginx API Gateway with rate limiting
- Normalized PostgreSQL schema (20+ tables)
- Redis caching for sessions and frequently accessed data
- JWT with refresh token rotation
- Role-based access control (RBAC)
- Input validation via class-validator DTOs
- CORS and XSS protection
- Next.js App Router with React Server Components
- Code splitting and lazy loading
- Responsive design with dark mode
- Internationalization (vi/en)
- Docker containerization
- GitHub Actions CI/CD + ArgoCD GitOps
- Ansible playbooks for server automation
- ESLint + Prettier + Husky
csc13114-busio/
βββ client/ # Next.js frontend
β βββ src/
β β βββ app/ # App Router pages
β β β βββ (main)/ # Main layout (user routes)
β β β β βββ page.tsx # Home page
β β β β βββ search-results/
β β β β βββ schedule/
β β β β βββ ticket-lookup/
β β β β βββ cancel-ticket/
β β β β βββ settings/
β β β β βββ policy/
β β β βββ admin/ # Admin dashboard
β β βββ components/ # Reusable components
β β βββ features/ # Redux slices
β β βββ store/ # Redux store config
β β βββ services/ # RTK Query APIs
β β βββ utils/ # Helper functions
β βββ public/ # Static assets
β βββ package.json
β
βββ server/ # NestJS backend
β βββ bso-api-gateway/ # Nginx reverse proxy
β βββ bso-auth-svc/ # Authentication service
β βββ bso-user-svc/ # User management
β βββ bso-trip-svc/ # Trip scheduling
β βββ bso-vehicle-svc/ # Fleet management
β βββ bso-reservation-svc/ # Booking system
β βββ bso-payment-svc/ # Payment processing
β βββ bso-ticket-svc/ # E-ticket generation
β βββ bso-location-svc/ # Location management
β βββ bso-noti-svc/ # Notification service
β βββ bso-ai-svc/ # AI chatbot
β βββ docker-compose.yml
β
βββ .github/workflows/ # CI/CD pipelines
βββ .husky/ # Git hooks
βββ README.md
This project is licensed under the MIT License - see the LICENSE file for details.