# cgbm-unimagdalena/biobanco-cgbm architecture

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

- Interactive diagram: https://gitdiagram.com/cgbm-unimagdalena/biobanco-cgbm
- Repository: https://github.com/cgbm-unimagdalena/biobanco-cgbm

## Overview

#### Purpose and Entry Points
This is a full-stack laboratory sample-management system, covering sample intake, storage, requests, audit records, users/roles, and a public-facing view. The frontend is a Vite React SPA entered through `frontend/src/main.jsx` and `frontend/src/App.jsx`. The Python backend exposes a versioned API from `backend/app/main.py`.

#### Frontend Application Shell and Navigation
The React client organizes authenticated operational screens within a shared layout and sidebar. Pages cover dashboard, samples, storage, requests, auditing, and users; login and public view are separate access modes.
- `frontend/src/components/layout/AppLayout.jsx`
- `frontend/src/components/layout/Sidebar.jsx`
- `frontend/src/pages/LoginPage.jsx`
- `frontend/src/pages/VistaPublicaPage.jsx`

#### Client State and API Boundary
Authentication state is centralized in a frontend store, while API calls pass through a client/service layer rather than being embedded directly in pages. This is the primary browser-to-backend boundary and likely owns token attachment, endpoint invocation, and response handling.
- `frontend/src/store/authStore.js`
- `frontend/src/api/client.js`
- `frontend/src/api/services.js`

#### Sample Management Workflow
Sample management is a principal domain workflow: list/detail/form UI drives sample API operations, with backend endpoints delegating domain behavior to a service and persisting sample/evidence-related entities. It connects intake or lifecycle updates to storage and audit concerns.
- `frontend/src/pages/MuestrasPage.jsx`
- `frontend/src/components/muestras/MuestraForm.jsx`
- `backend/app/api/v1/endpoints/muestras.py`
- `backend/app/services/muestra_service.py`
- `backend/app/models/muestra.py`

#### Backend API and Access Control
The backend uses a layered FastAPI-style structure: versioned endpoint modules provide HTTP contracts; dependency and security modules enforce authentication/authorization; auth services and user/role models support identity management. Roles and user administration are exposed as operational API capabilities.
- `backend/app/api/v1/endpoints/auth.py`
- `backend/app/api/v1/endpoints/roles.py`
- `backend/app/core/deps.py`
- `backend/app/core/security.py`
- `backend/app/services/auth_service.py`
- `backend/app/models/usuario.py`

#### Operational Domains: Storage, Requests, and Auditing
Independent API areas represent the system’s supporting operational flows. Storage tracks where samples reside, requests represent demand or processing workflow, and auditing records accountability/events. Corresponding frontend pages expose these functions to operators.
- `backend/app/api/v1/endpoints/almacenamiento.py`
- `backend/app/api/v1/endpoints/solicitudes.py`
- `backend/app/api/v1/endpoints/auditoria.py`
- `backend/app/models/almacenamiento.py`
- `backend/app/models/solicitud.py`
- `backend/app/models/auditoria.py`

#### Persistence and Runtime Infrastructure
The backend persists domain data through model definitions and a database base layer, with Alembic migration infrastructure and an initial SQL schema. Runtime configuration is environment-driven through backend configuration and `.env`; the frontend likewise has environment configuration. Python dependencies are declared in `backend/requirements.txt`, while the browser app runs through Vite/npm.
- `backend/app/db/base.py`
- `backend/alembic/versions/001_initial_schema.sql`
- `backend/app/core/config.py`
- `backend/.env`
- `frontend/.env.example`
- `frontend/vite.config.js`

Main entry points: [`backend/app/main.py`](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/main.py) (Versioned API), [`backend/app/models/muestra.py`](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/models/muestra.py) (Domain models), [`frontend/src/components/layout/AppLayout.jsx`](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/components/layout/AppLayout.jsx) (Authenticated layout), [`frontend/src/pages/MuestrasPage.jsx`](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/pages/MuestrasPage.jsx) (Operational pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_spa["Vite React SPA<br/>application entry<br/>[main.jsx]"]
  node_app_layout["Authenticated layout<br/>UI shell<br/>[AppLayout.jsx]"]
  node_access_pages["Login &amp; public view<br/>access screens<br/>[LoginPage.jsx]"]
  node_operations_pages["Operational pages<br/>UI pages<br/>[MuestrasPage.jsx]"]
  node_sample_form["Sample form<br/>sample UI<br/>[MuestraForm.jsx]"]
  node_auth_store["Auth store<br/>client state<br/>[authStore.js]"]
  node_api_client{{"API client &amp; services<br/>browser API boundary<br/>[client.js]"}}
  node_frontend_runtime["Frontend runtime config<br/>Vite config<br/>[vite.config.js]"]
end

subgraph group_backend["FastAPI backend"]
  node_api["Versioned API<br/>FastAPI entry<br/>[main.py]"]
  node_access_control{{"Access control<br/>dependencies &amp; security<br/>[deps.py]"}}
  node_identity["Auth &amp; identity service<br/>domain service<br/>[auth_service.py]"]
end

subgraph group_domains["Operational domains"]
  node_samples_api["Samples API<br/>endpoint module<br/>[muestras.py]"]
  node_sample_service["Sample service<br/>domain service<br/>[muestra_service.py]"]
  node_operations_api["Storage, requests &amp; audit APIs<br/>endpoint modules<br/>[almacenamiento.py]"]
end

subgraph group_data["Persistence &amp; runtime"]
  node_domain_models["Domain models<br/>ORM models<br/>[muestra.py]"]
  node_database[("Database base<br/>persistence layer<br/>[base.py]")]
  node_migrations["Initial schema migration<br/>Alembic SQL"]
  node_backend_config["Backend configuration<br/>runtime config<br/>[config.py]"]
end

node_spa -->|"authenticated routes"| node_app_layout
node_spa -->|"access modes"| node_access_pages
node_app_layout -->|"hosts"| node_operations_pages
node_operations_pages -->|"sample intake"| node_sample_form
node_access_pages -->|"sign-in state"| node_auth_store
node_app_layout -->|"session state"| node_auth_store
node_operations_pages -->|"API operations"| node_api_client
node_sample_form -->|"sample writes"| node_api_client
node_api_client -->|"versioned HTTP"| node_api
node_api -->|"protects routes"| node_access_control
node_access_control -->|"identity checks"| node_identity
node_api -->|"routes"| node_samples_api
node_api -->|"routes"| node_operations_api
node_samples_api -->|"delegates"| node_sample_service
node_sample_service -->|"persists samples"| node_domain_models
node_operations_api -->|"persists operations"| node_domain_models
node_identity -->|"users and roles"| node_domain_models
node_domain_models -->|"mapped through"| node_database
node_migrations -->|"creates schema"| node_database
node_backend_config -.->|"runtime settings"| node_api
node_frontend_runtime -.->|"build runtime"| node_spa

click node_spa "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/main.jsx"
click node_app_layout "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/components/layout/AppLayout.jsx"
click node_access_pages "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/pages/LoginPage.jsx"
click node_operations_pages "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/pages/MuestrasPage.jsx"
click node_sample_form "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/components/muestras/MuestraForm.jsx"
click node_auth_store "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/store/authStore.js"
click node_api_client "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/api/client.js"
click node_api "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/main.py"
click node_access_control "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/core/deps.py"
click node_identity "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/services/auth_service.py"
click node_samples_api "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/api/v1/endpoints/muestras.py"
click node_sample_service "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/services/muestra_service.py"
click node_operations_api "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/api/v1/endpoints/almacenamiento.py"
click node_domain_models "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/models/muestra.py"
click node_database "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/db/base.py"
click node_migrations "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/alembic/versions/001_initial_schema.sql"
click node_backend_config "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/core/config.py"
click node_frontend_runtime "https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/vite.config.js"

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_spa,node_app_layout,node_access_pages,node_operations_pages,node_sample_form,node_auth_store,node_api_client,node_frontend_runtime toneBlue
class node_api,node_access_control,node_identity toneAmber
class node_samples_api,node_sample_service,node_operations_api toneMint
class node_domain_models,node_database,node_migrations,node_backend_config toneRose
```

## Components

### React frontend

- [Vite React SPA](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/main.jsx): application entry · Browser application entry and route shell. · `frontend/src/main.jsx`
- [Authenticated layout](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/components/layout/AppLayout.jsx): UI shell · Shared operator layout and sidebar navigation. · `frontend/src/components/layout/AppLayout.jsx`
- [Login & public view](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/pages/LoginPage.jsx): access screens · Separate authentication and public access modes. · `frontend/src/pages/LoginPage.jsx`
- [Operational pages](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/pages/MuestrasPage.jsx): UI pages · Dashboard, samples, storage, requests, audit, and users. · `frontend/src/pages/MuestrasPage.jsx`
- [Sample form](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/components/muestras/MuestraForm.jsx): sample UI · `frontend/src/components/muestras/MuestraForm.jsx`
- [Auth store](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/store/authStore.js): client state · Centralized authentication state. · `frontend/src/store/authStore.js`
- [API client & services](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/src/api/client.js): browser API boundary · Invokes backend endpoints and handles tokens and responses. · `frontend/src/api/client.js`
- [Frontend runtime config](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/frontend/vite.config.js): Vite config · Vite and frontend environment configuration. · `frontend/vite.config.js`

### FastAPI backend

- [Versioned API](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/main.py): FastAPI entry · HTTP API exposing versioned endpoint modules. · `backend/app/main.py`
- [Access control](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/core/deps.py): dependencies & security · Authenticates and authorizes API access. · `backend/app/core/deps.py`
- [Auth & identity service](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/services/auth_service.py): domain service · Supports user and role identity operations. · `backend/app/services/auth_service.py`

### Operational domains

- [Samples API](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/api/v1/endpoints/muestras.py): endpoint module · `backend/app/api/v1/endpoints/muestras.py`
- [Sample service](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/services/muestra_service.py): domain service · Coordinates sample lifecycle, storage, and audit concerns. · `backend/app/services/muestra_service.py`
- [Storage, requests & audit APIs](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/api/v1/endpoints/almacenamiento.py): endpoint modules · Operational HTTP contracts for supporting workflows. · `backend/app/api/v1/endpoints/almacenamiento.py`

### Persistence & runtime

- [Domain models](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/models/muestra.py): ORM models · Samples, storage, requests, audit records, and users. · `backend/app/models/muestra.py`
- [Database base](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/db/base.py): persistence layer · Database model registration and access foundation. · `backend/app/db/base.py`
- [Initial schema migration](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/alembic/versions/001_initial_schema.sql): Alembic SQL · `backend/alembic/versions/001_initial_schema.sql`
- [Backend configuration](https://github.com/cgbm-unimagdalena/biobanco-cgbm/blob/main/backend/app/core/config.py): runtime config · Environment-driven backend settings. · `backend/app/core/config.py`

## Connections

- Vite React SPA → Authenticated layout: authenticated routes
- Vite React SPA → Login & public view: access modes
- Authenticated layout → Operational pages: hosts
- Operational pages → Sample form: sample intake
- Login & public view → Auth store: sign-in state
- Authenticated layout → Auth store: session state
- Operational pages → API client & services: API operations
- Sample form → API client & services: sample writes
- API client & services → Versioned API: versioned HTTP
- Versioned API → Access control: protects routes
- Access control → Auth & identity service: identity checks
- Versioned API → Samples API: routes
- Versioned API → Storage, requests & audit APIs: routes
- Samples API → Sample service: delegates
- Sample service → Domain models: persists samples
- Storage, requests & audit APIs → Domain models: persists operations
- Auth & identity service → Domain models: users and roles
- Domain models → Database base: mapped through
- Initial schema migration → Database base: creates schema
- Backend configuration → Versioned API: runtime settings
- Frontend runtime config → Vite React SPA: build runtime
