How benzarti-ahmed-yassine/medierp works
1. System shape
- MediERP Professional is a desktop ERP for medical practice built in Python with PySide6/PyQt-style UI.
- The runtime is centered around main.py, which boots the app and connects the UI layer to the core/application services.
2. Primary layering
- The repository is organized into four main layers: src/core for application infrastructure, src/views for screens/widgets, src/services for business/AI/automation services, and src/models for domain entities.
- src/utils contains cross-cutting helpers, including Qt compatibility support.
3. Core platform layer
- src/core holds the non-UI backbone: application lifecycle (app.py), database access (database.py), event coordination (events.py), RBAC enforcement (rbac.py), security primitives (security.py), and theming (theme_manager.py, theme_definitions.py).
- This layer is the main boundary between the desktop UI and persistence/security concerns.
4. Role-based UI architecture
- src/views is split by role: admin, doctor, assistant, secretary, and patient.
- Each role has dedicated dashboards and task views, which reflects the product’s RBAC model and keeps the user flows separated by persona.
5. End-to-end clinical workflow
- The README describes a connected workflow: arrival → vitals capture by assistant → doctor consultation with AI support → billing by secretary.
- The views mirror this: assistant screens for patients, inventory, and vital signs; doctor screens for agenda, messages, prescriptions, and patient selection; secretary screens for agenda, billing, and finance.
6. Data model and persistence
- src/models provides shared domain objects such as Patient and User, with base.py as the common model foundation.
- Persistence is backed by SQLite using the database/ folder for schema and migrations, and db/ for local database/document artifacts.
7. Schema evolution and migration strategy
- The database/migrations directory contains multiple SQL migrations, including RBAC, security, messaging, notifications, system config, and feature updates.
- This indicates the database schema is versioned and evolved through scripted SQL rather than an ORM-heavy migration framework.
8. Service layer responsibilities
- src/services contains the operational logic that sits behind the UI: ml_service.py for predictive risk scoring, biometric_service.py and face_service.py for biometric auth, pdf_service.py for document generation, and email_service.py / reminder_service.py / report_service.py for communication and automation.
- These services are the main integration boundary for non-UI capabilities.
9. AI and biometrics as first-class subsystems
- The ML assets in assets/models/ include a trained heart-risk model and scaler, showing the predictive component is embedded locally rather than called from an external API.
- Biometric authentication is also local and integrated into the desktop app, reinforcing the app’s offline-capable, privacy-sensitive architecture.
10. Document and reporting outputs
- Generated artifacts appear under docs/exports/ and db/documents/, including PDF prescriptions/ordonnances.
- This suggests the application produces clinical documents locally and stores them alongside the database files rather than in a remote document service.
11. Configuration and presentation layer
- config/settings.json, .env.example, and QSS/theme files define runtime configuration and visual styling.
- The repo uses a “Full Light” desktop theme, so UI presentation is controlled centrally rather than per-view.
12. Administration and governance
- The admin area covers user management, audit, and system settings, which aligns with the RBAC-heavy design.
- src/core/rbac.py and the admin views form the governance boundary for permissions, account lifecycle, and operational oversight.
13. Testing and operational scripts
- tests/ includes coverage for basic behavior, biometrics, and ML, which reflects the project’s risk areas.
- src/scripts/, scratch/, and standalone helpers like launch_test.py are operational utilities for database initialization, password resets, migrations, and environment checks; they are support tooling, not core runtime subsystems.
14. How to diagram it
- A clean architecture diagram should place the desktop UI/views at the top, fed by core app/security/RBAC/database in the middle, with services branching to ML, biometrics, PDF, email, and reminders, and SQLite + local assets/documents at the bottom as persistence/artifact stores.
- The key business boundary is role-based access: each persona view talks to the same core and service layers but exposes different workflows and datasets.
Main entry points: main_window.py Main window · app.py App core · database.py Database · admin_dashboard_view.py Admin dashboard
Components 29
Entry
Application bootstrap and top-level shell
- Main app · Starts the desktop application and wires core and UI
main.py
Core Platform
Application lifecycle, security, events, and database boundaries
- App core · Application startup, shutdown, and runtime wiring
src/core/app.py - Database · SQLite access and data coordination
src/core/database.py - Events · App-wide event signaling and dispatch
src/core/events.py - RBAC · Role and permission enforcement
src/core/rbac.py - Security · Security primitives and protected operations
src/core/security.py - Theme · Central theme definitions and theme switching
src/core/theme_manager.py
Views
Role-based desktop screens and shared UI
- Main window · Primary desktop shell hosting role-specific screens
src/views/main_window.py - Login · Entry screen for desktop authentication
src/views/login_view.py - Admin dashboard · Governance and system oversight home screen
src/views/admin/admin_dashboard_view.py - Doctor dashboard · Clinical workflow entry for physicians
src/views/doctor/doctor_dashboard_view.py - Assistant dashboard · Front-desk and vitals workflow entry
src/views/assistant/assistant_dashboard_view.py - Secretary dashboard · Billing and agenda workflow entry
src/views/secretary/secretary_dashboard_view.py - Patient portal · Patient-facing portal and self-service views
src/views/patient/patient_portal_view.py - Consultation · Doctor consultation workspace with shared patient context
src/views/consultation_view.py - Biometric auth · Local biometric login and identity capture widget
src/views/biometric_widget.py
Services
Operational services behind the UI
- ML service · Risk scoring and local model inference
src/services/ml_service.py - Biometrics · Biometric and face-based authentication support
src/services/biometric_service.py - PDF output · Generates prescriptions and other clinical PDFs
src/services/pdf_service.py - Messaging · Email-based communication and delivery
src/services/email_service.py - Reminders · Scheduled reminders and notification automation
src/services/reminder_service.py - Reports · Aggregates operational and business reports
src/services/report_service.py
Data & Assets
Persistent store, schema, exports, and ML artifacts
- Patient · Core patient entity shared across workflows
src/models/patient.py - User · Application user and role-bearing identity
src/models/user.py - Schema · Base schema and migration scripts for the database
database/schema.sql - Migrations · Versioned schema evolution scripts
database/migrations - Exports · Generated PDFs and exported clinical documents
docs/exports - Local docs · Database-backed local document artifacts
db/documents - ML assets · Local trained model and scaler artifacts
assets/models
Connections 31
- Main app → App core: boots · Main entry initializes the application runtime
- Main app → Main window: opens · Application bootstraps the desktop shell
- App core → Database: uses · Core app wires persistence services
- App core → Events: publishes · Application lifecycle emits shared events
- App core → RBAC: enforces · Role checks gate application actions
- App core → Security: secures · Security primitives protect the runtime
- App core → Theme: configures · Core app sets and updates global theme
- Main window → Login: hosts · Shell starts with authentication flow
- Main window → Admin dashboard: routes · Admin persona is routed into governance screens
- Main window → Doctor dashboard: routes · Doctor persona is routed into clinical screens
- Main window → Assistant dashboard: routes · Assistant persona is routed into intake screens
- Main window → Secretary dashboard: routes · Secretary persona is routed into billing screens
- Main window → Patient portal: routes · Patient persona is routed into self-service screens
- Login → Biometric auth: authenticates · Login can use biometric identity capture
- Biometric auth → Biometrics: calls · Widget delegates biometric verification to services
- Doctor dashboard → Consultation: opens · Doctor dashboard leads into consultation workflow
- Consultation → ML service: scores · Consultation can request local risk prediction
- Consultation → PDF output: prints · Clinical workflow can generate prescriptions and PDFs
- Assistant dashboard → Biometrics: verifies · Assistant intake can authenticate by biometrics
- Secretary dashboard → Messaging: sends · Billing and agenda flows can notify by email
- Secretary dashboard → Reminders: schedules · Secretary workflow triggers reminders
- Admin dashboard → Reports: reviews · Admin oversight uses reports and operational summaries
- Admin dashboard → RBAC: governs · Admin screens manage roles and permissions
- Patient portal → Events: listens · Patient-facing screens react to shared app events
- Patient → Database: persists · Domain data is stored through the database layer
- User → RBAC: binds · Users carry role information used by RBAC
- Database → Schema: loads · Database layer is defined by schema files
- Database → Migrations: evolves · Database changes are applied through migrations
- PDF output → Exports: writes · Generated PDFs are exported to docs storage
- PDF output → Local docs: archives · Clinical documents are kept in local document storage
- ML service → ML assets: loads · Risk scoring uses local serialized model assets