A modern bus ticketing system connecting passengers, bus staff, and bus owners in real-time.
Imagine booking a bus ticket as easy as ordering food online. That's Bus AgentUB.
The Problem We Solve:
- Passengers struggle to find and book intercity buses
- Bus staff manage bookings manually with phone calls
- Owners can't track their buses and revenue in real-time
Our Solution:
- Passengers: Search buses, book seats, track live bus location
- Supervisors (Bus Staff): Manage bookings, update location, handle passengers
- Owners: Monitor all buses, view sales reports, manage staff
Search buses → Send booking request → Wait for approval →
Choose seats & boarding point → Get confirmed ticket → Track bus live
Key Feature: Passenger details stay private until supervisor approves the booking.
See booking requests → Accept/Reject → View passenger details →
Update bus location → Manage boarding
Key Feature: See only booking existence initially, full details appear after acceptance.
Add buses → Register supervisors → Monitor bookings →
View revenue reports → Track all operations
Key Feature: Complete dashboard showing all buses, bookings, and earnings.
Built With:
- Backend: Python (FastAPI) - The server that handles all requests
- Database: PostgreSQL - Where all data is securely stored
- Hosting: Railway - Cloud platform for 24/7 availability
- Maps: OpenStreetMap - Free, open-source maps for location features
- Real-time: WebSockets - Live updates without refreshing
Frontend (Coming Soon):
- Flutter mobile apps for Passengers & Supervisors
- Flutter web dashboard for Owners
- Passenger phone numbers hidden until booking approved
- National IDs never exposed in API responses
- Secure authentication with 7-day session tokens
- Request: Passenger sends simple booking request (just bus selection)
- Review: Supervisor sees request without passenger details
- Approval: Supervisor accepts → passenger details revealed
- Confirmation: Passenger selects exact seats and boarding point
- Ticket: Digital ticket generated with all details
- Live bus location tracking on map
- Instant booking status updates
- Real-time seat availability
- Dashboard with key metrics (buses, bookings, revenue)
- Detailed sales reports by date and bus
- Supervisor management system
- Complete ownership verification (supervisors can't self-register)
- Passengers can poll booking status to detect approval
- Supervisors receive their assigned buses on login
- No manual refresh needed for status changes
- Frontend implements 5-10 second polling for real-time feel
Can Do:
- Search for buses by route and date
- Send booking requests
- Choose seats and boarding points (after approval)
- View confirmed tickets
- Track bus location in real-time
- Cancel bookings
Cannot Do:
- See bus details before booking is accepted
- Book without approval
- Access supervisor or owner features
Can Do:
- View all booking requests for their buses
- Accept or reject bookings
- See passenger details after accepting
- Update live bus GPS location
- Manage boarding points
- View passenger list with boarding sequence
- View ticket sales report for their assigned buses
Cannot Do:
- Self-register (must be registered by owner)
- Access owner dashboard
- Manage other buses
Can Do:
- Register and manage buses
- Create supervisor accounts
- View complete dashboard
- Monitor all bookings and tickets
- Generate revenue reports
- Assign supervisors to buses
Has Access To:
- All bus operations
- Sales analytics
- Supervisor management
- Complete system overview
Scenario: Sarah wants to travel from Dhaka to Chittagong
-
Sarah searches for buses:
- Sees: Route, time, type (AC/Non-AC), price
- Doesn't see: Supervisor details, boarding points, available seats (privacy!)
-
Sarah requests booking for Bus #123:
- System creates pending booking
- Supervisor Ahmed gets notification
- Ahmed sees: "1 new booking request" (no passenger details yet)
-
Ahmed accepts the booking:
- System reveals: Sarah's name and phone to Ahmed
- Sarah gets notification: "Booking accepted!"
- Sarah now sees: Boarding points list, full bus details
-
Sarah confirms ticket:
- Chooses: 2 seats, Mohakhali boarding point
- System generates ticket with total fare
- Bus seat count auto-updates
-
Journey day:
- Sarah tracks bus live on map
- Sees ETA to her boarding point
- Ahmed manages all passengers' boarding sequence
Frontend Apps → API Gateway → Backend (FastAPI) → Database (PostgreSQL)
↓
WebSocket Server (Real-time updates)
↓
OpenStreetMap APIs (Location services)
- JWT authentication (7-day tokens)
- Role-based access control
- Password hashing (bcrypt)
- Input validation on all endpoints
- CORS protection
- SQL injection prevention
bus_agentub/
├── backend/ # FastAPI application
│ ├── app/
│ │ ├── models/ # Database tables
│ │ ├── routers/ # API endpoints
│ │ └── schemas/ # Data validation
│ └── requirements.txt
├── frontend/ # Flutter apps (coming soon)
├── docs/ # Technical documentation
│ ├── api_contract.md # Complete API reference
│ ├── db_schema.md # Database structure
│ └── db_api_mapping.md # Data flow diagrams
└── README.md # This file
Tech Stack Details:
- Language: Python 3.12
- Framework: FastAPI 0.104.1
- ORM: SQLAlchemy 2.0
- Database: PostgreSQL 16
- Authentication: JWT (python-jose)
- Password Hashing: bcrypt
- Validation: Pydantic v2
- WebSocket: Native FastAPI WebSockets
- Maps: Nominatim (geocoding), OSRM (routing), Overpass (places)