# junixos/zootech-backend architecture

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

- Interactive diagram: https://gitdiagram.com/junixos/zootech-backend
- Repository: https://github.com/junixos/zootech-backend

## Overview

ZooTech is a multi-tenant livestock-management backend API. Its principal request path is an HTTP client calling a controller, which dispatches a typed request through application behavior/interactor logic and returns a response. The tree documents domain capabilities including cattle, heat cycles, breeding, milk production, animal health, authentication, tenant administration, and exports. Edges are limited to relationships shown by excerpts or the source index; implementations and wiring not sampled are represented cautiously.

Main entry points: [`src/ZooTech.API/Program.cs`](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.API/Program.cs) (API host), [`src/ZooTech.Application/Common/Behaviors/IBehaviorDispatcher.cs`](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Behaviors/IBehaviorDispatcher.cs) (Request dispatcher), [`src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs`](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs) (Tenant API), [`src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs`](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs) (Heat-cycle API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API boundary"]
  node_host["API host<br/>[Program.cs]"]
  node_celo_api["Heat-cycle API<br/>[CeloController.cs]"]
  node_vacuno_api["Cattle API"]
  node_milk_api["Milk API"]
  node_tenant_api["Tenant API"]
end

subgraph group_app["Application workflows"]
  node_dispatcher["Request dispatcher"]
  node_pipeline["Behavior pipeline"]
  node_celo_workflows["Heat-cycle workflows<br/>[UseCases]"]
  node_breeding_workflows["Breeding workflows<br/>[UseCases]"]
  node_milk_workflows["Milk workflows<br/>[Ordenios]"]
  node_health_workflows["Health workflows<br/>[UseCases]"]
  node_auth_workflows["Authentication<br/>[UseCases]"]
  node_tenant_workflows["Tenant workflows<br/>[UseCases]"]
  node_report_exports["Reports and exports"]
end

subgraph group_domain["Livestock domain"]
  node_cattle_domain["Cattle records<br/>[Vacuno.cs]"]
  node_celo_domain["Heat-cycle records<br/>[Celo.cs]"]
  node_milk_domain["Milking records<br/>[Ordenio.cs]"]
  node_health_domain["Health records<br/>[Triaje.cs]"]
  node_breeding_domain["Breeding records"]
end

subgraph group_platform["Tenant platform"]
  node_tenant_context["Tenant context<br/>[ITenantContext.cs]"]
  node_tenant_provision["Tenant provisioning"]
  node_report_storage["Report storage"]
  node_audit["Audit service"]
  node_data_store[("Tenant database")]
end

node_client(("API client"))

node_client -->|"sends HTTP"| node_host
node_host -->|"registers controller"| node_celo_api
node_host -->|"registers controller"| node_vacuno_api
node_host -->|"registers controller"| node_milk_api
node_host -->|"registers controller"| node_tenant_api
node_celo_api -->|"dispatches requests"| node_dispatcher
node_vacuno_api -->|"dispatches requests"| node_dispatcher
node_milk_api -->|"dispatches requests"| node_dispatcher
node_tenant_api -->|"dispatches requests"| node_dispatcher
node_pipeline -->|"invokes handler"| node_celo_workflows
node_celo_workflows -.->|"uses repository"| node_celo_domain
node_breeding_workflows -.->|"uses repository"| node_breeding_domain
node_milk_workflows -.->|"uses repository"| node_milk_domain
node_health_workflows -.->|"uses repository"| node_health_domain
node_tenant_api -->|"tenant filter reads"| node_tenant_context
node_tenant_workflows -.->|"provisions tenant"| node_tenant_provision
node_report_exports -.->|"stores reports"| node_report_storage
node_cattle_domain -.->|"persists records"| node_data_store
node_audit -.->|"records events"| node_data_store

click node_host "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.API/Program.cs"
click node_celo_api "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs"
click node_vacuno_api "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Vacuno/Controllers/VacunoController.cs"
click node_milk_api "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_ProduccionLeche/Controllers/ProduccionLecheController.cs"
click node_tenant_api "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs"
click node_dispatcher "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Behaviors/IBehaviorDispatcher.cs"
click node_pipeline "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Behaviors/BehaviorPipeline.cs"
click node_celo_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Celo/UseCases"
click node_breeding_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Fecundacion/UseCases"
click node_milk_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios"
click node_health_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Sanidad/UseCases"
click node_auth_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Auth/UseCases"
click node_tenant_workflows "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Tenancing/UseCases"
click node_report_exports "https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios/GenerateOrdeniosPdf"
click node_cattle_domain "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Ganaderia/Module_Vacuno/Entities/Vacuno.cs"
click node_celo_domain "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_Celo/Entities/Celo.cs"
click node_milk_domain "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_ProduccionLeche/Entities/Ordenio.cs"
click node_health_domain "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_Sanidad/Entities/Triaje.cs"
click node_breeding_domain "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Ganaderia/Module_Fecundacion/Interfaces/IFecundacionRepository.cs"
click node_tenant_context "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Gateway/Context/ITenantContext.cs"
click node_tenant_provision "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Tenant/TenantProvisioningService.cs"
click node_report_storage "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Storage/VacunoReportFileStorage.cs"
click node_audit "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Auditing/MongoDb/MongoDbAuditService.cs"
click node_data_store "https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Persistence/Context/GanaderiaDbContext.cs"

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_host,node_celo_api,node_vacuno_api,node_milk_api,node_tenant_api,node_client toneBlue
class node_dispatcher,node_pipeline,node_celo_workflows,node_breeding_workflows,node_milk_workflows,node_health_workflows,node_auth_workflows,node_tenant_workflows,node_report_exports toneAmber
class node_cattle_domain,node_celo_domain,node_milk_domain,node_health_domain,node_breeding_domain toneMint
class node_tenant_context,node_tenant_provision,node_report_storage,node_audit,node_data_store toneRose
```

## Components

### API boundary

- [API host](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.API/Program.cs): `src/ZooTech.API/Program.cs`
- [Heat-cycle API](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs): `src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs`
- [Cattle API](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Vacuno/Controllers/VacunoController.cs): `src/ZooTech.InterfaceAdapters/Modules/Module_Vacuno/Controllers/VacunoController.cs`
- [Milk API](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_ProduccionLeche/Controllers/ProduccionLecheController.cs): `src/ZooTech.InterfaceAdapters/Modules/Module_ProduccionLeche/Controllers/ProduccionLecheController.cs`
- [Tenant API](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs): `src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs`

### Application workflows

- [Request dispatcher](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Behaviors/IBehaviorDispatcher.cs): `src/ZooTech.Application/Common/Behaviors/IBehaviorDispatcher.cs`
- [Behavior pipeline](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Behaviors/BehaviorPipeline.cs): `src/ZooTech.Application/Common/Behaviors/BehaviorPipeline.cs`
- [Heat-cycle workflows](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Celo/UseCases): `src/ZooTech.Application/Modules/Module_Celo/UseCases`
- [Breeding workflows](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Fecundacion/UseCases): `src/ZooTech.Application/Modules/Module_Fecundacion/UseCases`
- [Milk workflows](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios): `src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios`
- [Health workflows](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Sanidad/UseCases): `src/ZooTech.Application/Modules/Module_Sanidad/UseCases`
- [Authentication](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Auth/UseCases): `src/ZooTech.Application/Modules/Module_Auth/UseCases`
- [Tenant workflows](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_Tenancing/UseCases): `src/ZooTech.Application/Modules/Module_Tenancing/UseCases`
- [Reports and exports](https://github.com/junixos/zootech-backend/tree/main/src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios/GenerateOrdeniosPdf): `src/ZooTech.Application/Modules/Module_ProduccionLeche/UseCases/Ordenios/GenerateOrdeniosPdf`

### Livestock domain

- [Cattle records](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Ganaderia/Module_Vacuno/Entities/Vacuno.cs): `src/ZooTech.Domain/Ganaderia/Module_Vacuno/Entities/Vacuno.cs`
- [Heat-cycle records](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_Celo/Entities/Celo.cs): `src/ZooTech.Domain/Module_Celo/Entities/Celo.cs`
- [Milking records](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_ProduccionLeche/Entities/Ordenio.cs): `src/ZooTech.Domain/Module_ProduccionLeche/Entities/Ordenio.cs`
- [Health records](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Module_Sanidad/Entities/Triaje.cs): `src/ZooTech.Domain/Module_Sanidad/Entities/Triaje.cs`
- [Breeding records](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Domain/Ganaderia/Module_Fecundacion/Interfaces/IFecundacionRepository.cs): `src/ZooTech.Domain/Ganaderia/Module_Fecundacion/Interfaces/IFecundacionRepository.cs`

### Tenant platform

- [Tenant context](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Application/Common/Gateway/Context/ITenantContext.cs): `src/ZooTech.Application/Common/Gateway/Context/ITenantContext.cs`
- [Tenant provisioning](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Tenant/TenantProvisioningService.cs): `src/ZooTech.Infrastructure/Tenant/TenantProvisioningService.cs`
- [Report storage](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Storage/VacunoReportFileStorage.cs): `src/ZooTech.Infrastructure/Storage/VacunoReportFileStorage.cs`
- [Audit service](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Auditing/MongoDb/MongoDbAuditService.cs): `src/ZooTech.Infrastructure/Auditing/MongoDb/MongoDbAuditService.cs`
- [Tenant database](https://github.com/junixos/zootech-backend/blob/main/src/ZooTech.Infrastructure/Persistence/Context/GanaderiaDbContext.cs): `src/ZooTech.Infrastructure/Persistence/Context/GanaderiaDbContext.cs`

### Other components

- **API client**

## Connections

- API client → API host: sends HTTP
- API host → Heat-cycle API: registers controller (evidence: `src/ZooTech.API/Program.cs`)
- API host → Cattle API: registers controller (evidence: `src/ZooTech.API/Program.cs`)
- API host → Milk API: registers controller (evidence: `src/ZooTech.API/Program.cs`)
- API host → Tenant API: registers controller (evidence: `src/ZooTech.API/Program.cs`)
- Heat-cycle API → Request dispatcher: dispatches requests (evidence: `src/ZooTech.InterfaceAdapters/Modules/Module_Celo/Controllers/CeloController.cs`)
- Cattle API → Request dispatcher: dispatches requests (evidence: `src/ZooTech.InterfaceAdapters/Modules/Module_Vacuno/Controllers/VacunoController.cs`)
- Milk API → Request dispatcher: dispatches requests (evidence: `src/ZooTech.InterfaceAdapters/Modules/Module_ProduccionLeche/Controllers/ProduccionLecheController.cs`)
- Tenant API → Request dispatcher: dispatches requests (evidence: `src/ZooTech.InterfaceAdapters/Modules/Module_Tenancing/Controllers/TenancingController.cs`)
- Behavior pipeline → Heat-cycle workflows: invokes handler (evidence: `src/ZooTech.Application/Common/Behaviors/Module_Celo/GetHistorialCeloPorVacuno/GetHistorialCeloPorVacunoBehaviorPipelineFactory.cs`)
- Heat-cycle workflows → Heat-cycle records: uses repository
- Breeding workflows → Breeding records: uses repository
- Milk workflows → Milking records: uses repository
- Health workflows → Health records: uses repository
- Tenant API → Tenant context: tenant filter reads
- Tenant workflows → Tenant provisioning: provisions tenant (evidence: `src/ZooTech.Infrastructure/Tenant/TenantProvisioningService.cs`)
- Reports and exports → Report storage: stores reports
- Cattle records → Tenant database: persists records
- Audit service → Tenant database: records events
