How cgbm-unimagdalena/biobanco-cgbm works
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: main.py Versioned API · muestra.py Domain models · AppLayout.jsx Authenticated layout · MuestrasPage.jsx Operational pages
Components 18
React frontend
- Vite React SPA · Browser application entry and route shell.
frontend/src/main.jsx - Authenticated layout · Shared operator layout and sidebar navigation.
frontend/src/components/layout/AppLayout.jsx - Login & public view · Separate authentication and public access modes.
frontend/src/pages/LoginPage.jsx - Operational pages · Dashboard, samples, storage, requests, audit, and users.
frontend/src/pages/MuestrasPage.jsx - Sample form
frontend/src/components/muestras/MuestraForm.jsx - Auth store · Centralized authentication state.
frontend/src/store/authStore.js - API client & services · Invokes backend endpoints and handles tokens and responses.
frontend/src/api/client.js - Frontend runtime config · Vite and frontend environment configuration.
frontend/vite.config.js
FastAPI backend
- Versioned API · HTTP API exposing versioned endpoint modules.
backend/app/main.py - Access control · Authenticates and authorizes API access.
backend/app/core/deps.py - Auth & identity service · Supports user and role identity operations.
backend/app/services/auth_service.py
Operational domains
- Samples API
backend/app/api/v1/endpoints/muestras.py - Sample service · Coordinates sample lifecycle, storage, and audit concerns.
backend/app/services/muestra_service.py - Storage, requests & audit APIs · Operational HTTP contracts for supporting workflows.
backend/app/api/v1/endpoints/almacenamiento.py
Persistence & runtime
- Domain models · Samples, storage, requests, audit records, and users.
backend/app/models/muestra.py - Database base · Database model registration and access foundation.
backend/app/db/base.py - Initial schema migration
backend/alembic/versions/001_initial_schema.sql - Backend configuration · Environment-driven backend settings.
backend/app/core/config.py
Connections 21
- 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