How rickypega/docuhuella works
1. Overall shape
DocuHuella is a PHP/MySQL MVC application for veterinary record management. The main request path is: browser → front controller/routing → role-specific controller → model → MySQL database → view render. The codebase is split by responsibility rather than by technical layer only, which makes it easy to map the app into domain areas.
2. Entry point and routing
index.php is the application entry point, and routes/web.php likely defines the request-to-controller mapping. The root .htaccess suggests clean URLs and Apache-based front-controller routing. This means the architecture depends on Apache/XAMPP or equivalent hosting, with PHP handling server-side rendering.
3. Shared infrastructure
config/db.php centralizes the database connection, using PDO as described in the README. config/auth_check.php is the main access-control boundary, enforcing login/role checks before protected actions run. This is the key security layer separating public pages from authenticated modules.
4. Role-based application boundaries
The repository is organized around four user domains:
• superadmin/ for system administration and catalog management
• admin/ for clinic/admin operations
• veterinario/ for clinical workflow
• cuidador/ for pet-owner/caregiver features
This is the strongest architectural boundary in the app; each role has its own controller set and views, and likely its own dashboard/home page.
5. Core domain model
The models/ folder holds the domain entities and persistence logic. The main business objects are:
• identity/access: Usuario, Rol, Administrador, Veterinario, Cuidador
• clinical workflow: Mascota, Cita, Consulta, Expediente, Nota, Vacuna, Vacunacion
• reference data: Clinica, Especie, Raza, Color, Especialidad
These models represent the data graph for the diagram: users own or manage pets; pets have appointments, consultations, notes, and vaccination records; vets and admins operate within clinic context.
6. Clinical workflow subsystem
The veterinarian area (controllers/veterinario/, views/veterinario/) is centered on day-to-day medical operations: citas, consultas, pacientes, paciente_ver, and vacunas. This is where most write-heavy clinical data flows happen, especially from appointments into consultation records and then into the pet’s expediente/history.
7. Caregiver subsystem
The caregiver module (controllers/cuidador/, views/cuidador/) handles pet ownership and self-service features like viewing a dashboard, managing mascota, and mis_mascotas. The shared view includes modal fragments such as modal_registrar_mascota, which suggests that caregivers can submit pet data through in-page forms rather than separate admin workflows.
8. Administration and reporting
The admin and superadmin areas separate operational administration from system-wide configuration. controllers/admin/ includes clinic management, vet registration, dashboard, and reports. controllers/superadmin/ adds administrator management, catalog maintenance, dashboards, and reporting. The reporting subsystem likely aggregates monthly clinical or operational statistics and may generate documents via FPDF.
9. Reusable UI composition
layouts/header.php and layouts/footer.php provide the shared shell for pages, while views/includes/ contains reusable fragments like profile and notes modals. This indicates a server-rendered UI with shared partials rather than a SPA. Page composition is view-driven, with controllers assembling the data and selecting the correct template.
10. Document generation and file assets
libs/fpdf.php and the bundled font files show that PDF generation is embedded in the app, most likely for reports and clinical outputs. Static assets live under public/, including CSS and uploads. The upload structure is domain-specific: public/uploads/pets and public/uploads/consultas separate pet images or documents from consultation attachments.
11. Database and initialization
DocuhuellaDB.sql is the schema/data seed source. The README also references an initialization step that creates default roles and a master account, so the system expects a populated database before first use. The application is therefore database-first: schema, seed data, then runtime behavior.
12. Deployment/runtime constraints
The stack is standard LAMP/XAMPP-style PHP with MySQL, and the README shows local and hosted deployment targets. The architecture assumes Apache URL rewriting and server-side sessions/auth, not client-side routing. For an architecture diagram, the main external dependencies to show are Apache/PHP runtime, MySQL database, and file storage under public/uploads.
13. Suggested diagram boundaries
A clean diagram would have four major zones:
• Presentation layer: views/, layouts/, public CSS/assets
• Application layer: controllers grouped by role plus auth checks
• Domain/data layer: models
• Infrastructure: MySQL, uploads filesystem, FPDF library
The most important data flows are login/authentication, pet registration, consultation/vaccination recording, and report generation.
Main entry points: web.php Web routes · header.php Shared layout · db.php DB config · Dashboardcontroller.php Admin area
Components 20
Entry & Routing
Front controller and route definitions for request dispatch.
- Front controller · Bootstraps the app and starts request handling.
index.php - Web routes · Maps incoming URLs to application controllers.
routes/web.php
Application Layer
Shared auth plus role-specific controllers and page orchestration.
- Auth check · Session and role gate for protected actions.
config/auth_check.php - Admin area · Clinic admin dashboard, vets, and reports.
controllers/admin/Dashboardcontroller.php - Superadmin area · System administration, catalogs, dashboards, and reports.
controllers/superadmin/DashboardController.php - Vet area · Clinical workflow for appointments, consultations, patients, and vaccines.
controllers/veterinario/VeterinarioController.php - Caregiver area · Owner self-service for pets and dashboard views.
controllers/cuidador/CuidadorController.php - Shared controllers · Cross-cutting controllers for profiles, users, notes, and registration.
controllers/UsuariosController.php
Domain & Data
Models and database schema for the clinical record system.
- DB config · Central PDO/MySQL connection setup.
config/db.php - Usuario · Base account and access identity.
models/Usuario.php - Roles · Administrator, veterinarian, and caregiver role entities.
models/Administrador.php - Clinic models · Clinic, specialty, species, breed, and color reference data.
models/Clinica.php - Patient records · Pets, appointments, consultations, expediente, notes, and vaccinations.
models/Mascota.php - DB schema · Schema and seed data for the application database.
DocuhuellaDB.sql
UI & Infrastructure
Shared templates, server-rendered views, uploads, and PDF support.
- Shared layout · Common header and footer for server-rendered pages.
layouts/header.php - Public views · Home, login, registration, privacy, and terms pages.
views/home.php - Role views · Admin, veterinarian, caregiver, and superadmin screens.
views/veterinario/dashboard.php - View partials · Reusable modal and notes fragments.
views/includes/modal_perfil.php - PDF library · Embedded FPDF engine and bundled fonts for report output.
libs/fpdf.php - Uploads · Filesystem storage for pet and consultation uploads.
public/uploads/consultas
Connections 29
- Front controller → Web routes: dispatches · Front controller hands off to route definitions.
- Web routes → Auth check: guards · Protected routes pass through role checks.
- Web routes → Admin area: admin requests · Admin URLs dispatch to the admin controller set.
- Web routes → Superadmin area: superadmin requests · System admin URLs dispatch to the superadmin controller set.
- Web routes → Vet area: vet requests · Clinical workflow URLs dispatch to veterinary controllers.
- Web routes → Caregiver area: caregiver requests · Owner self-service URLs dispatch to caregiver controllers.
- Web routes → Shared controllers: shared actions · Common pages and cross-cutting actions route to shared controllers.
- Admin area → DB config: queries · Admin features read and write through the database connection.
- Superadmin area → DB config: queries · Superadmin features read and write through the database connection.
- Vet area → DB config: queries · Veterinary workflow persists clinical records in MySQL.
- Caregiver area → DB config: queries · Caregiver actions read and update pet data.
- Shared controllers → DB config: queries · Shared controllers access users, profiles, and notes data.
- DB config → DB schema: defined by · Runtime schema is created from the SQL dump.
- Admin area → Shared layout: renders · Controllers assemble views through the shared page shell.
- Superadmin area → Shared layout: renders · Controllers assemble views through the shared page shell.
- Vet area → Shared layout: renders · Controllers assemble views through the shared page shell.
- Caregiver area → Shared layout: renders · Controllers assemble views through the shared page shell.
- Shared layout → Public views: wraps · Shared header/footer frame the public pages.
- Shared layout → Role views: wraps · Shared header/footer frame the role-specific pages.
- Role views → View partials: includes · Role views reuse modal and notes fragments.
- Shared controllers → Usuario: manages · User and profile actions center on account identity.
- Shared controllers → Roles: manages · Registration and profile flows bind to role entities.
- Admin area → Clinic models: administers · Admin screens manage clinic and catalog reference data.
- Superadmin area → Clinic models: administers · System configuration maintains catalogs and clinic data.
- Vet area → Patient records: operates on · Clinical screens create and update patient record data.
- Caregiver area → Patient records: views · Caregivers inspect and submit pet information.
- Patient records → Uploads: uploads · Pet photos and clinical attachments live in filesystem storage.
- Superadmin area → PDF library: reports · Report generation uses the bundled PDF engine.
- Admin area → PDF library: reports · Operational reports can be rendered as PDFs.