# iamnoseh/marathon architecture

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

## Overview

This is a .NET API for user accounts, a multi-category marathon scoring platform, and user reviews. The main workflow is an HTTP request to a controller, which dispatches an application command or query and returns its response. Major branches cover authentication and profiles, marathon attempts and rankings, reviews, and administration. Persistence is abstracted by an application context and implemented with Entity Framework Core. The source index and excerpts support the shown dispatch and selected data-access links; unsampled handlers are grouped by feature, and their internal calls are not inferred.

Main entry points: [`Infrastructure/Data/ApplicationDbContext.cs`](https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Data/ApplicationDbContext.cs) (Application database), [`Application/Interfaces/IApplicationDbContext.cs`](https://github.com/iamnoseh/marathon/blob/main/Application/Interfaces/IApplicationDbContext.cs) (Database contract), [`WebApi/Controllers/AuthController.cs`](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/AuthController.cs) (Auth API), [`WebApi/Controllers/ReviewController.cs`](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/ReviewController.cs) (Review API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_auth_api["Auth API<br/>[AuthController.cs]"]
  node_marathon_api["Marathon API"]
  node_review_api["Review API"]
  node_admin_api["Admin API<br/>[AdminController.cs]"]
end

subgraph group_application["Application Features"]
  node_auth_features["Auth features"]
  node_admin_features["Admin features"]
  node_marathon_features["Marathon features"]
  node_review_features["Review features"]
  node_db_contract["Database contract"]
  node_responses["API responses<br/>[Response.cs]"]
end

subgraph group_domain["Domain Model"]
  node_user_model["User identity<br/>[ApplicationUser.cs]"]
  node_score_models["Marathon results<br/>[BestResult.cs]"]
  node_attempt_model["Marathon attempts<br/>[MarathonAttempt.cs]"]
  node_token_model["Refresh tokens<br/>[RefreshToken.cs]"]
  node_review_model["Review entity<br/>[Review.cs]"]
end

subgraph group_infrastructure["Infrastructure"]
  node_db[("Application database")]
  node_file_storage["Profile file storage"]
  node_jwt_service["JWT service<br/>[JwtTokenService.cs]"]
end

node_user(("User"))
node_admin(("Administrator"))

node_user -->|"uses"| node_auth_api
node_user -->|"submits and views"| node_marathon_api
node_user -->|"submits and reads"| node_review_api
node_admin -->|"manages users"| node_admin_api
node_admin -->|"moderates reviews"| node_review_api
node_auth_api -->|"dispatches"| node_auth_features
node_auth_api -->|"saves profile files"| node_file_storage
node_marathon_api -->|"dispatches"| node_marathon_features
node_review_api -->|"dispatches"| node_review_features
node_admin_api -->|"dispatches"| node_admin_features
node_auth_features -->|"reads results"| node_db_contract
node_marathon_features -->|"reads rankings"| node_db_contract
node_review_features -->|"reads and writes"| node_db_contract
node_db -->|"implements"| node_db_contract
node_db -->|"maps"| node_user_model
node_db -->|"maps"| node_score_models
node_db -->|"maps"| node_attempt_model
node_db -->|"maps"| node_token_model
node_db -->|"maps"| node_review_model

click node_auth_api "https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/AuthController.cs"
click node_marathon_api "https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/MarathonController.cs"
click node_review_api "https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/ReviewController.cs"
click node_admin_api "https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/AdminController.cs"
click node_auth_features "https://github.com/iamnoseh/marathon/tree/main/Application/Features/Auth"
click node_admin_features "https://github.com/iamnoseh/marathon/tree/main/Application/Features/Admin"
click node_marathon_features "https://github.com/iamnoseh/marathon/tree/main/Application/Features/Marathon"
click node_review_features "https://github.com/iamnoseh/marathon/tree/main/Application/Features/Reviews"
click node_db_contract "https://github.com/iamnoseh/marathon/blob/main/Application/Interfaces/IApplicationDbContext.cs"
click node_responses "https://github.com/iamnoseh/marathon/blob/main/Application/Responses/Response.cs"
click node_user_model "https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/ApplicationUser.cs"
click node_score_models "https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/BestResult.cs"
click node_attempt_model "https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/MarathonAttempt.cs"
click node_token_model "https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/RefreshToken.cs"
click node_review_model "https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/Review.cs"
click node_db "https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Data/ApplicationDbContext.cs"
click node_file_storage "https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Services/FileStorageService.cs"
click node_jwt_service "https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Services/JwtTokenService.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_auth_api,node_marathon_api,node_review_api,node_admin_api,node_user toneBlue
class node_auth_features,node_admin_features,node_marathon_features,node_review_features,node_db_contract,node_responses toneAmber
class node_user_model,node_score_models,node_attempt_model,node_token_model,node_review_model toneMint
class node_db,node_file_storage,node_jwt_service toneRose
class node_admin toneIndigo
```

## Components

### HTTP API

- [Auth API](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/AuthController.cs): `WebApi/Controllers/AuthController.cs`
- [Marathon API](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/MarathonController.cs): `WebApi/Controllers/MarathonController.cs`
- [Review API](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/ReviewController.cs): `WebApi/Controllers/ReviewController.cs`
- [Admin API](https://github.com/iamnoseh/marathon/blob/main/WebApi/Controllers/AdminController.cs): `WebApi/Controllers/AdminController.cs`

### Application Features

- [Auth features](https://github.com/iamnoseh/marathon/tree/main/Application/Features/Auth): `Application/Features/Auth`
- [Admin features](https://github.com/iamnoseh/marathon/tree/main/Application/Features/Admin): `Application/Features/Admin`
- [Marathon features](https://github.com/iamnoseh/marathon/tree/main/Application/Features/Marathon): `Application/Features/Marathon`
- [Review features](https://github.com/iamnoseh/marathon/tree/main/Application/Features/Reviews): `Application/Features/Reviews`
- [Database contract](https://github.com/iamnoseh/marathon/blob/main/Application/Interfaces/IApplicationDbContext.cs): `Application/Interfaces/IApplicationDbContext.cs`
- [API responses](https://github.com/iamnoseh/marathon/blob/main/Application/Responses/Response.cs): `Application/Responses/Response.cs`

### Domain Model

- [User identity](https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/ApplicationUser.cs): `Domain/Entities/ApplicationUser.cs`
- [Marathon results](https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/BestResult.cs): `Domain/Entities/BestResult.cs`
- [Marathon attempts](https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/MarathonAttempt.cs): `Domain/Entities/MarathonAttempt.cs`
- [Refresh tokens](https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/RefreshToken.cs): `Domain/Entities/RefreshToken.cs`
- [Review entity](https://github.com/iamnoseh/marathon/blob/main/Domain/Entities/Review.cs): `Domain/Entities/Review.cs`

### Infrastructure

- [Application database](https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Data/ApplicationDbContext.cs): `Infrastructure/Data/ApplicationDbContext.cs`
- [Profile file storage](https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Services/FileStorageService.cs): `Infrastructure/Services/FileStorageService.cs`
- [JWT service](https://github.com/iamnoseh/marathon/blob/main/Infrastructure/Services/JwtTokenService.cs): `Infrastructure/Services/JwtTokenService.cs`

### Other components

- **User**
- **Administrator**

## Connections

- User → Auth API: uses
- User → Marathon API: submits and views
- User → Review API: submits and reads
- Administrator → Admin API: manages users
- Administrator → Review API: moderates reviews
- Auth API → Auth features: dispatches (evidence: `WebApi/Controllers/AuthController.cs`)
- Auth API → Profile file storage: saves profile files (evidence: `WebApi/Controllers/AuthController.cs`)
- Marathon API → Marathon features: dispatches (evidence: `WebApi/Controllers/MarathonController.cs`)
- Review API → Review features: dispatches (evidence: `WebApi/Controllers/ReviewController.cs`)
- Admin API → Admin features: dispatches (evidence: `WebApi/Controllers/AdminController.cs`)
- Auth features → Database contract: reads results (evidence: `Application/Features/Auth/Queries/GetUserProfile/GetUserProfileQueryHandler.cs`)
- Marathon features → Database contract: reads rankings (evidence: `Application/Features/Marathon/Queries/GetMyRank/GetMyRankQueryHandler.cs`)
- Review features → Database contract: reads and writes (evidence: `Application/Features/Reviews/Commands/AddReview/AddReviewCommandHandler.cs`)
- Application database → Database contract: implements (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Application database → User identity: maps (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Application database → Marathon results: maps (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Application database → Marathon attempts: maps (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Application database → Refresh tokens: maps (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
- Application database → Review entity: maps (evidence: `Infrastructure/Data/ApplicationDbContext.cs`)
