# gabineto69/clinica-del-norte-api architecture

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

- Interactive diagram: https://gitdiagram.com/gabineto69/clinica-del-norte-api
- Repository: https://github.com/gabineto69/clinica-del-norte-api

## Overview

Clinica Norte API is a clinic scheduling backend. Clients log in, then use role-scoped endpoints to manage doctors and appointments; receptionists and doctors can also consult agendas, and receptionists can generate appointment reports. Clients can submit idempotent reserve/cancel operations for synchronization. The sampled server implements these responsibilities together, so several nodes share its exact path. PostgreSQL is evident from the queries, but the schema file was not sampled; relationships to it reflect the server’s SQL usage, not inspected schema details.

Main entry points: [`src/server.js`](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js) (HTTP API), [`sql/001_schema.sql`](https://github.com/gabineto69/clinica-del-norte-api/blob/main/sql/001_schema.sql) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and API"]
  node_http_api["HTTP API<br/>[server.js]"]
  node_login["Login<br/>[server.js]"]
  node_authz["Token and roles<br/>[server.js]"]
  node_validation["Request validation<br/>[server.js]"]
end

subgraph group_clinic["Clinic operations"]
  node_doctors["Doctor records<br/>[server.js]"]
  node_appointments["Appointment records<br/>[server.js]"]
  node_booking["Appointment booking<br/>[server.js]"]
  node_agenda["Doctor agenda<br/>[server.js]"]
  node_reports["Appointment reports<br/>[server.js]"]
  node_sync["Offline operation sync<br/>[server.js]"]
end

subgraph group_persistence["Persistence"]
  node_postgres[("PostgreSQL<br/>[001_schema.sql]")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_http_api
node_http_api -->|"routes login"| node_login
node_http_api -->|"guards API routes"| node_authz
node_login -->|"reads users"| node_postgres
node_login -->|"issues token"| node_authz
node_authz -->|"checks token and role"| node_http_api
node_http_api -->|"validates inputs"| node_validation
node_http_api -->|"routes doctor requests"| node_doctors
node_doctors -->|"reads and writes doctors"| node_postgres
node_http_api -->|"routes appointment requests"| node_appointments
node_appointments -->|"reads and updates appointments"| node_postgres
node_http_api -->|"routes reservations"| node_booking
node_booking -->|"inserts appointments"| node_postgres
node_http_api -->|"routes agenda requests"| node_agenda
node_agenda -->|"reads appointments"| node_postgres
node_http_api -->|"routes report requests"| node_reports
node_reports -->|"aggregates appointments"| node_postgres
node_http_api -->|"routes sync requests"| node_sync
node_sync -->|"reserves appointments"| node_booking
node_sync -->|"locks and records operations"| node_postgres

click node_http_api "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_login "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_authz "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_validation "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_doctors "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_appointments "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_booking "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_agenda "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_reports "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_sync "https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js"
click node_postgres "https://github.com/gabineto69/clinica-del-norte-api/blob/main/sql/001_schema.sql"

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_http_api,node_login,node_authz,node_validation,node_client toneBlue
class node_doctors,node_appointments,node_booking,node_agenda,node_reports,node_sync toneAmber
class node_postgres toneMint
```

## Components

### Access and API

- [HTTP API](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Login](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Token and roles](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Request validation](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`

### Clinic operations

- [Doctor records](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Appointment records](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Appointment booking](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Doctor agenda](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Appointment reports](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`
- [Offline operation sync](https://github.com/gabineto69/clinica-del-norte-api/blob/main/src/server.js): `src/server.js`

### Persistence

- [PostgreSQL](https://github.com/gabineto69/clinica-del-norte-api/blob/main/sql/001_schema.sql): `sql/001_schema.sql`

### Other components

- **API client**

## Connections

- API client → HTTP API: sends requests (evidence: `src/server.js`)
- HTTP API → Login: routes login (evidence: `src/server.js`)
- HTTP API → Token and roles: guards API routes (evidence: `src/server.js`)
- Login → PostgreSQL: reads users (evidence: `src/server.js`)
- Login → Token and roles: issues token (evidence: `src/server.js`)
- Token and roles → HTTP API: checks token and role (evidence: `src/server.js`)
- HTTP API → Request validation: validates inputs (evidence: `src/server.js`)
- HTTP API → Doctor records: routes doctor requests (evidence: `src/server.js`)
- Doctor records → PostgreSQL: reads and writes doctors (evidence: `src/server.js`)
- HTTP API → Appointment records: routes appointment requests (evidence: `src/server.js`)
- Appointment records → PostgreSQL: reads and updates appointments (evidence: `src/server.js`)
- HTTP API → Appointment booking: routes reservations (evidence: `src/server.js`)
- Appointment booking → PostgreSQL: inserts appointments (evidence: `src/server.js`)
- HTTP API → Doctor agenda: routes agenda requests (evidence: `src/server.js`)
- Doctor agenda → PostgreSQL: reads appointments (evidence: `src/server.js`)
- HTTP API → Appointment reports: routes report requests (evidence: `src/server.js`)
- Appointment reports → PostgreSQL: aggregates appointments (evidence: `src/server.js`)
- HTTP API → Offline operation sync: routes sync requests (evidence: `src/server.js`)
- Offline operation sync → Appointment booking: reserves appointments (evidence: `src/server.js`)
- Offline operation sync → PostgreSQL: locks and records operations (evidence: `src/server.js`)
