# ernanesa/denguewatch architecture

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

- Interactive diagram: https://gitdiagram.com/ernanesa/denguewatch
- Repository: https://github.com/ernanesa/denguewatch

## Overview

DengueWatch is a .NET REST API for reporting and managing geolocated dengue cases, with JWT-protected mutations and MongoDB persistence. The main workflow is a client submitting HTTP requests: case requests are validated and handled by the cases controller and service, which stores GeoJSON-backed documents and returns case responses; login looks up a user and issues a JWT for subsequent authorized mutations. The API also provides development demo-user seeding, health checks, and Scalar/OpenAPI documentation. The README documents several capabilities beyond the sampled excerpts; edges for those are limited to documented relationships.

Main entry points: [`api/Program.cs`](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs) (ASP.NET API host), [`api/Controllers/AuthController.cs`](https://github.com/ernanesa/denguewatch/blob/main/api/Controllers/AuthController.cs) (Login route), [`api/Services/CasesService.cs`](https://github.com/ernanesa/denguewatch/blob/main/api/Services/CasesService.cs) (Case service), [`api/Services/TokenService.cs`](https://github.com/ernanesa/denguewatch/blob/main/api/Services/TokenService.cs) (JWT issuance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API runtime"]
  node_host["ASP.NET API host<br/>[Program.cs]"]
  node_case_routes["Case routes<br/>[CasesController.cs]"]
  node_auth_routes["Login route<br/>[AuthController.cs]"]
end

subgraph group_cases["Case reporting"]
  node_case_requests["Case request DTOs"]
  node_case_service["Case service<br/>[CasesService.cs]"]
  node_case_document["Case document<br/>[CaseDocument.cs]"]
  node_case_response["Case response<br/>[CaseResponse.cs]"]
  node_mongo[("MongoDB")]
end

subgraph group_identity["Authentication"]
  node_login_request["Login request<br/>[LoginRequest.cs]"]
  node_users_service["User lookup<br/>[UsersService.cs]"]
  node_user_document["User document<br/>[UserDocument.cs]"]
  node_password_hashing["Password hashing<br/>[Program.cs]"]
  node_token_service["JWT issuance<br/>[TokenService.cs]"]
  node_login_response["Login response<br/>[LoginResponse.cs]"]
  node_jwt_auth["JWT validation<br/>[Program.cs]"]
  node_demo_seeder["Demo user seeder<br/>[DevUserSeeder.cs]"]
end

subgraph group_support["Configuration and docs"]
  node_mongo_settings["Mongo settings<br/>[MongoSettings.cs]"]
  node_jwt_settings["JWT settings<br/>[JwtSettings.cs]"]
  node_demo_settings["Demo-user settings"]
  node_api_docs["Scalar and OpenAPI<br/>[Program.cs]"]
  node_health["Health endpoint<br/>[Program.cs]"]
end

node_client(("Client"))

node_client -->|"sends HTTP"| node_host
node_host -->|"maps routes"| node_case_routes
node_host -->|"maps routes"| node_auth_routes
node_case_routes -->|"calls service"| node_case_service
node_case_routes -->|"binds requests"| node_case_requests
node_case_service -->|"maps documents"| node_case_document
node_case_service -->|"reads and writes"| node_mongo
node_case_service -->|"returns responses"| node_case_response
node_auth_routes -->|"accepts credentials"| node_login_request
node_auth_routes -->|"looks up user"| node_users_service
node_auth_routes -->|"requests token"| node_token_service
node_users_service -->|"returns user"| node_user_document
node_token_service -->|"uses claims"| node_user_document
node_token_service -->|"reads settings"| node_jwt_settings
node_token_service -->|"returns token"| node_login_response
node_host -->|"configures middleware"| node_jwt_auth
node_host -->|"registers hasher"| node_password_hashing
node_host -->|"runs when enabled"| node_demo_seeder
node_demo_seeder -->|"seeds user"| node_user_document
node_host -->|"binds options"| node_mongo_settings
node_host -->|"binds options"| node_jwt_settings
node_host -->|"binds options"| node_demo_settings
node_host -->|"connects database"| node_mongo
node_host -->|"maps in development"| node_api_docs
node_client -->|"browses docs"| node_api_docs
node_host -->|"maps endpoint"| node_health

click node_host "https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs"
click node_case_routes "https://github.com/ernanesa/denguewatch/blob/main/api/Controllers/CasesController.cs"
click node_auth_routes "https://github.com/ernanesa/denguewatch/blob/main/api/Controllers/AuthController.cs"
click node_case_requests "https://github.com/ernanesa/denguewatch/tree/main/api/DTOs/Cases"
click node_case_service "https://github.com/ernanesa/denguewatch/blob/main/api/Services/CasesService.cs"
click node_case_document "https://github.com/ernanesa/denguewatch/blob/main/api/Data/Documents/CaseDocument.cs"
click node_case_response "https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Cases/CaseResponse.cs"
click node_login_request "https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Auth/LoginRequest.cs"
click node_users_service "https://github.com/ernanesa/denguewatch/blob/main/api/Services/UsersService.cs"
click node_user_document "https://github.com/ernanesa/denguewatch/blob/main/api/Data/Documents/UserDocument.cs"
click node_password_hashing "https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs"
click node_token_service "https://github.com/ernanesa/denguewatch/blob/main/api/Services/TokenService.cs"
click node_login_response "https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Auth/LoginResponse.cs"
click node_jwt_auth "https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs"
click node_demo_seeder "https://github.com/ernanesa/denguewatch/blob/main/api/Services/DevUserSeeder.cs"
click node_mongo_settings "https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/MongoSettings.cs"
click node_jwt_settings "https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/JwtSettings.cs"
click node_demo_settings "https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/DemoUserSettings.cs"
click node_api_docs "https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs"
click node_health "https://github.com/ernanesa/denguewatch/blob/main/api/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_host,node_case_routes,node_auth_routes,node_client toneBlue
class node_case_requests,node_case_service,node_case_document,node_case_response,node_mongo toneAmber
class node_login_request,node_users_service,node_user_document,node_password_hashing,node_token_service,node_login_response,node_jwt_auth,node_demo_seeder toneMint
class node_mongo_settings,node_jwt_settings,node_demo_settings,node_api_docs,node_health toneRose
```

## Components

### API runtime

- [ASP.NET API host](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs): `api/Program.cs`
- [Case routes](https://github.com/ernanesa/denguewatch/blob/main/api/Controllers/CasesController.cs): `api/Controllers/CasesController.cs`
- [Login route](https://github.com/ernanesa/denguewatch/blob/main/api/Controllers/AuthController.cs): `api/Controllers/AuthController.cs`

### Case reporting

- [Case request DTOs](https://github.com/ernanesa/denguewatch/tree/main/api/DTOs/Cases): `api/DTOs/Cases`
- [Case service](https://github.com/ernanesa/denguewatch/blob/main/api/Services/CasesService.cs): `api/Services/CasesService.cs`
- [Case document](https://github.com/ernanesa/denguewatch/blob/main/api/Data/Documents/CaseDocument.cs): `api/Data/Documents/CaseDocument.cs`
- [Case response](https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Cases/CaseResponse.cs): `api/DTOs/Cases/CaseResponse.cs`
- **MongoDB**

### Authentication

- [Login request](https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Auth/LoginRequest.cs): `api/DTOs/Auth/LoginRequest.cs`
- [User lookup](https://github.com/ernanesa/denguewatch/blob/main/api/Services/UsersService.cs): `api/Services/UsersService.cs`
- [User document](https://github.com/ernanesa/denguewatch/blob/main/api/Data/Documents/UserDocument.cs): `api/Data/Documents/UserDocument.cs`
- [Password hashing](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs): `api/Program.cs`
- [JWT issuance](https://github.com/ernanesa/denguewatch/blob/main/api/Services/TokenService.cs): `api/Services/TokenService.cs`
- [Login response](https://github.com/ernanesa/denguewatch/blob/main/api/DTOs/Auth/LoginResponse.cs): `api/DTOs/Auth/LoginResponse.cs`
- [JWT validation](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs): `api/Program.cs`
- [Demo user seeder](https://github.com/ernanesa/denguewatch/blob/main/api/Services/DevUserSeeder.cs): `api/Services/DevUserSeeder.cs`

### Configuration and docs

- [Mongo settings](https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/MongoSettings.cs): `api/Configuration/MongoSettings.cs`
- [JWT settings](https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/JwtSettings.cs): `api/Configuration/JwtSettings.cs`
- [Demo-user settings](https://github.com/ernanesa/denguewatch/blob/main/api/Configuration/DemoUserSettings.cs): `api/Configuration/DemoUserSettings.cs`
- [Scalar and OpenAPI](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs): `api/Program.cs`
- [Health endpoint](https://github.com/ernanesa/denguewatch/blob/main/api/Program.cs): `api/Program.cs`

### Other components

- **Client**

## Connections

- Client → ASP.NET API host: sends HTTP (evidence: `README.md`)
- ASP.NET API host → Case routes: maps routes (evidence: `api/Program.cs`)
- ASP.NET API host → Login route: maps routes (evidence: `api/Program.cs`)
- Case routes → Case service: calls service (evidence: `README.md`)
- Case routes → Case request DTOs: binds requests (evidence: `api/Controllers/CasesController.cs`)
- Case service → Case document: maps documents (evidence: `api/Services/CasesService.cs`)
- Case service → MongoDB: reads and writes (evidence: `api/Services/CasesService.cs`)
- Case service → Case response: returns responses (evidence: `api/Services/CasesService.cs`)
- Login route → Login request: accepts credentials (evidence: `api/Controllers/AuthController.cs`)
- Login route → User lookup: looks up user (evidence: `api/Controllers/AuthController.cs`)
- Login route → JWT issuance: requests token (evidence: `api/Controllers/AuthController.cs`)
- User lookup → User document: returns user (evidence: `api/Services/UsersService.cs`)
- JWT issuance → User document: uses claims (evidence: `api/Services/TokenService.cs`)
- JWT issuance → JWT settings: reads settings (evidence: `api/Services/TokenService.cs`)
- JWT issuance → Login response: returns token (evidence: `api/Services/TokenService.cs`)
- ASP.NET API host → JWT validation: configures middleware (evidence: `api/Program.cs`)
- ASP.NET API host → Password hashing: registers hasher (evidence: `api/Program.cs`)
- ASP.NET API host → Demo user seeder: runs when enabled (evidence: `api/Program.cs`)
- Demo user seeder → User document: seeds user (evidence: `api/Services/DevUserSeeder.cs`)
- ASP.NET API host → Mongo settings: binds options (evidence: `api/Program.cs`)
- ASP.NET API host → JWT settings: binds options (evidence: `api/Program.cs`)
- ASP.NET API host → Demo-user settings: binds options (evidence: `api/Program.cs`)
- ASP.NET API host → MongoDB: connects database (evidence: `api/Program.cs`)
- ASP.NET API host → Scalar and OpenAPI: maps in development (evidence: `api/Program.cs`)
- Client → Scalar and OpenAPI: browses docs (evidence: `README.md`)
- ASP.NET API host → Health endpoint: maps endpoint (evidence: `api/Program.cs`)
