# kevin-garcia27/proyecto-intercambio_servicios_y_habilidades architecture

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

- Interactive diagram: https://gitdiagram.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades
- Repository: https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades

## Overview

#### Purpose and topology
Semackro is a Spanish-language service-exchange platform with a static/vanilla-JS frontend and a Node.js backend. Core domains include user profiles, skills/services, exchange requests and work orders, messaging/video calls, reputation, verification, reporting, and administration.

#### Entry points
- Backend HTTP server: `SemackroBackend/server.js`
- Backend package/runtime definition: `SemackroBackend/package.json`
- Frontend main shell and browser bootstrap: `SemackroFrontend/index.html`, `SemackroFrontend/app.js`
- Frontend deployment configuration: `SemackroFrontend/vercel.json`

#### Browser application
The frontend is primarily multipage HTML with shared JavaScript rather than a single SPA. Authentication, API invocation, permissions, session handling, and translations are centralized in `SemackroFrontend/js/apiHelper.js`, `SemackroFrontend/js/auth-guard.js`, and `SemackroFrontend/js/permisos.js`. Major user surfaces include discovery, profile, login, exchange requests, reports, and video calling: `SemackroFrontend/Descubrir.html`, `SemackroFrontend/Perfil_Usuario/perfil.html`, `SemackroFrontend/solicitud_intercambio.html`.

#### API and domain routing
`SemackroBackend/server.js` composes route modules under `SemackroBackend/routes/`, forming the backend boundary between browser clients and persistence/services. Identity and access routes are separated from core account/profile APIs: `SemackroBackend/routes/Login.js`, `SemackroBackend/routes/auth.js`, `SemackroBackend/routes/Personas.js`. Profile capability data is handled through `SemackroBackend/routes/PerfilCompleto.js` and `SemackroBackend/routes/HabilidadesYServicios_Persona.js`.

#### Exchange lifecycle and engagement
The central transactional flow likely starts with a service/interchange request, advances into exchanges or work orders, and produces history, ratings, and metrics. Its principal route boundaries are `SemackroBackend/routes/SolicitudesIntercambio.js`, `SemackroBackend/routes/intercambios.js`, and `SemackroBackend/routes/ordenesTrabajo.js`; subsequent quality/reputation paths reside in `SemackroBackend/routes/calificaciones.js` and `SemackroBackend/routes/MetricasDesempeno.js`.

#### Realtime communication and media
Messaging, notifications, call signaling, and video calls are distinct backend capabilities: `SemackroBackend/routes/Mensajeria.js`, `SemackroBackend/routes/call-signals.js`, `SemackroBackend/routes/videollamadas.js`. Shared socket lifecycle is represented by `SemackroBackend/socketInstance.js`. Uploads and messaging images cross a storage boundary through `SemackroBackend/routes/upload.js`, `SemackroBackend/routes/ImagenesMensajeria.js`, and `SemackroBackend/cloudflareR2.js`; Cloudflare R2 is the evident external object-storage integration.

#### Security, governance, and operations
Authentication configuration and email integration live in `SemackroBackend/config/passport.js` and `SemackroBackend/config/email.js`, with Google auth exposed by `SemackroBackend/routes/authGoogle.js`. Authorization and audit controls wrap protected operations via `SemackroBackend/middlewares/verificarPermiso.js` and `SemackroBackend/middlewares/auditLogger.js`. Administrative governance includes user reports, verification, roles/permissions, and audit logs: `SemackroBackend/routes/ReportesUsuarios.js`, `SemackroBackend/routes/verificacionUsuarios.js`, `SemackroBackend/routes/bitacora.js`.

#### Persistence and schema evolution
The backend database connection boundary is `SemackroBackend/db.js`. SQL setup files establish key schema areas—users/companies, roles and permissions, system configuration, pets, and audit records—under `SemackroBackend/BaseDatos/`, notably `setup_final.sql`, `setup_roles_permisos_motivos.sql`, and `setup_bitacora.sql`. Numerous root-level backend scripts implement direct schema repair, migration, seeding, and operational inspection, indicating database evolution is script-driven rather than managed by a single migration framework.

Main entry points: [`SemackroBackend/server.js`](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/server.js) (HTTP server and route composition), [`SemackroBackend/db.js`](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/db.js) (Database connection), [`SemackroBackend/routes/ordenesTrabajo.js`](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/ordenesTrabajo.js) (Exchanges and work orders), [`SemackroBackend/routes/Login.js`](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/Login.js) (Identity and accounts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_frontend_shell["Multipage browser shell<br/>static frontend<br/>[index.html]"]
  node_frontend_client["Session and API client<br/>browser shared JS<br/>[apiHelper.js]"]
  node_frontend_surfaces["Discovery, profile and requests<br/>browser pages"]
end

subgraph group_api["Node.js API"]
  node_server{{"HTTP server and route composition<br/>Node.js server<br/>[server.js]"}}
  node_identity["Identity and accounts<br/>API routes<br/>[Login.js]"]
  node_profiles["Profiles, skills and services<br/>API routes<br/>[PerfilCompleto.js]"]
  node_requests["Exchange requests<br/>API routes"]
  node_work_lifecycle["Exchanges and work orders<br/>API routes<br/>[ordenesTrabajo.js]"]
  node_reputation["Ratings and performance<br/>API routes<br/>[calificaciones.js]"]
end

subgraph group_realtime["Realtime and media"]
  node_messaging["Messaging and notifications<br/>API routes<br/>[Mensajeria.js]"]
  node_calls["Call signaling and video<br/>API routes<br/>[call-signals.js]"]
  node_sockets["Shared socket lifecycle<br/>socket runtime<br/>[socketInstance.js]"]
  node_uploads["Uploads and message images<br/>media API routes<br/>[upload.js]"]
  node_object_storage[("Cloudflare R2<br/>object storage<br/>[cloudflareR2.js]")]
end

subgraph group_governance["Security and governance"]
  node_access_control["Authorization and audit middleware"]
  node_governance_routes["Reports, verification and audit<br/>governance API routes"]
  node_external_auth_email["Google auth and email<br/>external integrations<br/>[passport.js]"]
end

subgraph group_data["Data and operations"]
  node_database[("Database connection<br/>database boundary<br/>[db.js]")]
  node_schema["SQL schema and repair scripts<br/>script-driven schema evolution<br/>[setup_final.sql]"]
end

node_frontend_shell -->|"loads shared client"| node_frontend_client
node_frontend_surfaces -->|"uses"| node_frontend_client
node_frontend_client -->|"HTTP API calls"| node_server
node_server -->|"routes"| node_identity
node_server -->|"routes"| node_profiles
node_server -->|"routes"| node_requests
node_server -->|"routes"| node_work_lifecycle
node_server -->|"routes"| node_reputation
node_server -->|"routes"| node_messaging
node_server -->|"routes"| node_calls
node_server -->|"routes"| node_uploads
node_server -->|"routes"| node_governance_routes
node_access_control -.->|"protects operations"| node_server
node_identity -->|"auth and email"| node_external_auth_email
node_requests -->|"accepted request"| node_work_lifecycle
node_work_lifecycle -->|"completed work outcome"| node_reputation
node_messaging -->|"realtime delivery"| node_sockets
node_calls -->|"signaling"| node_sockets
node_uploads -->|"stores media"| node_object_storage
node_identity -->|"persists"| node_database
node_profiles -->|"persists"| node_database
node_work_lifecycle -->|"persists"| node_database
node_reputation -->|"persists"| node_database
node_governance_routes -->|"persists"| node_database
node_schema -->|"creates and repairs schema"| node_database

click node_frontend_shell "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/index.html"
click node_frontend_client "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/js/apiHelper.js"
click node_frontend_surfaces "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/solicitud_intercambio.html"
click node_server "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/server.js"
click node_identity "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/Login.js"
click node_profiles "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/PerfilCompleto.js"
click node_requests "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/SolicitudesIntercambio.js"
click node_work_lifecycle "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/ordenesTrabajo.js"
click node_reputation "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/calificaciones.js"
click node_messaging "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/Mensajeria.js"
click node_calls "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/call-signals.js"
click node_sockets "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/socketInstance.js"
click node_uploads "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/upload.js"
click node_object_storage "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/cloudflareR2.js"
click node_access_control "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/middlewares/verificarPermiso.js"
click node_governance_routes "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/ReportesUsuarios.js"
click node_database "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/db.js"
click node_schema "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/BaseDatos/setup_final.sql"
click node_external_auth_email "https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/config/passport.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_frontend_shell,node_frontend_client,node_frontend_surfaces toneBlue
class node_server,node_identity,node_profiles,node_requests,node_work_lifecycle,node_reputation toneAmber
class node_messaging,node_calls,node_sockets,node_uploads,node_object_storage toneMint
class node_access_control,node_governance_routes,node_external_auth_email toneRose
class node_database,node_schema toneIndigo
```

## Components

### Browser application

- [Multipage browser shell](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/index.html): static frontend · Shared bootstrap for HTML user surfaces. · `SemackroFrontend/index.html`
- [Session and API client](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/js/apiHelper.js): browser shared JS · Centralizes API calls, auth, permissions, and translations. · `SemackroFrontend/js/apiHelper.js`
- [Discovery, profile and requests](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroFrontend/solicitud_intercambio.html): browser pages · `SemackroFrontend/solicitud_intercambio.html`

### Node.js API

- [HTTP server and route composition](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/server.js): Node.js server · Backend boundary composing route modules. · `SemackroBackend/server.js`
- [Identity and accounts](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/Login.js): API routes · Login, authentication, and person account APIs. · `SemackroBackend/routes/Login.js`
- [Profiles, skills and services](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/PerfilCompleto.js): API routes · `SemackroBackend/routes/PerfilCompleto.js`
- [Exchange requests](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/SolicitudesIntercambio.js): API routes · Starts the service exchange lifecycle. · `SemackroBackend/routes/SolicitudesIntercambio.js`
- [Exchanges and work orders](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/ordenesTrabajo.js): API routes · Advances accepted requests into tracked work. · `SemackroBackend/routes/ordenesTrabajo.js`
- [Ratings and performance](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/calificaciones.js): API routes · Records quality outcomes and metrics. · `SemackroBackend/routes/calificaciones.js`

### Realtime and media

- [Messaging and notifications](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/Mensajeria.js): API routes · `SemackroBackend/routes/Mensajeria.js`
- [Call signaling and video](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/call-signals.js): API routes · `SemackroBackend/routes/call-signals.js`
- [Shared socket lifecycle](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/socketInstance.js): socket runtime · `SemackroBackend/socketInstance.js`
- [Uploads and message images](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/upload.js): media API routes · `SemackroBackend/routes/upload.js`
- [Cloudflare R2](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/cloudflareR2.js): object storage · External storage for uploaded media. · `SemackroBackend/cloudflareR2.js`

### Security and governance

- [Authorization and audit middleware](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/middlewares/verificarPermiso.js): middleware · Guards protected operations and records audit activity. · `SemackroBackend/middlewares/verificarPermiso.js`
- [Reports, verification and audit](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/routes/ReportesUsuarios.js): governance API routes · `SemackroBackend/routes/ReportesUsuarios.js`
- [Google auth and email](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/config/passport.js): external integrations · `SemackroBackend/config/passport.js`

### Data and operations

- [Database connection](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/db.js): database boundary · `SemackroBackend/db.js`
- [SQL schema and repair scripts](https://github.com/kevin-garcia27/proyecto-intercambio_servicios_y_habilidades/blob/main/SemackroBackend/BaseDatos/setup_final.sql): script-driven schema evolution · Schema setup, repair, seeding, and operational scripts. · `SemackroBackend/BaseDatos/setup_final.sql`

## Connections

- Multipage browser shell → Session and API client: loads shared client
- Discovery, profile and requests → Session and API client: uses
- Session and API client → HTTP server and route composition: HTTP API calls
- HTTP server and route composition → Identity and accounts: routes
- HTTP server and route composition → Profiles, skills and services: routes
- HTTP server and route composition → Exchange requests: routes
- HTTP server and route composition → Exchanges and work orders: routes
- HTTP server and route composition → Ratings and performance: routes
- HTTP server and route composition → Messaging and notifications: routes
- HTTP server and route composition → Call signaling and video: routes
- HTTP server and route composition → Uploads and message images: routes
- HTTP server and route composition → Reports, verification and audit: routes
- Authorization and audit middleware → HTTP server and route composition: protects operations
- Identity and accounts → Google auth and email: auth and email
- Exchange requests → Exchanges and work orders: accepted request
- Exchanges and work orders → Ratings and performance: completed work outcome
- Messaging and notifications → Shared socket lifecycle: realtime delivery
- Call signaling and video → Shared socket lifecycle: signaling
- Uploads and message images → Cloudflare R2: stores media
- Identity and accounts → Database connection: persists
- Profiles, skills and services → Database connection: persists
- Exchanges and work orders → Database connection: persists
- Ratings and performance → Database connection: persists
- Reports, verification and audit → Database connection: persists
- SQL schema and repair scripts → Database connection: creates and repairs schema
