# thisisnabi/leaderboard architecture

> Architecture diagram of the GitHub repository thisisnabi/leaderboard, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thisisnabi/leaderboard
- Repository: https://github.com/thisisnabi/leaderboard

## Overview

##### Project type and purpose
- This is a single microservice-style .NET application named “LeaderBoard.”
- It’s designed to consume two types of domain events (player scores and product sales), process them via a ScoreService, and presumably expose an HTTP API for querying leaderboard data.

##### File structure
- Top-level: standard .NET solution (.sln) with a single project under `src/LeaderBoard`.
- `Program.cs` + `LeaderBoard.http` (REST requests for manual testing) indicate it hosts an HTTP endpoint (likely a minimal API).
- `Subscriptions/…` directories hold two event consumers: one for `PlayerScoreChangedEvent` and one for `SoldProductEvent`.
- `ScoreService.cs` encapsulates business logic around updating and retrieving leaderboards.
- `Models/` contains domain entities and comparers that define score types.
- `appsettings.json` + `launchSettings.json` indicate configurable endpoints (e.g., message broker connection, HTTP port).

##### README
- Minimal content (“# LeaderBoard”), so architecture must be inferred from code structure and naming conventions rather than existing documentation.

##### Elements
- Labels: “PlayerScore Producer,” “SoldProduct Producer,” “Message Broker,” “LeaderBoard Service,” “PlayerScoreChangedConsumer,” “SoldProductConsumer,” “ScoreService,” “HTTP API,” “Data Store,” “API Client.”
→ from producers to broker,
→ from broker to consumers,
→ from consumers to ScoreService,
→ from ScoreService to Data Store,
→ from API Client to HTTP API to ScoreService/Data Store.

##### Final advice
- Be very detailed and capture each subscription path separately.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Producers
    PSProducer("PlayerScore Producer"):::external
    SPProducer("SoldProduct Producer"):::external

    %% Message Broker
    Broker("Message Broker"):::broker

    %% LeaderBoard Service
    subgraph "LeaderBoard Service"
        direction TB
        subgraph "Subscriptions"
            direction TB
            PlayerConsumer["PlayerScoreChangedConsumer"]:::internal
            PlayerEvent["PlayerScoreChangedEvent"]:::internal
            SoldConsumer["SoldProductConsumer"]:::internal
            SoldEvent["SoldProductEvent"]:::internal
        end
        ScoreService["ScoreService"]:::internal
        HTTPAPI["HTTP API"]:::internal
    end

    %% Data Store
    DataStore["Data Store"]:::datastore

    %% API Clients
    APIClient("API Client"):::external

    %% Interactions
    PSProducer -->|PlayerScoreChangedEvent| Broker
    SPProducer -->|SoldProductEvent| Broker

    Broker -->|PlayerScoreChangedEvent| PlayerConsumer
    Broker -->|SoldProductEvent| SoldConsumer

    PlayerConsumer -->|Invoke ScoreService| ScoreService
    SoldConsumer -->|Invoke ScoreService| ScoreService

    ScoreService -->|Read/Write| DataStore

    APIClient -->|HTTP GET/POST| HTTPAPI
    HTTPAPI -->|Use ScoreService| ScoreService
    HTTPAPI -->|Read Data| DataStore

    %% Click Events - Subscriptions
    click PlayerConsumer "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/Subscriptions/PlayerScoreSubscribe/PlayerScoreChangedConsumer.cs"
    click PlayerEvent "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/Subscriptions/PlayerScoreSubscribe/PlayerScoreChangedEvent.cs"
    click SoldConsumer "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/Subscriptions/TopSoldProductSubscribe/SoldProductConsumer.cs"
    click SoldEvent "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/Subscriptions/TopSoldProductSubscribe/SoldProductEvent.cs"

    %% Click Events - Core Business Logic
    click ScoreService "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/ScoreService.cs"

    %% Click Events - HTTP API Layer
    click HTTPAPI "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/Program.cs"
    click APIClient "https://github.com/thisisnabi/leaderboard/blob/main/src/LeaderBoard/LeaderBoard.http"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5,shape:round
    classDef internal fill:#bbf,stroke:#333,stroke-width:1px
    classDef broker fill:#fcf,stroke:#333,stroke-width:1px,shape:circle
    classDef datastore fill:#cfc,stroke:#333,stroke-width:1px,shape:cylinder
```
