How satishsurani/mybus-bus-booking-site works
1. Purpose and Runtime
A server-rendered PHP/MySQL bus-ticket booking system. Browser pages use JavaScript/AJAX for dynamic operations; PHP endpoints own authentication, inventory/booking mutations, and payment handling. It is intended for an Apache/PHP local stack such as XAMPP/WAMP, with schema/bootstrap data in mybus.sql.
2. Public Application Entry Points
The customer-facing flow begins at index.php, with bus discovery/detail interaction through bus.php and ajax/bus.php. Account and trip history are exposed through bookings.php; logout is handled by logout.php. Shared page chrome and likely session-aware navigation are centralized in inc/header.php, inc/footer.php, and inc/links.php.
3. Authentication Boundary
Customer login and registration are API-style PHP mutations in ajax/login.php and ajax/register.php. These endpoints form the identity boundary for booking operations; authenticated user state is then consumed by customer pages such as bookings.php and booking confirmation paths. Administrative authentication is separately entered through admin/index.php and terminated by admin/logout.php.
4. Search, Availability, and Seat Selection
Bus search/filtering and real-time availability are driven by the public bus endpoint ajax/bus.php, rendered in the customer bus UI at bus.php. The system’s key inventory boundary is the booking action: a selected seat must transition from available to reserved without conflicting with concurrent requests. The schema in mybus.sql is the authoritative persistence model for buses, routes/schedules, users, and bookings.
5. Booking and Payment Lifecycle
Booking confirmation is coordinated by confirm_booking.php and client logic in scripts/confirm_booking.js. State-changing operations are split into endpoints: ajax/confirm_booking.php confirms a reservation, ajax/cancel_booking.php cancels it, and ajax/submitpayment.php records/submits payment processing. User-visible terminal states are represented by payment-success.php and payment-failed.php. Razorpay is the stated external payment gateway; payment callbacks/result handling should be treated as a trust boundary rather than relying on browser-provided success state.
6. Administration Plane
The admin site is a distinct PHP surface rooted at admin/index.php, with operational screens in admin/dashboard.php, admin/bus.php, and admin/bookings.php. Admin AJAX endpoints—admin/ajax/dashboard.php, admin/ajax/bus.php, and admin/ajax/bookings.php—support management/reporting without full page reloads. Shared admin database and authorization foundations are concentrated in admin/inc/db_config.php and admin/inc/essentials.php.
7. Reporting and External Integrations
Booking output can be generated as a PDF through generate_pdf.php, with bookings_report.pdf indicating a report artifact/output. Dependency management is present via composer.json and composer.lock, likely supporting PHP integrations such as PHPMailer. Email confirmations are expected to use PHPMailer/SMTP, creating a separate outbound delivery boundary after successful booking/payment persistence.
Main entry points: submitpayment.php Payment submission API · mybus.sql MySQL booking store · index.php Customer pages · bus.php Bus discovery UI
Components 20
Customer app
- Customer browser · Server-rendered pages enhanced with AJAX.
- Customer pages · Discovery, account history, and shared page chrome.
index.php - Bus discovery UI · Shows search results, details, and seat selection.
bus.php - Customer auth API · Login and registration establish customer identity.
ajax/login.php - Availability API · Supplies bus search, filters, and availability.
ajax/bus.php - Booking history
bookings.php
Booking & payment
- Booking confirmation · Coordinates selected-seat confirmation and payment initiation.
confirm_booking.php - Reservation API · Confirms and cancels reservations against inventory.
ajax/confirm_booking.php - Payment submission API · Records payment submission and processes gateway results.
ajax/submitpayment.php - Payment result pages · Customer-visible success or failure states.
payment-success.php
Administration
- Admin login · Separate administrative authentication entry point.
admin/index.php - Admin console · Dashboard, bus operations, and booking operations.
admin/dashboard.php - Admin AJAX APIs · Management and reporting operations without page reloads.
admin/ajax/dashboard.php - Admin DB & authorization · Shared administrative database and authorization setup.
admin/inc/db_config.php
Persistence & integrations
- MySQL booking store · Authoritative buses, routes, schedules, users, bookings, and payment state.
mybus.sql - Razorpay · External payment trust boundary.
- SMTP email delivery · Sends confirmations after durable booking and payment state.
- PDF booking export · Generates booking-report output.
generate_pdf.php - Booking PDF report
bookings_report.pdf - PHP dependencies · Provides integration libraries such as PHPMailer.
composer.json
Connections 22
- Customer browser → Customer pages: renders
- Customer pages → Customer auth API: login/register
- Customer pages → Bus discovery UI: browse buses
- Customer pages → Booking history: view trips
- Bus discovery UI → Availability API: AJAX search & seats
- Availability API → MySQL booking store: reads availability
- Bus discovery UI → Booking confirmation: selected trip & seat
- Booking confirmation → Reservation API: confirm/cancel
- Reservation API → MySQL booking store: atomic reservation state
- Booking confirmation → Payment submission API: submit payment
- Payment submission API → Razorpay: payment request/result
- Payment submission API → MySQL booking store: persists payment state
- Payment submission API → Payment result pages: trusted outcome
- Payment submission API → SMTP email delivery: confirmation delivery
- Admin login → Admin console: authenticated access
- Admin console → Admin AJAX APIs: AJAX operations
- Admin AJAX APIs → Admin DB & authorization: authorization & DB setup
- Admin DB & authorization → MySQL booking store: administrative access
- Booking history → PDF booking export: generate report
- PDF booking export → MySQL booking store: reads bookings
- PDF booking export → Booking PDF report: writes
- PHP dependencies → SMTP email delivery: mailer library