# abbaskhudayer/clarus architecture

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

- Interactive diagram: https://gitdiagram.com/abbaskhudayer/clarus
- Repository: https://github.com/abbaskhudayer/clarus

## Overview

Clarus verifies forecasts from three providers against SMHI observations, preserves raw and structured data, evaluates comparable horizons, and publishes results through a Web API to a React dashboard. The graph separates collection, evaluation, persistence, API, and presentation. The README documents the overall flow and major capabilities; source-index references and excerpts support selected implementation links, while unsampled wiring is omitted where its caller is unclear.

Main entry points: [`backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs`](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs) (MongoDB access), [`backend/src/WebApi/Controllers`](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/WebApi/Controllers) (REST controllers), [`frontend/src/app/ClarusRouter.tsx`](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/app/ClarusRouter.tsx) (Page router), [`backend/src/Application/Evaluation/ForecastObservationMatchingService.cs`](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastObservationMatchingService.cs) (Forecast matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Data collection"]
  node_scheduler["Worker scheduler"]
  node_collection_jobs["Collection jobs"]
  node_forecast_collection["Forecast collection"]
  node_observation_collection["Observation collection"]
  node_forecast_sources["Forecast providers"]
  node_observation_source["SMHI observations"]
end

subgraph group_evaluation["Forecast evaluation"]
  node_matching["Forecast matching"]
  node_scoring["Accuracy scoring"]
  node_evaluation_orchestrator["Evaluation publishing"]
  node_history["Accuracy history"]
  node_comparisons["Forecast comparisons"]
  node_ranking["Source rankings"]
end

subgraph group_persistence["MongoDB persistence"]
  node_raw_store[("Raw responses")]
  node_forecast_store[("Forecast snapshots")]
  node_observation_store[("Weather observations")]
  node_result_store[("Published results")]
  node_comparison_store[("Comparison records")]
  node_mongo_database["MongoDB access"]
end

subgraph group_api["Web API"]
  node_controllers["REST controllers"]
  node_published_reader["Published result reader"]
  node_web_api["Web API host<br/>[Program.cs]"]
end

subgraph group_frontend["Frontend"]
  node_router["Page router<br/>[ClarusRouter.tsx]"]
  node_overview["Overview dashboard<br/>[OverviewPage.tsx]"]
  node_ranking_page["Rankings view<br/>[RankingsPage.tsx]"]
  node_history_page["History charts"]
  node_comparison_page["Comparison view"]
  node_api_client["Weather API client<br/>[weatherApi.ts]"]
end

node_user(("Dashboard user"))
node_weather_providers["Weather APIs"]
node_mongodb[("MongoDB")]

node_scheduler -->|"runs"| node_collection_jobs
node_collection_jobs -->|"collects forecasts"| node_forecast_collection
node_collection_jobs -->|"collects observations"| node_observation_collection
node_forecast_collection -->|"requests forecasts"| node_forecast_sources
node_observation_collection -.->|"requests observations"| node_observation_source
node_weather_providers -->|"provides data"| node_forecast_sources
node_weather_providers -->|"provides data"| node_observation_source
node_forecast_collection -->|"preserves responses"| node_raw_store
node_forecast_collection -->|"stores snapshots"| node_forecast_store
node_observation_collection -->|"stores observations"| node_observation_store
node_evaluation_orchestrator -->|"requests matches"| node_matching
node_matching -->|"reads forecasts"| node_forecast_store
node_matching -->|"reads observations"| node_observation_store
node_evaluation_orchestrator -.->|"scores matches"| node_scoring
node_evaluation_orchestrator -->|"stages and publishes"| node_result_store
node_evaluation_orchestrator -->|"stages comparisons"| node_comparison_store
node_history -->|"requests matches"| node_matching
node_history -.->|"scores windows"| node_scoring
node_comparisons -.->|"requests matches"| node_matching
node_ranking -.->|"reads published scores"| node_result_store
node_mongo_database -->|"opens collections"| node_mongodb
node_raw_store -.->|"uses"| node_mongo_database
node_forecast_store -.->|"uses"| node_mongo_database
node_observation_store -.->|"uses"| node_mongo_database
node_result_store -->|"uses"| node_mongo_database
node_comparison_store -.->|"uses"| node_mongo_database
node_web_api -->|"hosts"| node_controllers
node_controllers -->|"reads published results"| node_published_reader
node_controllers -->|"serves history"| node_history
node_controllers -->|"serves comparisons"| node_comparisons
node_controllers -->|"serves rankings"| node_ranking
node_user -->|"browses"| node_router
node_router -->|"routes to"| node_overview
node_router -->|"routes to"| node_ranking_page
node_router -->|"routes to"| node_history_page
node_router -->|"routes to"| node_comparison_page
node_ranking_page -->|"fetches results"| node_api_client
node_api_client -.->|"requests data"| node_web_api

click node_scheduler "https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Worker/Scheduling"
click node_collection_jobs "https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Worker/Jobs"
click node_forecast_collection "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/DataCollection/CollectForecastsService.cs"
click node_observation_collection "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/DataCollection/CollectObservationsService.cs"
click node_forecast_sources "https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Infrastructure/WeatherApis"
click node_observation_source "https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Infrastructure/WeatherApis/Smhi"
click node_matching "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastObservationMatchingService.cs"
click node_scoring "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastAccuracyScoringService.cs"
click node_evaluation_orchestrator "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastEvaluationService.cs"
click node_history "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/AccuracyHistoryService.cs"
click node_comparisons "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastComparisonService.cs"
click node_ranking "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/SourceRankingService.cs"
click node_raw_store "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoRawWeatherApiResponseRepository.cs"
click node_forecast_store "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastRepository.cs"
click node_observation_store "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoObservationRepository.cs"
click node_result_store "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastAccuracyRepository.cs"
click node_comparison_store "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastComparisonRepository.cs"
click node_mongo_database "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs"
click node_controllers "https://github.com/abbaskhudayer/clarus/tree/main/backend/src/WebApi/Controllers"
click node_published_reader "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/PublishedEvaluationReader.cs"
click node_web_api "https://github.com/abbaskhudayer/clarus/blob/main/backend/src/WebApi/Program.cs"
click node_router "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/app/ClarusRouter.tsx"
click node_overview "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/OverviewPage.tsx"
click node_ranking_page "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/RankingsPage.tsx"
click node_history_page "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/AccuracyHistoryPage.tsx"
click node_comparison_page "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/ForecastComparisonPage.tsx"
click node_api_client "https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/shared/api/weatherApi.ts"

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_scheduler,node_collection_jobs,node_forecast_collection,node_observation_collection,node_forecast_sources,node_observation_source,node_user toneBlue
class node_matching,node_scoring,node_evaluation_orchestrator,node_history,node_comparisons,node_ranking,node_mongodb toneAmber
class node_raw_store,node_forecast_store,node_observation_store,node_result_store,node_comparison_store,node_mongo_database,node_weather_providers toneMint
class node_controllers,node_published_reader,node_web_api toneRose
class node_router,node_overview,node_ranking_page,node_history_page,node_comparison_page,node_api_client toneIndigo
```

## Components

### Data collection

- [Worker scheduler](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Worker/Scheduling): `backend/src/Worker/Scheduling`
- [Collection jobs](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Worker/Jobs): `backend/src/Worker/Jobs`
- [Forecast collection](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/DataCollection/CollectForecastsService.cs): `backend/src/Application/DataCollection/CollectForecastsService.cs`
- [Observation collection](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/DataCollection/CollectObservationsService.cs): `backend/src/Application/DataCollection/CollectObservationsService.cs`
- [Forecast providers](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Infrastructure/WeatherApis): `backend/src/Infrastructure/WeatherApis`
- [SMHI observations](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/Infrastructure/WeatherApis/Smhi): `backend/src/Infrastructure/WeatherApis/Smhi`

### Forecast evaluation

- [Forecast matching](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastObservationMatchingService.cs): `backend/src/Application/Evaluation/ForecastObservationMatchingService.cs`
- [Accuracy scoring](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastAccuracyScoringService.cs): `backend/src/Application/Evaluation/ForecastAccuracyScoringService.cs`
- [Evaluation publishing](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastEvaluationService.cs): `backend/src/Application/Evaluation/ForecastEvaluationService.cs`
- [Accuracy history](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/AccuracyHistoryService.cs): `backend/src/Application/Evaluation/AccuracyHistoryService.cs`
- [Forecast comparisons](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/ForecastComparisonService.cs): `backend/src/Application/Evaluation/ForecastComparisonService.cs`
- [Source rankings](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/SourceRankingService.cs): `backend/src/Application/Evaluation/SourceRankingService.cs`

### MongoDB persistence

- [Raw responses](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoRawWeatherApiResponseRepository.cs): `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoRawWeatherApiResponseRepository.cs`
- [Forecast snapshots](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastRepository.cs): `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastRepository.cs`
- [Weather observations](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoObservationRepository.cs): `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoObservationRepository.cs`
- [Published results](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastAccuracyRepository.cs): `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastAccuracyRepository.cs`
- [Comparison records](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastComparisonRepository.cs): `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastComparisonRepository.cs`
- [MongoDB access](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs): `backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs`

### Web API

- [REST controllers](https://github.com/abbaskhudayer/clarus/tree/main/backend/src/WebApi/Controllers): `backend/src/WebApi/Controllers`
- [Published result reader](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/Application/Evaluation/PublishedEvaluationReader.cs): `backend/src/Application/Evaluation/PublishedEvaluationReader.cs`
- [Web API host](https://github.com/abbaskhudayer/clarus/blob/main/backend/src/WebApi/Program.cs): `backend/src/WebApi/Program.cs`

### Frontend

- [Page router](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/app/ClarusRouter.tsx): `frontend/src/app/ClarusRouter.tsx`
- [Overview dashboard](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/OverviewPage.tsx): `frontend/src/pages/OverviewPage.tsx`
- [Rankings view](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/RankingsPage.tsx): `frontend/src/pages/RankingsPage.tsx`
- [History charts](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/AccuracyHistoryPage.tsx): `frontend/src/pages/AccuracyHistoryPage.tsx`
- [Comparison view](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/pages/ForecastComparisonPage.tsx): `frontend/src/pages/ForecastComparisonPage.tsx`
- [Weather API client](https://github.com/abbaskhudayer/clarus/blob/main/frontend/src/shared/api/weatherApi.ts): `frontend/src/shared/api/weatherApi.ts`

### Other components

- **Dashboard user**
- **Weather APIs**
- **MongoDB**

## Connections

- Worker scheduler → Collection jobs: runs (evidence: `README.md`)
- Collection jobs → Forecast collection: collects forecasts (evidence: `README.md`)
- Collection jobs → Observation collection: collects observations (evidence: `README.md`)
- Forecast collection → Forecast providers: requests forecasts (evidence: `backend/src/Application/DataCollection/CollectForecastsService.cs`)
- Observation collection → SMHI observations: requests observations (evidence: `README.md`)
- Weather APIs → Forecast providers: provides data (evidence: `README.md`)
- Weather APIs → SMHI observations: provides data (evidence: `README.md`)
- Forecast collection → Raw responses: preserves responses (evidence: `backend/src/Application/DataCollection/CollectForecastsService.cs`)
- Forecast collection → Forecast snapshots: stores snapshots (evidence: `backend/src/Application/DataCollection/CollectForecastsService.cs`)
- Observation collection → Weather observations: stores observations (evidence: `README.md`)
- Evaluation publishing → Forecast matching: requests matches (evidence: `backend/src/Application/Evaluation/ForecastEvaluationService.cs`)
- Forecast matching → Forecast snapshots: reads forecasts (evidence: `backend/src/Application/Evaluation/ForecastObservationMatchingService.cs`)
- Forecast matching → Weather observations: reads observations (evidence: `backend/src/Application/Evaluation/ForecastObservationMatchingService.cs`)
- Evaluation publishing → Accuracy scoring: scores matches
- Evaluation publishing → Published results: stages and publishes (evidence: `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastAccuracyRepository.cs`)
- Evaluation publishing → Comparison records: stages comparisons (evidence: `backend/src/Application/Evaluation/ForecastEvaluationService.cs`)
- Accuracy history → Forecast matching: requests matches (evidence: `backend/src/Application/Evaluation/AccuracyHistoryService.cs`)
- Accuracy history → Accuracy scoring: scores windows (evidence: `backend/src/Application/Evaluation/AccuracyHistoryService.cs`)
- Forecast comparisons → Forecast matching: requests matches (evidence: `backend/src/Application/Evaluation/ForecastComparisonService.cs`)
- Source rankings → Published results: reads published scores
- MongoDB access → MongoDB: opens collections (evidence: `backend/src/Infrastructure/Persistence/MongoDb/ClarusMongoDatabase.cs`)
- Raw responses → MongoDB access: uses
- Forecast snapshots → MongoDB access: uses (evidence: `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastRepository.cs`)
- Weather observations → MongoDB access: uses
- Published results → MongoDB access: uses (evidence: `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastAccuracyRepository.cs`)
- Comparison records → MongoDB access: uses (evidence: `backend/src/Infrastructure/Persistence/MongoDb/Repositories/MongoForecastComparisonRepository.cs`)
- Web API host → REST controllers: hosts (evidence: `README.md`)
- REST controllers → Published result reader: reads published results (evidence: `backend/src/WebApi/Controllers/AccuracyHistoryController.cs`)
- REST controllers → Accuracy history: serves history (evidence: `backend/src/WebApi/Controllers/AccuracyHistoryController.cs`)
- REST controllers → Forecast comparisons: serves comparisons (evidence: `backend/src/WebApi/Controllers/ForecastComparisonsController.cs`)
- REST controllers → Source rankings: serves rankings (evidence: `backend/src/WebApi/Controllers/SourceRankingsController.cs`)
- Dashboard user → Page router: browses (evidence: `README.md`)
- Page router → Overview dashboard: routes to (evidence: `frontend/src/app/ClarusRouter.tsx`)
- Page router → Rankings view: routes to (evidence: `frontend/src/app/ClarusRouter.tsx`)
- Page router → History charts: routes to (evidence: `frontend/src/app/ClarusRouter.tsx`)
- Page router → Comparison view: routes to (evidence: `frontend/src/app/ClarusRouter.tsx`)
- Rankings view → Weather API client: fetches results (evidence: `frontend/src/pages/RankingsPage.tsx`)
- Weather API client → Web API host: requests data (evidence: `README.md`)
