# espectro0/rutadeorigen architecture

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

- Interactive diagram: https://gitdiagram.com/espectro0/rutadeorigen
- Repository: https://github.com/espectro0/rutadeorigen

## Overview

The repository is a Go service collection with shared HTTP lifecycle, health, logging, and telemetry support. Traceability is the only service whose product workflow is visible: an HTTP client submits a lot-creation request, which is routed through a controller to an application port. PostgreSQL-backed persistence is optional; the entry point also supports in-memory repositories. Notifications, processor, and QR currently show only service startup and health registration. The README is empty, and several traceability wiring and use-case relationships are not evidenced in the excerpts, so those links are omitted or marked unverified.

Main entry points: [`services/traceability/cmd/traceability/main.go`](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/cmd/traceability/main.go) (Traceability entry point), [`lib/app/app.go`](https://github.com/espectro0/rutadeorigen/blob/main/lib/app/app.go) (Service lifecycle), [`lib/config/config.go`](https://github.com/espectro0/rutadeorigen/blob/main/lib/config/config.go) (Configuration), [`lib/health/health.go`](https://github.com/espectro0/rutadeorigen/blob/main/lib/health/health.go) (Health checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shared["Shared runtime"]
  node_app_lifecycle["Service lifecycle<br/>[app.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_health["Health checks<br/>[health.go]"]
  node_http_server["HTTP server<br/>[server.go]"]
  node_http_middleware["HTTP middleware"]
  node_telemetry["Telemetry<br/>[telemetry.go]"]
  node_logger["Context logging<br/>[context_handler.go]"]
  node_request_context["Request context<br/>[requestcontext.go]"]
end

subgraph group_services["Service entry points"]
  node_notifications["Notifications service<br/>[main.go]"]
  node_processor["Processor service<br/>[main.go]"]
  node_qr["QR service<br/>[main.go]"]
  node_trace_main["Traceability entry point<br/>[main.go]"]
end

subgraph group_trace_api["Traceability API"]
  node_route_wiring["Route wiring<br/>[wiring.go]"]
  node_lot_controller["Lot controller<br/>[lot_controller.go]"]
  node_create_lot["Create-lot use case<br/>[create_lot.go]"]
  node_lot_domain["Lot domain<br/>[lot.go]"]
end

subgraph group_trace_persistence["Traceability persistence"]
  node_lot_repository["Lot repository<br/>[lot_repository.go]"]
  node_lot_assembler["Lot entity assembler<br/>[lot.go]"]
  node_memory_repositories[("In-memory repositories")]
end

node_client(("HTTP client"))
node_postgres[("PostgreSQL")]

node_notifications -->|"loads config"| node_config
node_notifications -->|"registers checks"| node_health
node_notifications -->|"starts service"| node_app_lifecycle
node_processor -->|"loads config"| node_config
node_processor -->|"registers checks"| node_health
node_processor -->|"starts service"| node_app_lifecycle
node_qr -->|"loads config"| node_config
node_qr -->|"registers checks"| node_health
node_qr -->|"starts service"| node_app_lifecycle
node_trace_main -->|"loads config"| node_config
node_trace_main -->|"registers routes"| node_health
node_trace_main -->|"registers routes"| node_route_wiring
node_trace_main -->|"starts service"| node_app_lifecycle
node_trace_main -->|"connects optionally"| node_postgres
node_trace_main -.->|"selects fallback"| node_memory_repositories
node_app_lifecycle -->|"initializes"| node_telemetry
node_app_lifecycle -->|"creates and serves"| node_http_server
node_http_server -->|"wraps requests"| node_http_middleware
node_logger -->|"reads identifiers"| node_request_context
node_client -->|"submits lot request"| node_lot_controller
node_lot_controller -->|"executes port"| node_create_lot
node_lot_repository -->|"converts entity"| node_lot_assembler
node_lot_repository -->|"queries and writes"| node_postgres
node_create_lot -.->|"uses domain"| node_lot_domain
node_create_lot -.->|"persists through port"| node_lot_repository

click node_notifications "https://github.com/espectro0/rutadeorigen/blob/main/services/notifications/cmd/notifications/main.go"
click node_processor "https://github.com/espectro0/rutadeorigen/blob/main/services/processor/cmd/processor/main.go"
click node_qr "https://github.com/espectro0/rutadeorigen/blob/main/services/qr/cmd/qr/main.go"
click node_trace_main "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/cmd/traceability/main.go"
click node_app_lifecycle "https://github.com/espectro0/rutadeorigen/blob/main/lib/app/app.go"
click node_config "https://github.com/espectro0/rutadeorigen/blob/main/lib/config/config.go"
click node_health "https://github.com/espectro0/rutadeorigen/blob/main/lib/health/health.go"
click node_http_server "https://github.com/espectro0/rutadeorigen/blob/main/lib/httpserver/server.go"
click node_http_middleware "https://github.com/espectro0/rutadeorigen/tree/main/lib/httpserver/middleware"
click node_telemetry "https://github.com/espectro0/rutadeorigen/blob/main/lib/telemetry/telemetry.go"
click node_logger "https://github.com/espectro0/rutadeorigen/blob/main/lib/logger/context_handler.go"
click node_request_context "https://github.com/espectro0/rutadeorigen/blob/main/lib/requestcontext/requestcontext.go"
click node_route_wiring "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/cmd/traceability/wiring.go"
click node_lot_controller "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/input/controllers/lot_controller.go"
click node_create_lot "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/application/usecases/createlot/create_lot.go"
click node_lot_domain "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/domain/lot/lot.go"
click node_lot_repository "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/output/repositories/structured/postgres/lot_repository.go"
click node_lot_assembler "https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/output/repositories/structured/postgres/assembler/lot.go"
click node_memory_repositories "https://github.com/espectro0/rutadeorigen/tree/main/services/traceability/internal/infrastructure/output/repositories/structured/memory"

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_lifecycle,node_config,node_health,node_http_server,node_http_middleware,node_telemetry,node_logger,node_request_context,node_client toneBlue
class node_notifications,node_processor,node_qr,node_trace_main,node_postgres toneAmber
class node_route_wiring,node_lot_controller,node_create_lot,node_lot_domain toneMint
class node_lot_repository,node_lot_assembler,node_memory_repositories toneRose
```

## Components

### Shared runtime

- [Service lifecycle](https://github.com/espectro0/rutadeorigen/blob/main/lib/app/app.go): `lib/app/app.go`
- [Configuration](https://github.com/espectro0/rutadeorigen/blob/main/lib/config/config.go): `lib/config/config.go`
- [Health checks](https://github.com/espectro0/rutadeorigen/blob/main/lib/health/health.go): `lib/health/health.go`
- [HTTP server](https://github.com/espectro0/rutadeorigen/blob/main/lib/httpserver/server.go): `lib/httpserver/server.go`
- [HTTP middleware](https://github.com/espectro0/rutadeorigen/tree/main/lib/httpserver/middleware): `lib/httpserver/middleware`
- [Telemetry](https://github.com/espectro0/rutadeorigen/blob/main/lib/telemetry/telemetry.go): `lib/telemetry/telemetry.go`
- [Context logging](https://github.com/espectro0/rutadeorigen/blob/main/lib/logger/context_handler.go): `lib/logger/context_handler.go`
- [Request context](https://github.com/espectro0/rutadeorigen/blob/main/lib/requestcontext/requestcontext.go): `lib/requestcontext/requestcontext.go`

### Service entry points

- [Notifications service](https://github.com/espectro0/rutadeorigen/blob/main/services/notifications/cmd/notifications/main.go): `services/notifications/cmd/notifications/main.go`
- [Processor service](https://github.com/espectro0/rutadeorigen/blob/main/services/processor/cmd/processor/main.go): `services/processor/cmd/processor/main.go`
- [QR service](https://github.com/espectro0/rutadeorigen/blob/main/services/qr/cmd/qr/main.go): `services/qr/cmd/qr/main.go`
- [Traceability entry point](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/cmd/traceability/main.go): `services/traceability/cmd/traceability/main.go`

### Traceability API

- [Route wiring](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/cmd/traceability/wiring.go): `services/traceability/cmd/traceability/wiring.go`
- [Lot controller](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/input/controllers/lot_controller.go): `services/traceability/internal/infrastructure/input/controllers/lot_controller.go`
- [Create-lot use case](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/application/usecases/createlot/create_lot.go): `services/traceability/internal/application/usecases/createlot/create_lot.go`
- [Lot domain](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/domain/lot/lot.go): `services/traceability/internal/domain/lot/lot.go`

### Traceability persistence

- [Lot repository](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/output/repositories/structured/postgres/lot_repository.go): `services/traceability/internal/infrastructure/output/repositories/structured/postgres/lot_repository.go`
- [Lot entity assembler](https://github.com/espectro0/rutadeorigen/blob/main/services/traceability/internal/infrastructure/output/repositories/structured/postgres/assembler/lot.go): `services/traceability/internal/infrastructure/output/repositories/structured/postgres/assembler/lot.go`
- [In-memory repositories](https://github.com/espectro0/rutadeorigen/tree/main/services/traceability/internal/infrastructure/output/repositories/structured/memory): `services/traceability/internal/infrastructure/output/repositories/structured/memory`

### Other components

- **HTTP client**
- **PostgreSQL**

## Connections

- Notifications service → Configuration: loads config (evidence: `services/notifications/cmd/notifications/main.go`)
- Notifications service → Health checks: registers checks (evidence: `services/notifications/cmd/notifications/main.go`)
- Notifications service → Service lifecycle: starts service (evidence: `services/notifications/cmd/notifications/main.go`)
- Processor service → Configuration: loads config (evidence: `services/processor/cmd/processor/main.go`)
- Processor service → Health checks: registers checks (evidence: `services/processor/cmd/processor/main.go`)
- Processor service → Service lifecycle: starts service (evidence: `services/processor/cmd/processor/main.go`)
- QR service → Configuration: loads config (evidence: `services/qr/cmd/qr/main.go`)
- QR service → Health checks: registers checks (evidence: `services/qr/cmd/qr/main.go`)
- QR service → Service lifecycle: starts service (evidence: `services/qr/cmd/qr/main.go`)
- Traceability entry point → Configuration: loads config (evidence: `services/traceability/cmd/traceability/main.go`)
- Traceability entry point → Health checks: registers routes (evidence: `services/traceability/cmd/traceability/main.go`)
- Traceability entry point → Route wiring: registers routes (evidence: `services/traceability/cmd/traceability/main.go`)
- Traceability entry point → Service lifecycle: starts service (evidence: `services/traceability/cmd/traceability/main.go`)
- Traceability entry point → PostgreSQL: connects optionally (evidence: `services/traceability/cmd/traceability/main.go`)
- Traceability entry point → In-memory repositories: selects fallback (evidence: `services/traceability/cmd/traceability/main.go`)
- Service lifecycle → Telemetry: initializes (evidence: `lib/app/app.go`)
- Service lifecycle → HTTP server: creates and serves (evidence: `lib/app/app.go`)
- HTTP server → HTTP middleware: wraps requests (evidence: `lib/httpserver/server.go`)
- Context logging → Request context: reads identifiers (evidence: `lib/logger/context_handler.go`)
- HTTP client → Lot controller: submits lot request (evidence: `services/traceability/internal/infrastructure/input/controllers/lot_controller.go`)
- Lot controller → Create-lot use case: executes port (evidence: `services/traceability/internal/infrastructure/input/controllers/lot_controller.go`)
- Lot repository → Lot entity assembler: converts entity (evidence: `services/traceability/internal/infrastructure/output/repositories/structured/postgres/lot_repository.go`)
- Lot repository → PostgreSQL: queries and writes (evidence: `services/traceability/internal/infrastructure/output/repositories/structured/postgres/lot_repository.go`)
- Create-lot use case → Lot domain: uses domain
- Create-lot use case → Lot repository: persists through port
