How keerthuammu/hospital-appointment-booking-system works
What this project is (type + purpose)
CarePlus Hospital System is a small full-stack web application for medical appointment scheduling:
• Frontend: static pages (index.html, booking.html) with Bootstrap + jQuery/AJAX.
• Backend: PHP 8 “API endpoints” under backend/api/.
• Database: MySQL with schema in database/schema.sql.
• Data flow called out in README: Load doctors (AJAX) → Book (validate in jQuery, persist via PHP/MySQL) → Cancel / “My Bookings”.
What the file tree tells you about the architecture
Directories/files to architectural components:
Backend (application/API layer)
• backend/api/get_doctors.php (read/list doctors for UI)
• backend/api/book_appointment.php (create appointment)
• backend/includes/config.php (DB connection + constants; should be a shared dependency)
Data layer
• database/schema.sql (authoritative DB structure)
Web Browser (Client)
• Renders index.html, booking.html
• Runs js/script.js
Web Server + PHP Runtime (Backend)
• Serves static files (or note: could be Apache/Nginx serving both static + PHP)
• Hosts API endpoints:
• GET /backend/api/get_doctors.php
• POST /backend/api/book_appointment.php
MySQL Database
• Schema from database/schema.sql
• Static Assets Store (assets/, css/, js/) as a “Static Content” sub-container (even if served by same server)
Decompose the backend container into components:
• API: Doctor Catalog Endpoint
• backend/api/get_doctors.php
• Depends on backend/includes/config.php
• Reads from doctors table (or equivalent)
• API: Appointment Booking Endpoint
• backend/api/book_appointment.php
• Depends on backend/includes/config.php
• Writes to appointments/bookings tables (whatever schema defines)
• Config/DB Connector
• backend/includes/config.php
• Owns DB connection parameters and creates a DB handle
If cancellation exists (“My Bookings” suggests it might), but there’s no endpoint in the tree, represent it as:
• “Cancel booking” UI flow calling a (missing/not yet implemented) endpoint OR note it as future work. Don’t invent files that aren’t present.
Relationships & interactions to show (data flows)
Base this strictly on README workflow + the API files you have.
script.js sends AJAX request to
• backend/api/get_doctors.php
3. PHP endpoint queries MySQL (or reads doctors.json if that’s what implementation does)
Returns JSON → browser renders doctor list / available slots
• Browser → get_doctors.php (HTTP GET)
• get_doctors.php → MySQL (SQL SELECT)
• MySQL → get_doctors.php
• get_doctors.php → Browser (JSON)
Browser sends AJAX POST to
• backend/api/book_appointment.php
4. PHP validates server-side (should be shown as a responsibility even if simple), inserts into MySQL
Returns success/failure JSON → UI updates
• Browser → book_appointment.php (HTTP POST: patient info, doctor_id, time slot)
• book_appointment.php → MySQL (SQL INSERT)
• book_appointment.php → Browser (JSON response)
Flow 3: “My Bookings” / Cancel (if present in UI)
If no endpoint exists, show:
• Browser “My Bookings” UI → (TBD API) → MySQL
C4 L1 (Context): User ↔ CarePlus ↔ MySQL
2. C4 L2 (Container): Browser (HTML/JS/CSS) ↔ PHP API (two endpoints + config) ↔ MySQL (+ optional JSON files)
• “Load doctors”
• “Book appointment”
These three views together will be the most accurate representation of what the repository actually implements, while still being detailed and decomposed into many components.