# thang-ph/livestock-management architecture

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

- Interactive diagram: https://gitdiagram.com/thang-ph/livestock-management
- Repository: https://github.com/thang-ph/livestock-management

## Overview

This repository implements a livestock-management system with a web dashboard and an ASP.NET Core API. Staff use the dashboard to monitor animal health, vaccination progress, and farm operations; backend domain services manage the corresponding records. The sampled code confirms the EF Core data model, import and vaccination services, and a vaccination controller’s repository interface. README capabilities also include operational reporting and field-task management, but those paths were not sampled, so their internal connections remain unverified.

Main entry points: [`livestock-management-backend/BusinessObjects/LmsContext.cs`](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/LmsContext.cs) (EF Core context), [`livestock-management-frontend/src/pages/Dashboard/index.tsx`](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/pages/Dashboard/index.tsx) (Dashboard UI), [`livestock-management-backend/LivestockManagementSystemAPI/Controllers`](https://github.com/thang-ph/livestock-management/tree/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers) (REST controllers), [`livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs`](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs) (Vaccination service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web dashboard"]
  node_dashboard["Dashboard UI<br/>[index.tsx]"]
  node_vaccination_ui["Vaccination views<br/>[index.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_dashboard_metrics["Operational metrics<br/>[bar-graph.tsx]"]
end

subgraph group_api["API and access"]
  node_api_controllers["REST controllers"]
  node_vaccination_controller["Vaccination API"]
  node_auth["Authentication<br/>[AuthController.cs]"]
  node_permissions["Permission checks"]
  node_operations_api["Farm operations API"]
end

subgraph group_operations["Farm operations"]
  node_import_service["Batch imports<br/>[ImportService.cs]"]
  node_livestock["Livestock records<br/>[Livestock.cs]"]
  node_barn["Barns and batches<br/>[BatchImport.cs]"]
  node_field_tasks["Field operations"]
end

subgraph group_health["Health and vaccination"]
  node_disease["Disease records<br/>[Disease.cs]"]
  node_medical_history["Treatment history<br/>[MedicalHistory.cs]"]
  node_vaccination_service["Vaccination service"]
  node_vaccination_records["Vaccination records"]
end

subgraph group_persistence["Domain and persistence"]
  node_mapper["DTO mapping<br/>[ConfigMapper.cs]"]
  node_context[("EF Core context<br/>[LmsContext.cs]")]
end

node_staff(("Farm staff"))
node_sql[("SQL Server")]
node_cloud_storage[("Cloudinary")]

node_staff -->|"uses"| node_dashboard
node_staff -->|"tracks campaigns"| node_vaccination_ui
node_dashboard -.->|"requests data"| node_api_client
node_vaccination_ui -.->|"requests data"| node_api_client
node_api_client -.->|"calls API"| node_api_controllers
node_api_controllers -.->|"includes sign-in"| node_auth
node_api_controllers -.->|"checks access"| node_permissions
node_vaccination_controller -->|"dispatches via repository"| node_vaccination_service
node_vaccination_service -->|"reads and writes"| node_context
node_import_service -->|"reads and writes"| node_context
node_operations_api -.->|"handles imports"| node_import_service
node_context -->|"persists records"| node_sql
node_context -->|"maps entities"| node_livestock
node_context -->|"maps entities"| node_barn
node_context -->|"maps entities"| node_vaccination_records
node_context -->|"maps entities"| node_disease
node_context -->|"maps entities"| node_medical_history
node_vaccination_service -.->|"optional file operations"| node_cloud_storage
node_dashboard -.->|"presents metrics"| node_dashboard_metrics
node_staff -->|"manages activities"| node_field_tasks
node_mapper -.->|"maps DTOs to models"| node_context

click node_dashboard "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/pages/Dashboard/index.tsx"
click node_vaccination_ui "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/pages/ChiTietLoTiem/components/add/index.tsx"
click node_api_client "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/lib/api.ts"
click node_api_controllers "https://github.com/thang-ph/livestock-management/tree/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers"
click node_vaccination_controller "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/BatchVacinationController.cs"
click node_auth "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/AuthController.cs"
click node_permissions "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Authorization/PermissionAuthorizationHandler.cs"
click node_import_service "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/Repository/Services/ImportService.cs"
click node_operations_api "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/ImportController.cs"
click node_livestock "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/Livestock.cs"
click node_barn "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/BatchImport.cs"
click node_disease "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/Disease.cs"
click node_medical_history "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/MedicalHistory.cs"
click node_vaccination_service "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs"
click node_vaccination_records "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/BatchVaccination.cs"
click node_dashboard_metrics "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/components/charts/bar-graph.tsx"
click node_field_tasks "https://github.com/thang-ph/livestock-management/tree/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers"
click node_mapper "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/AutoMapperConfig/ConfigMapper.cs"
click node_context "https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/LmsContext.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_dashboard,node_vaccination_ui,node_api_client,node_dashboard_metrics toneBlue
class node_api_controllers,node_vaccination_controller,node_auth,node_permissions,node_operations_api,node_sql,node_cloud_storage toneAmber
class node_import_service,node_livestock,node_barn,node_field_tasks toneMint
class node_disease,node_medical_history,node_vaccination_service,node_vaccination_records toneRose
class node_mapper,node_context,node_staff toneIndigo
```

## Components

### Web dashboard

- [Dashboard UI](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/pages/Dashboard/index.tsx): `livestock-management-frontend/src/pages/Dashboard/index.tsx`
- [Vaccination views](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/pages/ChiTietLoTiem/components/add/index.tsx): `livestock-management-frontend/src/pages/ChiTietLoTiem/components/add/index.tsx`
- [API client](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/lib/api.ts): `livestock-management-frontend/src/lib/api.ts`
- [Operational metrics](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-frontend/src/components/charts/bar-graph.tsx): `livestock-management-frontend/src/components/charts/bar-graph.tsx`

### API and access

- [REST controllers](https://github.com/thang-ph/livestock-management/tree/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers): `livestock-management-backend/LivestockManagementSystemAPI/Controllers`
- [Vaccination API](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/BatchVacinationController.cs): `livestock-management-backend/LivestockManagementSystemAPI/Controllers/BatchVacinationController.cs`
- [Authentication](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/AuthController.cs): `livestock-management-backend/LivestockManagementSystemAPI/Controllers/AuthController.cs`
- [Permission checks](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Authorization/PermissionAuthorizationHandler.cs): `livestock-management-backend/LivestockManagementSystemAPI/Authorization/PermissionAuthorizationHandler.cs`
- [Farm operations API](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers/ImportController.cs): `livestock-management-backend/LivestockManagementSystemAPI/Controllers/ImportController.cs`

### Farm operations

- [Batch imports](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/Repository/Services/ImportService.cs): `livestock-management-backend/DataAccess/Repository/Services/ImportService.cs`
- [Livestock records](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/Livestock.cs): `livestock-management-backend/BusinessObjects/Models/Livestock.cs`
- [Barns and batches](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/BatchImport.cs): `livestock-management-backend/BusinessObjects/Models/BatchImport.cs`
- [Field operations](https://github.com/thang-ph/livestock-management/tree/main/livestock-management-backend/LivestockManagementSystemAPI/Controllers): `livestock-management-backend/LivestockManagementSystemAPI/Controllers`

### Health and vaccination

- [Disease records](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/Disease.cs): `livestock-management-backend/BusinessObjects/Models/Disease.cs`
- [Treatment history](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/MedicalHistory.cs): `livestock-management-backend/BusinessObjects/Models/MedicalHistory.cs`
- [Vaccination service](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs): `livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs`
- [Vaccination records](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/Models/BatchVaccination.cs): `livestock-management-backend/BusinessObjects/Models/BatchVaccination.cs`

### Domain and persistence

- [DTO mapping](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/DataAccess/AutoMapperConfig/ConfigMapper.cs): `livestock-management-backend/DataAccess/AutoMapperConfig/ConfigMapper.cs`
- [EF Core context](https://github.com/thang-ph/livestock-management/blob/main/livestock-management-backend/BusinessObjects/LmsContext.cs): `livestock-management-backend/BusinessObjects/LmsContext.cs`

### Other components

- **Farm staff**
- **SQL Server**
- **Cloudinary**

## Connections

- Farm staff → Dashboard UI: uses
- Farm staff → Vaccination views: tracks campaigns
- Dashboard UI → API client: requests data
- Vaccination views → API client: requests data
- API client → REST controllers: calls API
- REST controllers → Authentication: includes sign-in
- REST controllers → Permission checks: checks access
- Vaccination API → Vaccination service: dispatches via repository (evidence: `livestock-management-backend/LivestockManagementSystemAPI/Controllers/BatchVacinationController.cs`)
- Vaccination service → EF Core context: reads and writes (evidence: `livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs`)
- Batch imports → EF Core context: reads and writes (evidence: `livestock-management-backend/DataAccess/Repository/Services/ImportService.cs`)
- Farm operations API → Batch imports: handles imports
- EF Core context → SQL Server: persists records (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- EF Core context → Livestock records: maps entities (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- EF Core context → Barns and batches: maps entities (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- EF Core context → Vaccination records: maps entities (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- EF Core context → Disease records: maps entities (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- EF Core context → Treatment history: maps entities (evidence: `livestock-management-backend/BusinessObjects/LmsContext.cs`)
- Vaccination service → Cloudinary: optional file operations (evidence: `livestock-management-backend/DataAccess/Repository/Services/BatchVacinationService.cs`)
- Dashboard UI → Operational metrics: presents metrics
- Farm staff → Field operations: manages activities
- DTO mapping → EF Core context: maps DTOs to models
