How carlosdgiron/php-clinica works
Purpose and deployment
This is a Dockerized PHP clinic-management application. It serves a browser UI and an internal same-server API for clinical, operational, inventory, and access-management workflows. Apache rewrite/configuration establishes the public boundary and forwards requests to the PHP front controller: Dockerfile, apache2-custom.conf, public/index.php.
Application entry and routing
public/index.php boots the custom framework. The routing layer maps requests to resource controllers, while the base controller loads models and middleware. This is a conventional controller/model/view structure rather than a separate API service.
Paths: public/index.php, app/libraries/Core.php, app/config/RouteMap.php.
Authentication and authorization boundary
Login is a distinct flow; protected controller operations pass through token validation middleware. Authorization domain data is modeled around users, roles, permissions, employees, and positions.
Paths: app/Controllers/LoginController.php, app/middleware/AuthMiddleware.php, app/Models/MiddlewareModel.php.
Clinical-care domain
Patient management is central, with linked diagnosis and examination records. These controllers/models form the clinical-record flow: UI/API requests create or query patient data and associated diagnoses/exams through the database layer.
Paths: app/Controllers/PatientController.php, app/Controllers/PatientDiagnosisController.php, app/Controllers/PatientExamController.php.
Facilities and staffing domain
Room state is separated into rooms, availability, assignments, and history, supporting operational tracking of patient/staff placement and occupancy over time. Branch and employee resources define the organizational context.
Paths: app/Controllers/RoomController.php, app/Controllers/RoomAssignmentController.php, app/Controllers/RoomHistoryController.php.
Pharmacy and commercial domain
Medicine, supplier, batch, inventory, sales, and sale-detail resources provide the medication lifecycle: supplies/batches feed inventory, and sales with line details consume or report on stock. Medicine images are public static assets.
Paths: app/Controllers/MedicineController.php, app/Controllers/InventoryController.php, app/Controllers/SaleController.php.
Data, views, and browser client
Models access the configured database through a shared database abstraction. PHP views render the application shell/templates; JavaScript dynamically loads feature modules and calls the internal API. The home feature also has a local cached news payload, suggesting an external news integration configured server-side.
Paths: app/libraries/Database.php, app/config/Database.php, app/Views/Template/Header.php, public/js/services/apiService.js, app/storage/cache/news.json.
Primary request flow
Browser requests enter Apache and public/index.php, then Core resolves routes to controllers. Controllers apply auth where required, invoke entity models/database access, and return data or render views. Client modules use apiService for authenticated API calls and update the browser UI.
Paths: app/libraries/Core.php, app/libraries/Controllers.php, public/js/moduleLoader.js.
Main entry points: Controllers.php Base controller · Database.php Database abstraction · Core.php Core router · apache2-custom.conf Apache public boundary
Components 18
Web boundary
- Browser UI
- Apache public boundary · Rewrite rules forward application requests to the front controller.
apache2-custom.conf - PHP front controller
public/index.php
PHP application
- Core router
app/libraries/Core.php - Route map
app/config/RouteMap.php - Base controller · Loads models and middleware for resource controllers.
app/libraries/Controllers.php - Auth middleware
app/middleware/AuthMiddleware.php - Login flow
app/Controllers/LoginController.php
Business domains
- Access management · Users, roles, permissions, employees, and positions.
app/Models/MiddlewareModel.php - Clinical records · Patient records with diagnosis and examination flows.
app/Controllers/PatientController.php - Rooms and assignments · Room state, placement, and occupancy history.
app/Controllers/RoomController.php - Pharmacy and sales · Medicine, inventory, batches, suppliers, sales, and sale details.
app/Controllers/MedicineController.php
Data and presentation
- Database abstraction
app/libraries/Database.php - Database configuration
app/config/Database.php - PHP templates
app/Views/Template/Header.php - Feature module loader
public/js/moduleLoader.js - API service
public/js/services/apiService.js - Cached news payload · Cached home-feature news integration data.
app/storage/cache/news.json
Connections 21
- Browser UI → Apache public boundary: HTTP requests
- Apache public boundary → PHP front controller: rewrites
- PHP front controller → Core router: boots
- Core router → Route map: resolves routes from
- Core router → Base controller: dispatches to
- Base controller → Auth middleware: protects operations with
- Base controller → Login flow: serves
- Auth middleware → Access management: validates against
- Base controller → Clinical records: handles
- Base controller → Rooms and assignments: handles
- Base controller → Pharmacy and sales: handles
- Clinical records → Database abstraction: persists records
- Rooms and assignments → Database abstraction: persists state
- Pharmacy and sales → Database abstraction: manages stock and sales
- Access management → Database abstraction: reads authorization data
- Database abstraction → Database configuration: uses connection settings
- Base controller → PHP templates: renders
- Browser UI → Feature module loader: loads
- Feature module loader → API service: uses
- API service → Apache public boundary: internal API calls
- Base controller → Cached news payload: reads cached home news