# bmaravena/cesfam_pdc architecture

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

- Interactive diagram: https://gitdiagram.com/bmaravena/cesfam_pdc
- Repository: https://github.com/bmaravena/cesfam_pdc

## Overview

OIRS is a municipal health-network portal for public requests and satisfaction surveys, with staff workflows for response, reporting, user/role administration, establishment management, and audit review. The principal flow is public submission or staff action through the frontend into FastAPI endpoints, business services, repositories, and PostgreSQL; staff authenticate with JWT and role/scope checks. The tree documents the additional portal, consultation, metrics, CSV export, and audit capabilities. Several endpoint and UI implementations were not sampled, so their internal calls are not asserted; the shown edges follow excerpts or the router registration.

Main entry points: [`backend/db/repositories`](https://github.com/bmaravena/cesfam_pdc/tree/main/backend/db/repositories) (Repositories), [`frontend/src/router/index.tsx`](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/router/index.tsx) (Page routing), [`frontend/src/pages/private`](https://github.com/bmaravena/cesfam_pdc/tree/main/frontend/src/pages/private) (Staff workflows), [`frontend/src/services/api.ts`](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/services/api.ts) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web portal"]
  node_app["Web application<br/>[main.tsx]"]
  node_routing["Page routing<br/>[index.tsx]"]
  node_auth_ui["Auth provider<br/>[AuthProvider.tsx]"]
  node_token_client["JWT client<br/>[auth.ts]"]
  node_api_client["HTTP client<br/>[api.ts]"]
  node_public_pages["Public workflows"]
  node_staff_pages["Staff workflows"]
  node_response_ui["Request response<br/>[ResponderModal.tsx]"]
end

subgraph group_api["API entry"]
  node_api_router["API router<br/>[router.py]"]
  node_request_api["Request endpoints<br/>[requerimientos.py]"]
  node_auth_api["Auth endpoint<br/>[auth.py]"]
  node_other_api["Other endpoints"]
end

subgraph group_domain["Business services"]
  node_request_service["Request service"]
  node_survey_service["Survey service"]
  node_user_service["User service<br/>[usuario_service.py]"]
  node_other_services["Supporting services"]
end

subgraph group_identity["Identity and access"]
  node_jwt_security["JWT security<br/>[security.py]"]
  node_access_rules["Role and scope<br/>[authz.py]"]
end

subgraph group_persistence["Data layer"]
  node_repositories["Repositories"]
  node_domain_models["Domain records"]
  node_db_sessions["Database sessions<br/>[session.py]"]
  node_postgres[("PostgreSQL")]
end

node_public(("Public visitors"))
node_staff(("Health staff"))

node_app -->|"loads routes"| node_routing
node_routing -->|"routes to"| node_public_pages
node_routing -->|"routes to"| node_staff_pages
node_routing -->|"guards routes"| node_auth_ui
node_auth_ui -->|"reads token"| node_token_client
node_auth_ui -->|"requests profile"| node_api_client
node_api_client -->|"attaches JWT"| node_token_client
node_public -.->|"uses"| node_public_pages
node_staff -.->|"uses"| node_staff_pages
node_staff_pages -.->|"opens response"| node_response_ui
node_public_pages -.->|"calls API"| node_api_client
node_staff_pages -.->|"calls API"| node_api_client
node_api_router -->|"registers"| node_request_api
node_api_router -->|"registers"| node_auth_api
node_api_router -->|"registers"| node_other_api
node_request_api -->|"invokes"| node_request_service
node_auth_api -->|"authenticates"| node_user_service
node_auth_api -->|"issues token"| node_jwt_security
node_request_service -->|"queries and writes"| node_repositories
node_survey_service -->|"queries and writes"| node_repositories
node_request_api -->|"checks access"| node_access_rules
node_request_service -->|"checks scope"| node_access_rules
node_jwt_security -->|"loads user"| node_repositories
node_user_service -->|"manages users"| node_repositories
node_repositories -->|"reads and writes"| node_domain_models
node_repositories -->|"uses session"| node_db_sessions
node_db_sessions -->|"opens connections"| node_postgres

click node_app "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/main.tsx"
click node_routing "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/router/index.tsx"
click node_auth_ui "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/features/auth/AuthProvider.tsx"
click node_token_client "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/lib/auth.ts"
click node_api_client "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/services/api.ts"
click node_public_pages "https://github.com/bmaravena/cesfam_pdc/tree/main/frontend/src/pages/public"
click node_staff_pages "https://github.com/bmaravena/cesfam_pdc/tree/main/frontend/src/pages/private"
click node_response_ui "https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/features/requerimientos/ResponderModal.tsx"
click node_api_router "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/router.py"
click node_request_api "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/endpoints/requerimientos.py"
click node_auth_api "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/endpoints/auth.py"
click node_other_api "https://github.com/bmaravena/cesfam_pdc/tree/main/backend/api/v1/endpoints"
click node_request_service "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/requerimiento_oirs_service.py"
click node_survey_service "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/encuesta_satisfaccion_service.py"
click node_user_service "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/usuario_service.py"
click node_other_services "https://github.com/bmaravena/cesfam_pdc/tree/main/backend/services"
click node_jwt_security "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/core/security.py"
click node_access_rules "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/authz.py"
click node_repositories "https://github.com/bmaravena/cesfam_pdc/tree/main/backend/db/repositories"
click node_domain_models "https://github.com/bmaravena/cesfam_pdc/tree/main/backend/db/models"
click node_db_sessions "https://github.com/bmaravena/cesfam_pdc/blob/main/backend/db/session.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_routing,node_auth_ui,node_token_client,node_api_client,node_public_pages,node_staff_pages,node_response_ui toneBlue
class node_api_router,node_request_api,node_auth_api,node_other_api toneAmber
class node_request_service,node_survey_service,node_user_service,node_other_services toneMint
class node_jwt_security,node_access_rules toneRose
class node_repositories,node_domain_models,node_db_sessions,node_postgres,node_public,node_staff toneIndigo
```

## Components

### Web portal

- [Web application](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Page routing](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/router/index.tsx): `frontend/src/router/index.tsx`
- [Auth provider](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/features/auth/AuthProvider.tsx): `frontend/src/features/auth/AuthProvider.tsx`
- [JWT client](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/lib/auth.ts): `frontend/src/lib/auth.ts`
- [HTTP client](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Public workflows](https://github.com/bmaravena/cesfam_pdc/tree/main/frontend/src/pages/public): `frontend/src/pages/public`
- [Staff workflows](https://github.com/bmaravena/cesfam_pdc/tree/main/frontend/src/pages/private): `frontend/src/pages/private`
- [Request response](https://github.com/bmaravena/cesfam_pdc/blob/main/frontend/src/features/requerimientos/ResponderModal.tsx): `frontend/src/features/requerimientos/ResponderModal.tsx`

### API entry

- [API router](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/router.py): `backend/api/v1/router.py`
- [Request endpoints](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/endpoints/requerimientos.py): `backend/api/v1/endpoints/requerimientos.py`
- [Auth endpoint](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/api/v1/endpoints/auth.py): `backend/api/v1/endpoints/auth.py`
- [Other endpoints](https://github.com/bmaravena/cesfam_pdc/tree/main/backend/api/v1/endpoints): `backend/api/v1/endpoints`

### Business services

- [Request service](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/requerimiento_oirs_service.py): `backend/services/requerimiento_oirs_service.py`
- [Survey service](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/encuesta_satisfaccion_service.py): `backend/services/encuesta_satisfaccion_service.py`
- [User service](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/usuario_service.py): `backend/services/usuario_service.py`
- [Supporting services](https://github.com/bmaravena/cesfam_pdc/tree/main/backend/services): `backend/services`

### Identity and access

- [JWT security](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/core/security.py): `backend/core/security.py`
- [Role and scope](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/services/authz.py): `backend/services/authz.py`

### Data layer

- [Repositories](https://github.com/bmaravena/cesfam_pdc/tree/main/backend/db/repositories): `backend/db/repositories`
- [Domain records](https://github.com/bmaravena/cesfam_pdc/tree/main/backend/db/models): `backend/db/models`
- [Database sessions](https://github.com/bmaravena/cesfam_pdc/blob/main/backend/db/session.py): `backend/db/session.py`
- **PostgreSQL**

### Other components

- **Public visitors**
- **Health staff**

## Connections

- Web application → Page routing: loads routes (evidence: `frontend/src/main.tsx`)
- Page routing → Public workflows: routes to (evidence: `frontend/src/router/index.tsx`)
- Page routing → Staff workflows: routes to (evidence: `frontend/src/router/index.tsx`)
- Page routing → Auth provider: guards routes (evidence: `frontend/src/router/index.tsx`)
- Auth provider → JWT client: reads token (evidence: `frontend/src/features/auth/AuthProvider.tsx`)
- Auth provider → HTTP client: requests profile (evidence: `frontend/src/features/auth/AuthProvider.tsx`)
- HTTP client → JWT client: attaches JWT (evidence: `frontend/src/services/api.ts`)
- Public visitors → Public workflows: uses
- Health staff → Staff workflows: uses
- Staff workflows → Request response: opens response
- Public workflows → HTTP client: calls API
- Staff workflows → HTTP client: calls API
- API router → Request endpoints: registers (evidence: `backend/api/v1/router.py`)
- API router → Auth endpoint: registers (evidence: `backend/api/v1/router.py`)
- API router → Other endpoints: registers (evidence: `backend/api/v1/router.py`)
- Request endpoints → Request service: invokes (evidence: `backend/api/v1/endpoints/requerimientos.py`)
- Auth endpoint → User service: authenticates (evidence: `backend/api/v1/endpoints/auth.py`)
- Auth endpoint → JWT security: issues token (evidence: `backend/api/v1/endpoints/auth.py`)
- Request service → Repositories: queries and writes (evidence: `backend/services/requerimiento_oirs_service.py`)
- Survey service → Repositories: queries and writes (evidence: `backend/services/encuesta_satisfaccion_service.py`)
- Request endpoints → Role and scope: checks access (evidence: `backend/api/v1/endpoints/requerimientos.py`)
- Request service → Role and scope: checks scope (evidence: `backend/services/requerimiento_oirs_service.py`)
- JWT security → Repositories: loads user (evidence: `backend/core/security.py`)
- User service → Repositories: manages users (evidence: `backend/services/usuario_service.py`)
- Repositories → Domain records: reads and writes (evidence: `backend/db/repositories/requerimiento_oirs_repo.py`)
- Repositories → Database sessions: uses session (evidence: `backend/db/repositories/base.py`)
- Database sessions → PostgreSQL: opens connections (evidence: `backend/db/session.py`)
