How gody19/hospital works
Purpose and Runtime
MediCare is a framework-free PHP 8 MVC application for hospital operations: patient and doctor management, appointment scheduling, prescriptions, dashboard metrics, and reports. It runs behind Apache with mod_rewrite, serving the front controller at public/index.php; the project root rewrite supports XAMPP-style deployment via .htaccess.
Application Bootstrap and Routing
public/index.php is the HTTP entry point and loads application initialization from app/bootstrap.php. Bootstrap/configuration establish the application environment, database settings, and controller dispatch conventions. Controllers are the request boundary:
• app/Controllers/AuthController.php
• app/Controllers/AppointmentController.php
• app/Controllers/ReportController.php
Requests are routed to controller actions, which enforce authorization, validate input, invoke models, and render PHP views.
MVC Domain Modules
The principal business modules are organized around hospital entities:
• Patients: app/Controllers/PatientController.php, app/Models/Patient.php, app/Views/patients/index.php
• Doctors: app/Controllers/DoctorController.php, app/Models/Doctor.php, app/Views/doctors/form.php
• Appointments: app/Controllers/AppointmentController.php, app/Models/Appointment.php, app/Views/appointments/_table.php
• Prescriptions: app/Controllers/PrescriptionController.php, app/Models/Prescription.php, app/Views/prescriptions/show.php
The controller → model → view boundary keeps SQL/data access out of templates and places request orchestration in controllers.
Core Platform Services
Shared application behavior resides in app/Core:
• Database abstraction and base persistence model: app/Core/Database.php, app/Core/Model.php
• Controller base/rendering behavior: app/Core/Controller.php
• Session/login authorization: app/Core/Auth.php
• CSRF protection and request validation: app/Core/Csrf.php, app/Core/Validator.php
• Sensitive-field encryption and audit activity recording: app/Core/Crypto.php, app/Core/Audit.php
These services form the main security and persistence boundary used by domain controllers/models.
Data and Security Flow
Browser requests pass through Apache and the public front controller, then into authenticated controller actions. Mutating actions should flow through CSRF validation and input validation before model persistence. Models use the shared database layer to access MySQL/MariaDB. Sensitive records can be encrypted through Crypto; decryption depends on the environment-specific APP_KEY, so key retention is required to recover existing data. Audit logging captures material application activity.
Persistence and External Dependencies
The sole operational datastore is MySQL/MariaDB. Schema and bootstrap data are supplied by:
• database/schema.sql
• database/create_user.sql
• database/seed_demo.php
Database credentials and application key are environment-provided via .env based on .env.example, with PHP OpenSSL required for key generation/encryption. No external API, queue, or cloud service dependency is indicated.
Presentation and Reporting
Server-rendered PHP templates share the primary layout at app/Views/layouts/main.php. Dashboard and reporting are separate read-oriented flows:
• app/Controllers/DashboardController.php, app/Views/dashboard/index.php
• app/Controllers/ReportController.php, app/Views/reports/index.php
Static browser assets are delivered from public/assets/css/app.css and public/assets/js/app.js.
Main entry points: AppointmentController.php Domain controllers · Database.php Model and database layer · bootstrap.php Bootstrap · main.php PHP views and layout
Components 18
Web Runtime
- Apache + rewrite · Routes requests to the public front controller.
.htaccess - Front controller
public/index.php
MVC Application
- Bootstrap · Loads environment, database settings, and dispatch conventions.
app/bootstrap.php - Domain controllers · Authorize requests, validate input, invoke models, and render views.
app/Controllers/AppointmentController.php - Dashboard flow
app/Controllers/DashboardController.php - Reporting flow
app/Controllers/ReportController.php - Patients
app/Models/Patient.php - Doctors
app/Models/Doctor.php - Appointments
app/Models/Appointment.php - Prescriptions
app/Models/Prescription.php
Core Services
- Auth and session
app/Core/Auth.php - CSRF and validation · Protects mutating requests before persistence.
app/Core/Csrf.php - Model and database layer
app/Core/Database.php - Crypto and audit · Encrypts sensitive fields and records material activity.
app/Core/Crypto.php
Data & Environment
- Environment secrets · Supplies database credentials and APP_KEY.
.env.example - MySQL / MariaDB
database/schema.sql
Presentation
- PHP views and layout · Templates render through the shared primary layout.
app/Views/layouts/main.php - Static assets
public/assets/js/app.js
Connections 26
- Apache + rewrite → Front controller: rewrites requests
- Front controller → Bootstrap: loads
- Bootstrap → Domain controllers: dispatches
- Bootstrap → Dashboard flow: dispatches
- Bootstrap → Reporting flow: dispatches
- Domain controllers → Auth and session: authorizes
- Domain controllers → CSRF and validation: validates mutations
- Domain controllers → Patients: manages
- Domain controllers → Doctors: manages
- Domain controllers → Appointments: schedules
- Domain controllers → Prescriptions: manages
- Patients → Model and database layer: persists through
- Doctors → Model and database layer: persists through
- Appointments → Model and database layer: persists through
- Prescriptions → Model and database layer: persists through
- Dashboard flow → Model and database layer: reads metrics
- Reporting flow → Model and database layer: reads report data
- Model and database layer → MySQL / MariaDB: queries
- Environment secrets → Bootstrap: configures
- Environment secrets → Crypto and audit: provides APP_KEY
- Patients → Crypto and audit: protects activity
- Prescriptions → Crypto and audit: protects activity
- Domain controllers → PHP views and layout: renders
- Dashboard flow → PHP views and layout: renders
- Reporting flow → PHP views and layout: renders
- PHP views and layout → Static assets: loads