# alanq139/agrosolutions architecture

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

- Interactive diagram: https://gitdiagram.com/alanq139/agrosolutions
- Repository: https://github.com/alanq139/agrosolutions

## Overview

AgroSolutions is an agricultural IoT monitoring MVP. The main workflow is client access through the Ocelot gateway, management of identity and farm properties, sensor ingestion and asynchronous alert processing, with service metrics monitored by Prometheus and Grafana. The README documents the overall service topology and capabilities; sampled code confirms sensor-event publishing and identity/property persistence. Alert-worker internals and some infrastructure wiring were not sampled, so those links are omitted or marked unverified.

Main entry points: [`src/Services/AgroSolutions.ApiGateway/Program.cs`](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.ApiGateway/Program.cs) (API gateway), [`src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs`](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs) (Sensor ingestion), [`src/Services/AgroSolutions.IdentityService/Controller/IdentityserviceAuthcontroller.cs`](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Controller/IdentityserviceAuthcontroller.cs) (Authentication), [`src/Services/AgroSolutions.IdentityService/Models/IdentityserviceApplicationdbcontext.cs`](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Models/IdentityserviceApplicationdbcontext.cs) (Identity context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and identity"]
  node_gateway["API gateway<br/>[Program.cs]"]
  node_identity["Authentication"]
  node_identity_context["Identity context"]
  node_identity_db[("Identity SQL database")]
end

subgraph group_farm["Farm data"]
  node_properties["Properties and plots"]
  node_farm_model["Farm data model"]
  node_farm_db[("Farm SQL database")]
  node_shared_contracts["Shared API contracts<br/>[DTO.cs]"]
end

subgraph group_events["Sensor and alerts"]
  node_sensor_api["Sensor ingestion"]
  node_sensor_event["Sensor event contract"]
  node_broker["RabbitMQ"]
  node_alert_worker["Alert processing<br/>[Worker.cs]"]
  node_alert_db[("Alert SQL database")]
  node_shared_config["Shared configuration<br/>[Configuration.cs]"]
end

subgraph group_ops["Monitoring"]
  node_prometheus["Prometheus<br/>[prometheus.yml]"]
  node_grafana["Grafana"]
end

node_client(("Client"))

node_client -->|"sends requests"| node_gateway
node_gateway -->|"routes requests"| node_identity
node_gateway -->|"routes requests"| node_properties
node_gateway -->|"routes requests"| node_sensor_api
node_identity -->|"uses identity store"| node_identity_context
node_identity_context -.->|"persists users"| node_identity_db
node_properties -->|"uses data model"| node_farm_model
node_farm_model -.->|"maps entities"| node_farm_db
node_sensor_api -->|"creates event"| node_sensor_event
node_sensor_api -->|"publishes event"| node_broker
node_broker -.->|"dispatches events"| node_alert_worker
node_alert_worker -.->|"stores alerts"| node_alert_db
node_prometheus -.->|"provides monitoring"| node_grafana

click node_gateway "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.ApiGateway/Program.cs"
click node_identity "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Controller/IdentityserviceAuthcontroller.cs"
click node_identity_context "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Models/IdentityserviceApplicationdbcontext.cs"
click node_properties "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.PropertyService/Controllers/PropertyserviceControllers.cs"
click node_farm_model "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.PropertyService/Models/PropertyserviceModels.cs"
click node_sensor_api "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs"
click node_sensor_event "https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Messages/Sensordatareceived.cs"
click node_alert_worker "https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.AlertService/Worker.cs"
click node_shared_config "https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Common/Configuration.cs"
click node_shared_contracts "https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Common/DTO.cs"
click node_prometheus "https://github.com/alanq139/agrosolutions/blob/main/prometheus.yml"
click node_grafana "https://github.com/alanq139/agrosolutions/blob/main/k8s/grafana-deployment.yaml"

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_gateway,node_identity,node_identity_context,node_identity_db,node_client toneBlue
class node_properties,node_farm_model,node_farm_db,node_shared_contracts toneAmber
class node_sensor_api,node_sensor_event,node_broker,node_alert_worker,node_alert_db,node_shared_config toneMint
class node_prometheus,node_grafana toneRose
```

## Components

### Access and identity

- [API gateway](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.ApiGateway/Program.cs): `src/Services/AgroSolutions.ApiGateway/Program.cs`
- [Authentication](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Controller/IdentityserviceAuthcontroller.cs): `src/Services/AgroSolutions.IdentityService/Controller/IdentityserviceAuthcontroller.cs`
- [Identity context](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.IdentityService/Models/IdentityserviceApplicationdbcontext.cs): `src/Services/AgroSolutions.IdentityService/Models/IdentityserviceApplicationdbcontext.cs`
- **Identity SQL database**

### Farm data

- [Properties and plots](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.PropertyService/Controllers/PropertyserviceControllers.cs): `src/Services/AgroSolutions.PropertyService/Controllers/PropertyserviceControllers.cs`
- [Farm data model](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.PropertyService/Models/PropertyserviceModels.cs): `src/Services/AgroSolutions.PropertyService/Models/PropertyserviceModels.cs`
- **Farm SQL database**
- [Shared API contracts](https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Common/DTO.cs): `src/Shared/AgroSolutions.Shared.Common/DTO.cs`

### Sensor and alerts

- [Sensor ingestion](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs): `src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs`
- [Sensor event contract](https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Messages/Sensordatareceived.cs): `src/Shared/AgroSolutions.Shared.Messages/Sensordatareceived.cs`
- **RabbitMQ**
- [Alert processing](https://github.com/alanq139/agrosolutions/blob/main/src/Services/AgroSolutions.AlertService/Worker.cs): `src/Services/AgroSolutions.AlertService/Worker.cs`
- **Alert SQL database**
- [Shared configuration](https://github.com/alanq139/agrosolutions/blob/main/src/Shared/AgroSolutions.Shared.Common/Configuration.cs): `src/Shared/AgroSolutions.Shared.Common/Configuration.cs`

### Monitoring

- [Prometheus](https://github.com/alanq139/agrosolutions/blob/main/prometheus.yml): `prometheus.yml`
- [Grafana](https://github.com/alanq139/agrosolutions/blob/main/k8s/grafana-deployment.yaml): `k8s/grafana-deployment.yaml`

### Other components

- **Client**

## Connections

- Client → API gateway: sends requests (evidence: `README.md`)
- API gateway → Authentication: routes requests (evidence: `README.md`)
- API gateway → Properties and plots: routes requests (evidence: `README.md`)
- API gateway → Sensor ingestion: routes requests (evidence: `README.md`)
- Authentication → Identity context: uses identity store
- Identity context → Identity SQL database: persists users
- Properties and plots → Farm data model: uses data model (evidence: `src/Services/AgroSolutions.PropertyService/Controllers/PropertyserviceControllers.cs`)
- Farm data model → Farm SQL database: maps entities
- Sensor ingestion → Sensor event contract: creates event (evidence: `src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs`)
- Sensor ingestion → RabbitMQ: publishes event (evidence: `src/Services/AgroSolutions.SensorIngestionService/Controller/SensoringestionserviceController.cs`)
- RabbitMQ → Alert processing: dispatches events
- Alert processing → Alert SQL database: stores alerts
- Prometheus → Grafana: provides monitoring
