# malves4018/natureprotector architecture

> Architecture diagram of the GitHub repository malves4018/natureprotector, 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/malves4018/natureprotector
- Repository: https://github.com/malves4018/natureprotector

## Overview

NatureProtector is a local technical baseline for simulating sensor readings and processing them into operational fire-risk views. The principal journey starts when an operator launches a scenario in the webUI: the backoffice orchestrates a Simulator.Host run, readings travel through RabbitMQ, and Prevention.Host durably ingests and processes them into risk assessments and projections. PostgreSQL holds control, pipeline, and projection state; InfluxDB stores telemetry, with Grafana dashboards for support. The graph combines README-documented runtime links with source-index and excerpt evidence; some internal processing links are documented or referenced but not fully shown in the excerpts.

Main entry points: [`src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs) (Risk pipeline), [`src/NatureProtector.Backoffice.Api/Program.cs`](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Backoffice.Api/Program.cs) (Backoffice API), [`src/NatureProtector.Prevention.Host/Program.cs`](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Program.cs) (Prevention host), [`webUI/src/app/App.tsx`](https://github.com/malves4018/natureprotector/blob/master/webUI/src/app/App.tsx) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Run control"]
  node_backoffice["Backoffice API<br/>[Program.cs]"]
  node_orchestrator["Run orchestrator"]
  node_simulator["Scenario simulator"]
end

subgraph group_processing["Reading processing"]
  node_rabbit["RabbitMQ"]
  node_prevention["Prevention host<br/>[Program.cs]"]
  node_inbox[("Durable inbox")]
  node_pipeline["Risk pipeline"]
  node_normalize["Reading normalization"]
  node_eligibility["Risk eligibility"]
  node_scoring["Risk scoring"]
  node_daily["Daily cell state<br/>[DailyCellState.cs]"]
end

subgraph group_persistence["Data and telemetry"]
  node_postgres[("PostgreSQL")]
  node_projection[("Operational projections")]
  node_influx[("InfluxDB telemetry")]
end

subgraph group_experience["Operator experience"]
  node_webui["Web UI<br/>[App.tsx]"]
  node_pipelineui["Pipeline view<br/>[PipelinePage.tsx]"]
  node_grafana["Grafana dashboards"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_webui
node_webui -->|"requests operations"| node_backoffice
node_backoffice -->|"starts runs"| node_orchestrator
node_orchestrator -->|"launches"| node_simulator
node_simulator -->|"publishes readings"| node_rabbit
node_rabbit -->|"transports events"| node_prevention
node_prevention -->|"persists events"| node_inbox
node_prevention -->|"processes events"| node_pipeline
node_pipeline -->|"normalizes event"| node_normalize
node_pipeline -->|"checks eligibility"| node_eligibility
node_pipeline -->|"scores risk"| node_scoring
node_pipeline -->|"uses daily state"| node_daily
node_pipeline -->|"writes projections"| node_projection
node_pipeline -->|"writes telemetry"| node_influx
node_inbox -->|"stores inbox"| node_postgres
node_projection -->|"stores projection state"| node_postgres
node_backoffice -->|"reads control state"| node_postgres
node_influx -->|"feeds dashboards"| node_grafana
node_webui -->|"routes to"| node_pipelineui
node_pipelineui -->|"displays runtime data"| node_backoffice

click node_webui "https://github.com/malves4018/natureprotector/blob/master/webUI/src/app/App.tsx"
click node_pipelineui "https://github.com/malves4018/natureprotector/blob/master/webUI/src/app/pages/PipelinePage.tsx"
click node_backoffice "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Backoffice.Api/Program.cs"
click node_orchestrator "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Backoffice.Api/RuntimeOrchestration/CloudRunJobRuntimeRunOrchestrator.cs"
click node_simulator "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Simulator.Host/Services/ReadingGenerationService.cs"
click node_prevention "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Program.cs"
click node_inbox "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Processing/PostgresReadingEventInbox.cs"
click node_pipeline "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs"
click node_normalize "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Readings/NormalizedReading.cs"
click node_eligibility "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/RiskEligibilityService.cs"
click node_scoring "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/SimpleRiskScoringService.cs"
click node_daily "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/DailyCellState.cs"
click node_postgres "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Infrastructure.Postgres/Persistence/NatureProtectorControlDbContext.cs"
click node_projection "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Projection/PostgresAreaOperationalProjectionStore.cs"
click node_influx "https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Infrastructure.Influx/Services/InfluxWriteService.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_backoffice,node_orchestrator,node_simulator toneBlue
class node_rabbit,node_prevention,node_inbox,node_pipeline,node_normalize,node_eligibility,node_scoring,node_daily toneAmber
class node_postgres,node_projection,node_influx toneMint
class node_webui,node_pipelineui,node_grafana toneRose
class node_operator toneIndigo
```

## Components

### Run control

- [Backoffice API](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Backoffice.Api/Program.cs): `src/NatureProtector.Backoffice.Api/Program.cs`
- [Run orchestrator](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Backoffice.Api/RuntimeOrchestration/CloudRunJobRuntimeRunOrchestrator.cs): `src/NatureProtector.Backoffice.Api/RuntimeOrchestration/CloudRunJobRuntimeRunOrchestrator.cs`
- [Scenario simulator](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Simulator.Host/Services/ReadingGenerationService.cs): `src/NatureProtector.Simulator.Host/Services/ReadingGenerationService.cs`

### Reading processing

- **RabbitMQ**
- [Prevention host](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Program.cs): `src/NatureProtector.Prevention.Host/Program.cs`
- [Durable inbox](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Processing/PostgresReadingEventInbox.cs): `src/NatureProtector.Prevention.Host/Processing/PostgresReadingEventInbox.cs`
- [Risk pipeline](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs): `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`
- [Reading normalization](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Readings/NormalizedReading.cs): `src/NatureProtector.Prevention/Readings/NormalizedReading.cs`
- [Risk eligibility](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/RiskEligibilityService.cs): `src/NatureProtector.Prevention/Risk/RiskEligibilityService.cs`
- [Risk scoring](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/SimpleRiskScoringService.cs): `src/NatureProtector.Prevention/Risk/SimpleRiskScoringService.cs`
- [Daily cell state](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention/Risk/DailyCellState.cs): `src/NatureProtector.Prevention/Risk/DailyCellState.cs`

### Data and telemetry

- [PostgreSQL](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Infrastructure.Postgres/Persistence/NatureProtectorControlDbContext.cs): `src/NatureProtector.Infrastructure.Postgres/Persistence/NatureProtectorControlDbContext.cs`
- [Operational projections](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Prevention.Host/Projection/PostgresAreaOperationalProjectionStore.cs): `src/NatureProtector.Prevention.Host/Projection/PostgresAreaOperationalProjectionStore.cs`
- [InfluxDB telemetry](https://github.com/malves4018/natureprotector/blob/master/src/NatureProtector.Infrastructure.Influx/Services/InfluxWriteService.cs): `src/NatureProtector.Infrastructure.Influx/Services/InfluxWriteService.cs`

### Operator experience

- [Web UI](https://github.com/malves4018/natureprotector/blob/master/webUI/src/app/App.tsx): `webUI/src/app/App.tsx`
- [Pipeline view](https://github.com/malves4018/natureprotector/blob/master/webUI/src/app/pages/PipelinePage.tsx): `webUI/src/app/pages/PipelinePage.tsx`
- **Grafana dashboards**

### Other components

- **Operator**

## Connections

- Operator → Web UI: uses (evidence: `README.md`)
- Web UI → Backoffice API: requests operations (evidence: `README.md`)
- Backoffice API → Run orchestrator: starts runs (evidence: `README.md`)
- Run orchestrator → Scenario simulator: launches (evidence: `README.md`)
- Scenario simulator → RabbitMQ: publishes readings (evidence: `README.md`)
- RabbitMQ → Prevention host: transports events (evidence: `README.md`)
- Prevention host → Durable inbox: persists events (evidence: `src/NatureProtector.Prevention.Host/Program.cs`)
- Prevention host → Risk pipeline: processes events (evidence: `src/NatureProtector.Prevention.Host/Program.cs`)
- Risk pipeline → Reading normalization: normalizes event (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Risk pipeline → Risk eligibility: checks eligibility (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Risk pipeline → Risk scoring: scores risk (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Risk pipeline → Daily cell state: uses daily state (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Risk pipeline → Operational projections: writes projections (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Risk pipeline → InfluxDB telemetry: writes telemetry (evidence: `src/NatureProtector.Prevention.Host/Processing/ReadingRiskPipeline.cs`)
- Durable inbox → PostgreSQL: stores inbox
- Operational projections → PostgreSQL: stores projection state (evidence: `README.md`)
- Backoffice API → PostgreSQL: reads control state (evidence: `README.md`)
- InfluxDB telemetry → Grafana dashboards: feeds dashboards (evidence: `README.md`)
- Web UI → Pipeline view: routes to (evidence: `webUI/src/app/App.tsx`)
- Pipeline view → Backoffice API: displays runtime data (evidence: `README.md`)
