# dilom21/clinica-oftalmologica-api architecture

> Architecture diagram of the GitHub repository dilom21/clinica-oftalmologica-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dilom21/clinica-oftalmologica-api
- Repository: https://github.com/dilom21/clinica-oftalmologica-api

## Overview

This is a FastAPI backend for an ophthalmology clinic. Users authenticate and are authorized before using patient, appointment, and clinical-record workflows; the broader module tree also covers inventory, payments, administrative reporting, and patient interaction. Sampled routes call domain services, which use repositories and SQLAlchemy models; shared dependencies provide database sessions and role/permission checks. The README is empty, so several product capabilities are identified from module names only; their internal flows are not asserted.

Main entry points: [`app/main.py`](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/main.py) (API application), [`app/modules/gestion_usuarios_seguridad/api/router.py`](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/api/router.py) (User and auth API), [`app/modules/gestion_usuarios_seguridad/services/auth_service.py`](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/services/auth_service.py) (Login service), [`app/modules/gestion_agenda_citas/api/router.py`](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/api/router.py) (Appointment API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform"]
  node_app["API application<br/>[main.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_dbsession["Database sessions<br/>[session.py]"]
  node_db[("Relational database")]
end

subgraph group_identity["Identity &amp; Access"]
  node_dependencies["Auth dependencies<br/>[dependencies.py]"]
  node_security["Token security<br/>[security.py]"]
  node_authapi["User and auth API<br/>[router.py]"]
  node_authservice["Login service<br/>[auth_service.py]"]
  node_userrepo["User and role data<br/>[repository.py]"]
end

subgraph group_care["Patient Care"]
  node_patientapi["Patient API<br/>[router.py]"]
  node_patientservice["Patient service<br/>[service.py]"]
  node_patientrepo["Patient records<br/>[repository.py]"]
  node_appointmentapi["Appointment API<br/>[router.py]"]
  node_appointmentservice["Appointment services<br/>[citas.py]"]
  node_availability["Schedule and availability<br/>[service.py]"]
  node_appointmentrepo["Appointment data<br/>[repository.py]"]
  node_clinicalapi["Clinical record API<br/>[router.py]"]
  node_clinicalservice["Clinical record service<br/>[service.py]"]
  node_clinicalrepo["Clinical record data<br/>[repository.py]"]
end

subgraph group_operations["Clinic Operations"]
  node_inventory["Inventory and suppliers"]
  node_payments["Payments"]
  node_reports["Reports and dashboard"]
end

subgraph group_engagement["Patient Engagement"]
  node_notifications["Notifications and chatbot"]
  node_email["Email delivery<br/>[email_service.py]"]
end

node_user(("Clinic user"))

node_user -.->|"uses API"| node_app
node_app -->|"registers routes"| node_authapi
node_app -->|"registers routes"| node_patientapi
node_app -->|"registers routes"| node_clinicalapi
node_app -->|"registers routes"| node_appointmentapi
node_authapi -->|"calls login"| node_authservice
node_authservice -->|"looks up user"| node_userrepo
node_authservice -->|"verifies and issues token"| node_security
node_authapi -->|"requires permissions"| node_dependencies
node_dependencies -->|"opens session"| node_dbsession
node_dbsession -->|"connects"| node_db
node_patientapi -->|"calls"| node_patientservice
node_patientservice -->|"uses repository"| node_patientrepo
node_appointmentapi -->|"calls"| node_appointmentservice
node_appointmentapi -->|"calls"| node_availability
node_appointmentservice -->|"uses repository"| node_appointmentrepo
node_availability -->|"reads schedules"| node_appointmentrepo
node_clinicalapi -->|"calls"| node_clinicalservice
node_clinicalservice -->|"uses repository"| node_clinicalrepo
node_clinicalservice -->|"checks and updates visit"| node_appointmentrepo
node_config -->|"configures database"| node_dbsession
node_email -->|"loads mail settings"| node_config

click node_app "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/main.py"
click node_config "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/config.py"
click node_dbsession "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/database/session.py"
click node_dependencies "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/dependencies.py"
click node_security "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/security.py"
click node_authapi "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/api/router.py"
click node_authservice "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/services/auth_service.py"
click node_userrepo "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/repositories/repository.py"
click node_patientapi "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/api/router.py"
click node_patientservice "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/services/service.py"
click node_patientrepo "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/repositories/repository.py"
click node_appointmentapi "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/api/router.py"
click node_appointmentservice "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/services/citas.py"
click node_availability "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/services/service.py"
click node_appointmentrepo "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/repositories/repository.py"
click node_clinicalapi "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/api/router.py"
click node_clinicalservice "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/services/service.py"
click node_clinicalrepo "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/repositories/repository.py"
click node_inventory "https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/gestion_inventario_proveedores"
click node_payments "https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/gestion_pagos"
click node_reports "https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/reportes_panel_administrativo"
click node_notifications "https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/notificaciones_interaccion_chatbot"
click node_email "https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/shared/services/email_service.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_config,node_dbsession,node_db,node_user toneBlue
class node_dependencies,node_security,node_authapi,node_authservice,node_userrepo toneAmber
class node_patientapi,node_patientservice,node_patientrepo,node_appointmentapi,node_appointmentservice,node_availability,node_appointmentrepo,node_clinicalapi,node_clinicalservice,node_clinicalrepo toneMint
class node_inventory,node_payments,node_reports toneRose
class node_notifications,node_email toneIndigo
```

## Components

### Platform

- [API application](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/main.py): `app/main.py`
- [Runtime configuration](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/config.py): `app/core/config.py`
- [Database sessions](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/database/session.py): `app/database/session.py`
- **Relational database**

### Identity & Access

- [Auth dependencies](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/dependencies.py): `app/core/dependencies.py`
- [Token security](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/core/security.py): `app/core/security.py`
- [User and auth API](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/api/router.py): `app/modules/gestion_usuarios_seguridad/api/router.py`
- [Login service](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/services/auth_service.py): `app/modules/gestion_usuarios_seguridad/services/auth_service.py`
- [User and role data](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_usuarios_seguridad/repositories/repository.py): `app/modules/gestion_usuarios_seguridad/repositories/repository.py`

### Patient Care

- [Patient API](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/api/router.py): `app/modules/gestion_pacientes/api/router.py`
- [Patient service](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/services/service.py): `app/modules/gestion_pacientes/services/service.py`
- [Patient records](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_pacientes/repositories/repository.py): `app/modules/gestion_pacientes/repositories/repository.py`
- [Appointment API](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/api/router.py): `app/modules/gestion_agenda_citas/api/router.py`
- [Appointment services](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/services/citas.py): `app/modules/gestion_agenda_citas/services/citas.py`
- [Schedule and availability](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/services/service.py): `app/modules/gestion_agenda_citas/services/service.py`
- [Appointment data](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_agenda_citas/repositories/repository.py): `app/modules/gestion_agenda_citas/repositories/repository.py`
- [Clinical record API](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/api/router.py): `app/modules/gestion_historial_clinico/api/router.py`
- [Clinical record service](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/services/service.py): `app/modules/gestion_historial_clinico/services/service.py`
- [Clinical record data](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/modules/gestion_historial_clinico/repositories/repository.py): `app/modules/gestion_historial_clinico/repositories/repository.py`

### Clinic Operations

- [Inventory and suppliers](https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/gestion_inventario_proveedores): `app/modules/gestion_inventario_proveedores`
- [Payments](https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/gestion_pagos): `app/modules/gestion_pagos`
- [Reports and dashboard](https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/reportes_panel_administrativo): `app/modules/reportes_panel_administrativo`

### Patient Engagement

- [Notifications and chatbot](https://github.com/dilom21/clinica-oftalmologica-api/tree/main/app/modules/notificaciones_interaccion_chatbot): `app/modules/notificaciones_interaccion_chatbot`
- [Email delivery](https://github.com/dilom21/clinica-oftalmologica-api/blob/main/app/shared/services/email_service.py): `app/shared/services/email_service.py`

### Other components

- **Clinic user**

## Connections

- Clinic user → API application: uses API
- API application → User and auth API: registers routes (evidence: `app/main.py`)
- API application → Patient API: registers routes (evidence: `app/main.py`)
- API application → Clinical record API: registers routes (evidence: `app/main.py`)
- API application → Appointment API: registers routes (evidence: `app/main.py`)
- User and auth API → Login service: calls login (evidence: `app/modules/gestion_usuarios_seguridad/api/router.py`)
- Login service → User and role data: looks up user (evidence: `app/modules/gestion_usuarios_seguridad/services/auth_service.py`)
- Login service → Token security: verifies and issues token (evidence: `app/modules/gestion_usuarios_seguridad/services/auth_service.py`)
- User and auth API → Auth dependencies: requires permissions (evidence: `app/modules/gestion_usuarios_seguridad/api/router.py`)
- Auth dependencies → Database sessions: opens session (evidence: `app/core/dependencies.py`)
- Database sessions → Relational database: connects (evidence: `app/database/session.py`)
- Patient API → Patient service: calls (evidence: `app/modules/gestion_pacientes/api/router.py`)
- Patient service → Patient records: uses repository (evidence: `app/modules/gestion_pacientes/services/service.py`)
- Appointment API → Appointment services: calls (evidence: `app/modules/gestion_agenda_citas/api/router.py`)
- Appointment API → Schedule and availability: calls (evidence: `app/modules/gestion_agenda_citas/api/router.py`)
- Appointment services → Appointment data: uses repository (evidence: `app/modules/gestion_agenda_citas/services/citas.py`)
- Schedule and availability → Appointment data: reads schedules (evidence: `app/modules/gestion_agenda_citas/services/service.py`)
- Clinical record API → Clinical record service: calls (evidence: `app/modules/gestion_historial_clinico/api/router.py`)
- Clinical record service → Clinical record data: uses repository (evidence: `app/modules/gestion_historial_clinico/services/service.py`)
- Clinical record service → Appointment data: checks and updates visit (evidence: `app/modules/gestion_historial_clinico/services/service.py`)
- Runtime configuration → Database sessions: configures database
- Email delivery → Runtime configuration: loads mail settings (evidence: `app/shared/services/email_service.py`)
