# nishanthrao01/farmgaurd architecture

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

- Interactive diagram: https://gitdiagram.com/nishanthrao01/farmgaurd
- Repository: https://github.com/nishanthrao01/farmgaurd

## Overview

FarmGuard is a farm-management portal for antimicrobial-use tracking and residue safety. Farmers and administrators manage farms, livestock, medicines, and treatments; treatment records calculate product withdrawal periods, while laboratory results are evaluated against MRL standards. The portal also provides dashboard analytics and compliance reporting. The graph reflects documented capabilities and sampled controller/service relationships; unsampled controller wiring and report/export implementation are not asserted as verified calls.

Main entry points: [`Controllers/Mvc/WebControllers.cs`](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/Mvc/WebControllers.cs) (Web and API), [`Data/FarmGuardDbContext.cs`](https://github.com/nishanthrao01/farmgaurd/blob/main/Data/FarmGuardDbContext.cs) (Application database), [`Services/Implementations/TreatmentService.cs`](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/TreatmentService.cs) (Treatment service), [`Services/Implementations/AnimalService.cs`](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/AnimalService.cs) (Animal service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Portal Entry"]
  node_portal["Web and API<br/>[WebControllers.cs]"]
  node_auth["Authentication<br/>[AuthController.cs]"]
  node_dashboard["Dashboard"]
end

subgraph group_management["Farm Management"]
  node_animals["Livestock"]
  node_farms["Farm records<br/>[FarmsController.cs]"]
  node_medicines["Medicine catalog"]
  node_treatments["Treatment records"]
  node_animal_service["Animal service<br/>[AnimalService.cs]"]
  node_farm_service["Farm service<br/>[FarmService.cs]"]
  node_medicine_service["Medicine service<br/>[MedicineService.cs]"]
  node_treatment_service["Treatment service"]
end

subgraph group_safety["Safety Compliance"]
  node_withdrawal["Product clearance"]
  node_lab_tests["Laboratory tests"]
  node_mrl_standards["MRL standards"]
  node_reports["Compliance reports"]
  node_withdrawal_service["Withdrawal service"]
  node_mrl_service["MRL evaluation<br/>[MRLService.cs]"]
  node_dashboard_service["Dashboard analytics"]
end

subgraph group_platform["Application Platform"]
  node_auth_service["Identity and tokens<br/>[AuthService.cs]"]
  node_domain_models["Farm domain records"]
  node_database[("Application database")]
  node_app_host["Application host<br/>[Program.cs]"]
end

node_farm_users(("Farm users"))

node_farm_users -->|"use portal"| node_portal
node_farm_users -->|"sign in"| node_auth
node_portal -.->|"manage livestock"| node_animals
node_portal -.->|"manage farms"| node_farms
node_portal -.->|"manage catalog"| node_medicines
node_portal -->|"record usage"| node_treatments
node_portal -->|"check clearance"| node_withdrawal
node_portal -->|"enter test results"| node_lab_tests
node_portal -->|"evaluate limits"| node_mrl_standards
node_portal -->|"view analytics"| node_dashboard
node_portal -->|"export audits"| node_reports
node_animals -->|"calls"| node_animal_service
node_farms -->|"calls"| node_farm_service
node_treatments -->|"calls"| node_treatment_service
node_treatments -->|"retrieves animals"| node_animal_service
node_lab_tests -->|"calls"| node_mrl_service
node_withdrawal -->|"calls"| node_withdrawal_service
node_withdrawal -->|"retrieves animals"| node_animal_service
node_treatment_service -->|"writes treatments and restrictions"| node_database
node_treatment_service -->|"uses records"| node_domain_models
node_animal_service -->|"queries records"| node_database
node_mrl_service -->|"evaluates test results"| node_database
node_withdrawal_service -->|"checks restrictions"| node_database
node_dashboard_service -->|"aggregates metrics"| node_database
node_auth -.->|"authenticates"| node_auth_service
node_dashboard -.->|"loads analytics"| node_dashboard_service
node_medicines -.->|"manages catalog"| node_medicine_service
node_mrl_standards -.->|"manages standards"| node_mrl_service
node_reports -.->|"audits AMU"| node_treatment_service
node_app_host -->|"configures store"| node_database
node_app_host -->|"registers service"| node_auth_service
node_app_host -->|"registers service"| node_treatment_service

click node_portal "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/Mvc/WebControllers.cs"
click node_auth "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/AuthController.cs"
click node_dashboard "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/DashboardController.cs"
click node_animals "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/AnimalsController.cs"
click node_farms "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/FarmsController.cs"
click node_medicines "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/MedicinesController.cs"
click node_treatments "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/TreatmentsController.cs"
click node_withdrawal "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/WithdrawalController.cs"
click node_lab_tests "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/LabTestsController.cs"
click node_mrl_standards "https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/MRLStandardsController.cs"
click node_reports "https://github.com/nishanthrao01/farmgaurd/tree/main/Controllers"
click node_animal_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/AnimalService.cs"
click node_farm_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/FarmService.cs"
click node_medicine_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/MedicineService.cs"
click node_treatment_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/TreatmentService.cs"
click node_withdrawal_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/WithdrawalService.cs"
click node_mrl_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/MRLService.cs"
click node_dashboard_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/DashboardService.cs"
click node_auth_service "https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/AuthService.cs"
click node_domain_models "https://github.com/nishanthrao01/farmgaurd/tree/main/Models"
click node_database "https://github.com/nishanthrao01/farmgaurd/blob/main/Data/FarmGuardDbContext.cs"
click node_app_host "https://github.com/nishanthrao01/farmgaurd/blob/main/Program.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_portal,node_auth,node_dashboard,node_farm_users toneBlue
class node_animals,node_farms,node_medicines,node_treatments,node_animal_service,node_farm_service,node_medicine_service,node_treatment_service toneAmber
class node_withdrawal,node_lab_tests,node_mrl_standards,node_reports,node_withdrawal_service,node_mrl_service,node_dashboard_service toneMint
class node_auth_service,node_domain_models,node_database,node_app_host toneRose
```

## Components

### Portal Entry

- [Web and API](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/Mvc/WebControllers.cs): `Controllers/Mvc/WebControllers.cs`
- [Authentication](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/AuthController.cs): `Controllers/AuthController.cs`
- [Dashboard](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/DashboardController.cs): `Controllers/DashboardController.cs`

### Farm Management

- [Livestock](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/AnimalsController.cs): `Controllers/AnimalsController.cs`
- [Farm records](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/FarmsController.cs): `Controllers/FarmsController.cs`
- [Medicine catalog](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/MedicinesController.cs): `Controllers/MedicinesController.cs`
- [Treatment records](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/TreatmentsController.cs): `Controllers/TreatmentsController.cs`
- [Animal service](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/AnimalService.cs): `Services/Implementations/AnimalService.cs`
- [Farm service](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/FarmService.cs): `Services/Implementations/FarmService.cs`
- [Medicine service](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/MedicineService.cs): `Services/Implementations/MedicineService.cs`
- [Treatment service](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/TreatmentService.cs): `Services/Implementations/TreatmentService.cs`

### Safety Compliance

- [Product clearance](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/WithdrawalController.cs): `Controllers/WithdrawalController.cs`
- [Laboratory tests](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/LabTestsController.cs): `Controllers/LabTestsController.cs`
- [MRL standards](https://github.com/nishanthrao01/farmgaurd/blob/main/Controllers/MRLStandardsController.cs): `Controllers/MRLStandardsController.cs`
- [Compliance reports](https://github.com/nishanthrao01/farmgaurd/tree/main/Controllers): `Controllers`
- [Withdrawal service](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/WithdrawalService.cs): `Services/Implementations/WithdrawalService.cs`
- [MRL evaluation](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/MRLService.cs): `Services/Implementations/MRLService.cs`
- [Dashboard analytics](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/DashboardService.cs): `Services/Implementations/DashboardService.cs`

### Application Platform

- [Identity and tokens](https://github.com/nishanthrao01/farmgaurd/blob/main/Services/Implementations/AuthService.cs): `Services/Implementations/AuthService.cs`
- [Farm domain records](https://github.com/nishanthrao01/farmgaurd/tree/main/Models): `Models`
- [Application database](https://github.com/nishanthrao01/farmgaurd/blob/main/Data/FarmGuardDbContext.cs): `Data/FarmGuardDbContext.cs`
- [Application host](https://github.com/nishanthrao01/farmgaurd/blob/main/Program.cs): `Program.cs`

### Other components

- **Farm users**

## Connections

- Farm users → Web and API: use portal (evidence: `README.md`)
- Farm users → Authentication: sign in (evidence: `README.md`)
- Web and API → Livestock: manage livestock
- Web and API → Farm records: manage farms
- Web and API → Medicine catalog: manage catalog
- Web and API → Treatment records: record usage (evidence: `README.md`)
- Web and API → Product clearance: check clearance (evidence: `README.md`)
- Web and API → Laboratory tests: enter test results (evidence: `README.md`)
- Web and API → MRL standards: evaluate limits (evidence: `README.md`)
- Web and API → Dashboard: view analytics (evidence: `README.md`)
- Web and API → Compliance reports: export audits (evidence: `README.md`)
- Livestock → Animal service: calls (evidence: `Controllers/AnimalsController.cs`)
- Farm records → Farm service: calls (evidence: `Controllers/FarmsController.cs`)
- Treatment records → Treatment service: calls (evidence: `Controllers/TreatmentsController.cs`)
- Treatment records → Animal service: retrieves animals (evidence: `Controllers/TreatmentsController.cs`)
- Laboratory tests → MRL evaluation: calls (evidence: `Controllers/LabTestsController.cs`)
- Product clearance → Withdrawal service: calls (evidence: `Controllers/WithdrawalController.cs`)
- Product clearance → Animal service: retrieves animals (evidence: `Controllers/WithdrawalController.cs`)
- Treatment service → Application database: writes treatments and restrictions (evidence: `Services/Implementations/TreatmentService.cs`)
- Treatment service → Farm domain records: uses records (evidence: `Services/Implementations/TreatmentService.cs`)
- Animal service → Application database: queries records (evidence: `Services/Implementations/AnimalService.cs`)
- MRL evaluation → Application database: evaluates test results (evidence: `Services/Implementations/MRLService.cs`)
- Withdrawal service → Application database: checks restrictions (evidence: `Services/Implementations/WithdrawalService.cs`)
- Dashboard analytics → Application database: aggregates metrics (evidence: `Services/Implementations/DashboardService.cs`)
- Authentication → Identity and tokens: authenticates
- Dashboard → Dashboard analytics: loads analytics
- Medicine catalog → Medicine service: manages catalog
- MRL standards → MRL evaluation: manages standards
- Compliance reports → Treatment service: audits AMU
- Application host → Application database: configures store (evidence: `Program.cs`)
- Application host → Identity and tokens: registers service (evidence: `Program.cs`)
- Application host → Treatment service: registers service (evidence: `Program.cs`)
