How rg727876-hub/clinica-padre-pio works
1. Architecture style
- This is a small, server-rendered Flask monolith for a dental clinic.
- The main application logic lives in a single Python entrypoint, app.py, with persistence handled by local SQLite via clinica.db.
- There is no separate frontend app, API service, or background worker layer.
2. Core runtime boundary
- The system is a classic request/response web app:
- Browser request → Flask route in app.py → database read/write → Jinja2 template render → HTML response.
- The UI is built from server-rendered templates, with Bootstrap 5 styling and a small amount of client-side JavaScript in static/js/app.js.
3. Data layer
- database.py is the persistence bootstrap and audit helper layer.
- The database is local and file-based (clinica.db), which makes the deployment self-contained but also means the app is stateful on disk rather than using an external DB server.
- The README indicates an audit log/bitácora is part of the system, so database writes are not just transactional domain updates but also traceable actions.
4. Main application coordinator
- app.py is the central orchestrator for routes, role checks, form handling, and business rules.
- It likely owns the full workflow for authentication, authorization, CRUD operations, and state transitions for appointments, patients, users, services, and payments.
- Because the repository is small and template-driven, app.py is effectively both controller and service layer.
5. Role-based subsystems
- The app is partitioned by user role, and each role has its own view set:
- Administrador: users, services, schedules, reports, audit.
- Recepcionista: patients, appointment creation, reprogramming, schedule management.
- Doctor: own agenda, own schedule, patient history, clinical observations.
- Cajero: payment lookup, payment registration, receipt/comprobante generation.
- This role segmentation is a primary architectural boundary and should be shown prominently in a diagram.
6. Patient and appointment flow
- Receptionists create and edit patients, then schedule appointments by selecting a doctor, service, date, and time.
- Appointments move through a defined lifecycle: confirmada → atendida → pagada, with alternate terminal states like cancelada and no_asistio.
- Reprogramming and cancellation are separate operational paths, implying appointment state is a key domain object.
7. Clinical workflow boundary
- Doctors do not manage the full patient registry; they see only their assigned agenda and their own patients’ histories.
- Clinical data appears to be appended at attendance time via observations/notes, separating administrative scheduling from clinical follow-up.
- This creates an important access boundary: clinicians can read and update only the records relevant to their assignments.
8. Billing / cashier flow
- The cashier module is downstream of attended appointments.
- The typical path is: search by appointment code or DNI → verify attended status → register payment method → generate receipt/invoice view.
- The system tracks payment methods such as efectivo, tarjeta, Yape, Plin, and transferencia, so payment capture is part of the domain model rather than a simple confirmation flag.
9. Administration and governance
- The admin area covers the clinic’s operational configuration:
- user accounts and roles
- active/inactive status control
- dental services catalog
- doctor schedules
- exportable reports
- audit trail review
- This is the system’s configuration and governance boundary, distinct from day-to-day patient care and billing.
10. Presentation layer structure
- Templates are grouped by role under templates/admin, templates/recepcionista, templates/doctor, and templates/cajero.
- Shared layout is centralized in templates/base.html, with a standalone login.html and a high-level dashboard.html.
- This structure reinforces the role-based navigation model and makes the page hierarchy easy to map in an architecture diagram.
11. Static assets
- static/css/style.css provides custom styling on top of Bootstrap.
- static/js/app.js likely supports small interactions such as form behavior, UI helpers, or client-side enhancements; it does not appear to be a SPA or complex frontend runtime.
12. Deployment and operational shape
- The app is meant to run locally with python app.py, using a bundled SQLite file and default admin credentials for first access.
- iniciar.bat suggests a Windows-oriented startup convenience script.
- Overall, the repo is a compact, single-process clinic management system with clear role-separated screens and a shared data store.
Main entry points: app.py App · base.html Base layout · database.py DB layer · style.css Styles
Components 16
Runtime
Flask request handling, business rules, and persistence.
- Browser · User-facing HTTP client entering the app.
- App · Central Flask entrypoint for routes, role checks, workflows, and business rules.
app.py
Presentation
Server-rendered templates and static assets.
- Base layout · Shared page shell and navigation.
templates/base.html - Login page · Standalone authentication page.
templates/login.html - Dashboard · Role-aware landing page after login.
templates/dashboard.html - Admin area · User management, services, schedules, reports, and audit views.
templates/admin/usuarios.html - Reception area · Patient management, appointment creation, and reprogramming screens.
templates/recepcionista/citas.html - Doctor area · Agenda, patient history, and clinical follow-up screens.
templates/doctor/citas.html - Cashier area · Payment lookup, registration, and receipt generation screens.
templates/cajero/pago.html - Styles · Custom styling layered on Bootstrap.
static/css/style.css - UI script · Small client-side enhancements and form behavior.
static/js/app.js
Data
Local SQLite storage and persistence bootstrap.
- DB layer · SQLite bootstrap, writes, and audit/bitácora support.
database.py - Clinica DB · Local stateful database file used by the application.
clinica.db
Ops
Repository-level startup and dependency wiring.
- README · Project overview, usage, and clinic workflow notes.
README.md - Deps · Python package requirements for the Flask app.
requirements.txt - Startup script · Convenience launcher for local execution.
iniciar.bat
Connections 17
- Browser → App: HTTP request · Browser interactions enter the Flask app.
- App → Login page: auth view · Renders the login page.
- App → Dashboard: home view · Renders the role-aware dashboard.
- App → Admin area: admin screens · Serves administrative workflows.
- App → Reception area: reception screens · Serves patient and appointment workflows.
- App → Doctor area: doctor screens · Serves clinical agenda and history views.
- App → Cashier area: cashier screens · Serves payment and receipt flows.
- App → DB layer: persistence · Delegates reads, writes, and audit logging.
- DB layer → Clinica DB: SQLite I/O · Stores clinic state on disk.
- App → Base layout: layout · Uses shared base template for rendering.
- App → Styles: assets · Includes custom styles in rendered pages.
- App → UI script: assets · Includes small client-side helpers.
- Base layout → Styles: styles · Base layout loads CSS theme.
- Base layout → UI script: scripts · Base layout loads client script.
- App → README: docs · Repository documentation describes workflows and usage.
- App → Deps: deps · Runtime dependencies for the Flask monolith.
- App → Startup script: startup · Windows launcher for local runs.