# ana2320-ux/sistema_distribuido_srb architecture

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

- Interactive diagram: https://gitdiagram.com/ana2320-ux/sistema_distribuido_srb
- Repository: https://github.com/ana2320-ux/sistema_distribuido_srb

## Overview

SRB is a three-tier ticket-reservation system: clients query events, reserve or modify seats synchronously, and cancel asynchronously. The synchronous route passes through the Transaction Manager, RMC business logic, persistence client and persistence service to SQLite; cancellations are acknowledged first, then processed and reported by notification. The README also documents read scaling, retries and idempotent writes. Some cancellation internals and deployment behavior are described only in the README; the graph does not infer unsampled call details.

Main entry points: [`capa_cliente/cliente.py`](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/cliente.py) (Client API), [`capa_negocios/gestor_transacciones.py`](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/gestor_transacciones.py) (Transaction Manager), [`capa_negocios/cliente_persistencia.py`](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/cliente_persistencia.py) (Persistence client), [`capa_negocios/main.py`](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/main.py) (Cancellation service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client layer"]
  node_client["Client API<br/>[cliente.py]"]
  node_script["Operation scripts<br/>[script.py]"]
  node_load["Load scenarios<br/>[carga.py]"]
  node_locust["Locust driver<br/>[locustfile.py]"]
end

subgraph group_business["Business layer"]
  node_gt["Transaction Manager"]
  node_rmc["RMC service<br/>[rmc.py]"]
  node_cancel["Cancellation service<br/>[main.py]"]
  node_persist_client["Persistence client"]
  node_metrics["Transaction metrics<br/>[metricas.py]"]
end

subgraph group_storage["Persistence layer"]
  node_persist_service["Persistence service"]
  node_database[("SQLite database<br/>[db.py]")]
  node_read_replica["Read replica<br/>[main.py]"]
  node_catalog["Catalog loader<br/>[cargar_datos.py]"]
end

subgraph group_shared["Protocol and telemetry"]
  node_protocol["JSON message protocol<br/>[E_mensaje.py]"]
  node_configuration["Runtime configuration<br/>[configuracion.py]"]
end

node_customer(("Reservation client"))

node_customer -->|"submits operations"| node_client
node_client -->|"sends requests"| node_gt
node_client -->|"receives notification"| node_cancel
node_script -->|"executes operations"| node_client
node_locust -->|"generates load"| node_load
node_load -->|"sends requests"| node_client
node_gt -->|"dispatches requests"| node_rmc
node_rmc -->|"requests persistence"| node_persist_client
node_persist_client -->|"sends requests"| node_persist_service
node_persist_service -->|"reads and writes"| node_database
node_gt -->|"queues cancellation"| node_cancel
node_cancel -->|"releases reservation"| node_persist_service
node_cancel -->|"sends result"| node_client
node_persist_client -->|"routes reads"| node_read_replica
node_read_replica -->|"reads shared store"| node_database
node_catalog -->|"loads catalog"| node_database
node_gt -->|"records measurements"| node_metrics
node_client -->|"encodes messages"| node_protocol
node_gt -->|"decodes messages"| node_protocol
node_rmc -->|"builds requests"| node_protocol
node_persist_service -->|"builds responses"| node_protocol
node_client -->|"reads endpoints"| node_configuration
node_persist_client -->|"reads endpoints"| node_configuration

click node_client "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/cliente.py"
click node_script "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/script.py"
click node_load "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/carga.py"
click node_locust "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/locustfile.py"
click node_gt "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/gestor_transacciones.py"
click node_rmc "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/rmc.py"
click node_cancel "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/main.py"
click node_persist_client "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/cliente_persistencia.py"
click node_metrics "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/metricas.py"
click node_persist_service "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/servicio_persistencia.py"
click node_database "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/db.py"
click node_read_replica "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/main.py"
click node_catalog "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/cargar_datos.py"
click node_protocol "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/config/E_mensaje.py"
click node_configuration "https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/config/configuracion.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_client,node_script,node_load,node_locust,node_customer toneBlue
class node_gt,node_rmc,node_cancel,node_persist_client,node_metrics toneAmber
class node_persist_service,node_database,node_read_replica,node_catalog toneMint
class node_protocol,node_configuration toneRose
```

## Components

### Client layer

- [Client API](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/cliente.py): `capa_cliente/cliente.py`
- [Operation scripts](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/script.py): `capa_cliente/script.py`
- [Load scenarios](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/carga.py): `capa_cliente/carga.py`
- [Locust driver](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_cliente/locustfile.py): `capa_cliente/locustfile.py`

### Business layer

- [Transaction Manager](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/gestor_transacciones.py): `capa_negocios/gestor_transacciones.py`
- [RMC service](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/rmc.py): `capa_negocios/rmc.py`
- [Cancellation service](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/main.py): `capa_negocios/main.py`
- [Persistence client](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/cliente_persistencia.py): `capa_negocios/cliente_persistencia.py`
- [Transaction metrics](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_negocios/metricas.py): `capa_negocios/metricas.py`

### Persistence layer

- [Persistence service](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/servicio_persistencia.py): `capa_persistencia/servicio_persistencia.py`
- [SQLite database](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/db.py): `capa_persistencia/db.py`
- [Read replica](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/main.py): `capa_persistencia/main.py`
- [Catalog loader](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/capa_persistencia/cargar_datos.py): `capa_persistencia/cargar_datos.py`

### Protocol and telemetry

- [JSON message protocol](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/config/E_mensaje.py): `config/E_mensaje.py`
- [Runtime configuration](https://github.com/ana2320-ux/sistema_distribuido_srb/blob/main/config/configuracion.py): `config/configuracion.py`

### Other components

- **Reservation client**

## Connections

- Reservation client → Client API: submits operations (evidence: `README.md`)
- Client API → Transaction Manager: sends requests (evidence: `README.md`)
- Client API → Cancellation service: receives notification (evidence: `README.md`)
- Operation scripts → Client API: executes operations (evidence: `capa_cliente/main.py`)
- Locust driver → Load scenarios: generates load (evidence: `capa_cliente/locustfile.py`)
- Load scenarios → Client API: sends requests (evidence: `capa_cliente/carga.py`)
- Transaction Manager → RMC service: dispatches requests (evidence: `README.md`)
- RMC service → Persistence client: requests persistence (evidence: `capa_negocios/rmc.py`)
- Persistence client → Persistence service: sends requests (evidence: `capa_negocios/cliente_persistencia.py`)
- Persistence service → SQLite database: reads and writes (evidence: `capa_persistencia/servicio_persistencia.py`)
- Transaction Manager → Cancellation service: queues cancellation (evidence: `README.md`)
- Cancellation service → Persistence service: releases reservation (evidence: `README.md`)
- Cancellation service → Client API: sends result (evidence: `README.md`)
- Persistence client → Read replica: routes reads (evidence: `README.md`)
- Read replica → SQLite database: reads shared store (evidence: `README.md`)
- Catalog loader → SQLite database: loads catalog (evidence: `capa_persistencia/cargar_datos.py`)
- Transaction Manager → Transaction metrics: records measurements (evidence: `capa_negocios/gestor_transacciones.py`)
- Client API → JSON message protocol: encodes messages (evidence: `capa_cliente/cliente.py`)
- Transaction Manager → JSON message protocol: decodes messages (evidence: `capa_negocios/gestor_transacciones.py`)
- RMC service → JSON message protocol: builds requests (evidence: `capa_negocios/rmc.py`)
- Persistence service → JSON message protocol: builds responses (evidence: `capa_persistencia/servicio_persistencia.py`)
- Client API → Runtime configuration: reads endpoints (evidence: `capa_cliente/cliente.py`)
- Persistence client → Runtime configuration: reads endpoints (evidence: `capa_negocios/cliente_persistencia.py`)
