A comprehensive bus ticket booking and management platform designed for Ethiopian bus transportation services. Built with modern web technologies to streamline bus operations, ticket booking, and passenger management.
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Installation
- Configuration
- Running the Application
- API Documentation
- User Roles
- Payment Integration
- Contributing
- License
β¨ Features
- π« Online Ticket Booking - Search and book bus tickets with real-time seat availability
- π΄ Real-Time Seat Locking - See live seat availability with instant updates (NEW!)
- πΊ Visual Seat Selection - Interactive seat map with 4 color-coded status indicators
- β‘ Instant Updates - WebSocket-powered real-time synchronization across all users (<100ms)
- π Temporary Seat Reservation - Automatic 10-minute seat locks during booking process
- οΏ½ *Persistent Selection - Your seat selection is saved even after page refresh
- π¨ Smart Visual Feedback - Green (available), Blue (your selection), Orange (locked by others), Red (booked)
- οΏ½ *QR Code Tickets - Digital tickets with QR codes for easy check-in
- π³ Multiple Payment Options - Support for TeleBirr, CBE Birr, HelloCash, and international cards
- π Booking History - Track all your past and upcoming trips
- π Loyalty Program - Earn rewards for frequent bookings
- π Bus Management - Add, edit, and manage bus fleet information
- πΊοΈ Route Management - Create and manage bus routes with multiple stops
- β° Schedule Management - Set up recurring and one-time schedules
- π¨β
βοΈ Driver Assignment - Assign drivers to specific schedules - π Analytics Dashboard - View booking statistics and revenue reports
- ποΈ Ticketer System - Dedicated interface for ticket verification and check-in
- π Bus Reports Management - View, filter, and manage all driver-submitted bus reports
- π Report Status Updates - Update report status (pending β in progress β resolved)
- π Operator Notes - Add notes and actions taken for each report
- π€ Export Reports - Export filtered reports to CSV or Excel for analysis
- π± Driver Mobile App - Dedicated interface for drivers
- β Passenger Check-in - Scan QR codes to verify tickets
- πΊοΈ Route Information - View assigned routes and schedules
- π Trip Reports - Track completed trips and passenger counts
- π Bus Reporting System - Submit maintenance, fuel, and issue reports with severity levels
- π§ Quick Report Templates - Pre-configured templates for common bus issues
- π Report History - View status of submitted reports and operator responses
- π€ User Management - Manage all system users and roles
- π° Payment Tracking - Monitor all transactions and refunds
- π¨ Emergency Controls - Cancel schedules and handle emergencies
- βοΈ System Settings - Configure tariffs, fees, and system parameters
- π Comprehensive Reports - Generate detailed analytics and reports
- React 18 - Modern UI library
- Vite - Fast build tool and dev server
- Socket.io-client 4.7 - WebSocket client for real-time updates (NEW!)
- React Router - Client-side routing
- Tailwind CSS - Utility-first CSS framework
- Axios - HTTP client
- Chart.js & Recharts - Data visualization
- React Hook Form - Form management
- QRCode.react - QR code generation
- React Toastify - Toast notifications
- Lucide React - Icon library
- Flask 2.3 - Python web framework
- Flask-SocketIO 5.3 - WebSocket support for real-time features (NEW!)
- MongoDB - NoSQL database
- PyMongo - MongoDB driver
- Flask-JWT-Extended - JWT authentication
- Flask-Bcrypt - Password hashing
- Flask-CORS - Cross-origin resource sharing
- Stripe - Payment processing (international)
- Chapa (TeleBirr, CBE Birr, HelloCash)
- Stripe (International cards)
- Cash payments
ethiobus/
βββ backend/ # Flask backend application
β βββ app/
β β βββ routes/ # API route handlers
β β βββ utils/ # Utility functions
β β β βββ seat_lock.py # Seat locking logic (NEW!)
β β β βββ cleanup_locks.py # Lock cleanup task (NEW!)
β β βββ models.py # Data models and enums
β β βββ socket_events.py # WebSocket event handlers (NEW!)
β β βββ __init__.py # App factory
β βββ config/ # Configuration files
β βββ middleware/ # Custom middleware
β βββ .env # Environment variables
β βββ requirements.txt # Python dependencies
β βββ test_seat_locking.py # Seat locking tests (NEW!)
β βββ run.py # Application entry point
β
βββ frontend/ # React frontend application
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Page components
β β βββ contexts/ # React contexts
β β βββ hooks/ # Custom React hooks
β β βββ services/ # API service layer
β β β βββ socketService.js # WebSocket client (NEW!)
β β βββ utils/ # Utility functions
β β βββ styles/ # CSS and styling
β β βββ App.jsx # Main app component
β β βββ main.jsx # Application entry point
β βββ public/ # Static assets
β βββ .env # Environment variables
β βββ package.json # Node dependencies
β βββ vite.config.js # Vite configuration
β βββ tailwind.config.js # Tailwind configuration
β
βββ README.md # Project documentation
Before you begin, ensure you have the following installed:
- Node.js (v16 or higher)
- Python (v3.8 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn
- pip (Python package manager)
git clone https://github.com/yourusername/ethiobus.git
cd ethiobus# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# or
yarn installCreate a .env file in the backend directory:
# Flask Configuration
SECRET_KEY=your-secret-key-here
DEBUG=True
PORT=5000
# Database Configuration
MONGO_URI=mongodb://localhost:27017/ethiobusdb
# JWT Configuration
JWT_SECRET_KEY=your-jwt-secret-key-here
# Chapa Payment Configuration (Ethiopian Payment Gateway)
CHAPA_SECRET_KEY=your-chapa-secret-key
CHAPA_PUBLIC_KEY=your-chapa-public-key
CHAPA_BASE_URL=https://api.chapa.co/v1
# Stripe Configuration (International Payments)
STRIPE_SECRET_KEY=your-stripe-secret-key
STRIPE_PUBLIC_KEY=your-stripe-public-keyCreate a .env file in the frontend directory:
# API Configuration
VITE_API_URL=http://localhost:5000
# Payment Configuration
VITE_CHAPA_PUBLIC_KEY=your-chapa-public-key
VITE_STRIPE_PUBLIC_KEY=your-stripe-public-key-
Install MongoDB on your system
-
Start MongoDB service:
# Windows net start MongoDB # macOS brew services start mongodb-community # Linux sudo systemctl start mongod
-
The database
ethiobusdbwill be created automatically on first run
cd backend
python run.pyThe backend server will start on http://localhost:5000 with WebSocket support enabled.
Open a new terminal:
cd backend
python -m app.utils.cleanup_locksThis background task automatically removes expired seat locks every 60 seconds.
cd frontend
npm run dev
# or
yarn devThe frontend will start on http://localhost:5173
Open your browser and navigate to:
- Frontend: http://localhost:5173
- Backend API: http://localhost:5000
- Health Check: http://localhost:5000/
- WebSocket: Automatically connects when you visit seat selection page
http://localhost:5000
POST /auth/register- Register new userPOST /auth/login- User loginPOST /auth/logout- User logoutGET /auth/profile- Get user profile
GET /bookings- Get all bookingsPOST /bookings- Create new bookingGET /bookings/:id- Get booking detailsPUT /bookings/:id- Update bookingDELETE /bookings/:id- Cancel booking
GET /schedules- Get all schedulesPOST /schedules- Create schedule (operator/admin)GET /schedules/:id- Get schedule detailsPUT /schedules/:id- Update scheduleDELETE /schedules/:id- Delete schedule
GET /routes- Get all routesPOST /routes- Create route (operator/admin)GET /routes/:id- Get route detailsPUT /routes/:id- Update route
GET /buses- Get all busesPOST /buses- Add new bus (operator/admin)GET /buses/:id- Get bus detailsPUT /buses/:id- Update bus
POST /payments/initialize- Initialize paymentPOST /payments/verify- Verify paymentGET /payments/:id- Get payment details
GET /admin/users- Get all usersPUT /admin/users/:id- Update userDELETE /admin/users/:id- Delete userGET /admin/statistics- Get system statistics
POST /driver/bus-reports- Submit bus report (driver)GET /driver/bus-reports- Get driver's reportsGET /operator/bus-reports- Get all bus reports (operator)PATCH /operator/bus-reports/:id- Update report status and notesGET /operator/bus-reports/stats- Get report statistics
- Book tickets
- View booking history
- Make payments
- Receive notifications
- View assigned schedules
- Check-in passengers
- Update trip status
- View route information
- Submit bus reports (maintenance, issues, fuel status)
- Track report status and operator responses
- Manage buses
- Create routes and schedules
- Assign drivers
- View analytics
- Manage bus reports from drivers
- Update report status and add notes
- Export reports for maintenance planning
- Full system access
- User management
- System configuration
- Emergency controls
- TeleBirr - Ethiopian mobile money
- CBE Birr - Commercial Bank of Ethiopia mobile banking
- HelloCash - Ethiopian mobile wallet
- Bank Transfer - Direct bank transfers
- Stripe - International credit/debit cards
- Cash - Pay at station
- Customer selects seats and proceeds to payment
- System calculates total amount (base fare + fees)
- Customer chooses payment method
- Payment gateway processes transaction
- System verifies payment and confirms booking
- Customer receives ticket with QR code
cd backend
pytestcd frontend
npm run test
# or
yarn test- JWT-based authentication
- Password hashing with bcrypt
- CORS protection
- Input validation and sanitization
- Secure payment processing
- Role-based access control
# Login to Heroku
heroku login
# Create new app
heroku create ethiobus-api
# Set environment variables
heroku config:set SECRET_KEY=your-secret-key
heroku config:set MONGO_URI=your-mongodb-uri
# Deploy
git push heroku main# Install Vercel CLI
npm install -g vercel
# Deploy
cd frontend
vercelContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work
- Ethiopian bus transportation industry
- Open source community
- All contributors
For support, email support@ethiobus.com or join our Slack channel.
-
Instant Seat Locking - When you select a seat, it's immediately locked for 10 minutes
-
Visual Indicators - 4 color-coded states:
- π’ Green - Available (click to select)
- π΅ Blue - Your selection (click to deselect)
- π Orange - Locked by another user (wait or choose different seat)
- π΄ Red - Booked (confirmed booking)
-
Persistent Selection - Your seat selection is saved in the database and restored after page refresh
-
Automatic Cleanup - Expired locks (10+ minutes old) are automatically removed
-
Zero Race Conditions - Database-level validation prevents double bookings
-
Real-Time Updates - All users see seat changes instantly (<100ms latency)
cd backend
python test_seat_locking.pyAll 7 tests should pass:
- β Lock seats for User A
- β Prevent User B from locking same seats
- β Get locked seats for schedule
- β Unlock seats for User A
- β Confirm seat locks after booking
- β Test lock expiration
- β Lock seats for User B after expiration
Comprehensive documentation available:
FINAL_SUMMARY.md- Complete overviewQUICK_REFERENCE.md- Quick commands and troubleshootingSEAT_LOCK_BEHAVIOR.md- Detailed behavior explanationSTART_WITH_WEBSOCKET.md- Getting started guideREADME_WEBSOCKET_IMPLEMENTATION.md- Technical implementation details
- Real-time seat locking with WebSocket (COMPLETED!)
- Temporary seat reservations with auto-expiration (COMPLETED!)
- Visual seat selection with 4 color states (COMPLETED!)
- Persistent seat selection across page refresh (COMPLETED!)
- Bus reporting system for drivers and operators
- Export functionality for bus reports
- Mobile app for iOS and Android
- Real-time bus tracking with GPS
- Multi-language support (Amharic, Oromo, Tigrinya)
- Advanced analytics and reporting
- Integration with more payment gateways
- Customer review and rating system
- Automated refund processing
- SMS notifications
- WhatsApp integration
- Automated maintenance scheduling based on reports
- Push notifications for critical bus issues
Made with β€οΈ for Ethiopian bus transportation