# ma813/trekking architecture

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

- Interactive diagram: https://gitdiagram.com/ma813/trekking
- Repository: https://github.com/ma813/trekking

## Overview

This repository implements a browser-based multiplayer card game with a .NET backend. Players enter through the frontend, use account and card-management features, and can participate in real-time lobby/game flows; backend APIs also support statistics and persisted game results. The sampled source supports the frontend composition, backend API-to-repository calls, and core game/lobby relationships, but not all frontend-to-backend HTTP wiring. Major unsampled UI and backend subsystems are represented at their exact tree paths.

Main entry points: [`Frontend/src/controllers/apiClient.ts`](https://github.com/ma813/trekking/blob/main/Frontend/src/controllers/apiClient.ts) (API Controllers), [`Frontend/src/App.tsx`](https://github.com/ma813/trekking/blob/main/Frontend/src/App.tsx) (App and Pages), [`Backend/Repositories/Repository.cs`](https://github.com/ma813/trekking/blob/main/Backend/Repositories/Repository.cs) (Repository Facade), [`Backend/Models/Game.cs`](https://github.com/ma813/trekking/blob/main/Backend/Models/Game.cs) (Game Rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Frontend"]
  node_app["App and Pages<br/>[App.tsx]"]
  node_game_ui["Game UI<br/>[Game.tsx]"]
  node_lobby_ui["Lobby UI<br/>[Lobby.tsx]"]
  node_auth_ui["Authentication UI<br/>[AuthPage.tsx]"]
  node_cards_ui["Card and Deck UI<br/>[AllCardsPage.tsx]"]
  node_stats_ui["Stats UI<br/>[StatsPage.tsx]"]
  node_api_client["API Controllers<br/>[apiClient.ts]"]
  node_hub_client["Hub Client<br/>[LobbyHubClient.ts]"]
end

subgraph group_api["Backend APIs"]
  node_auth_api["Authentication API<br/>[AuthController.cs]"]
  node_cards_api["Cards API<br/>[CardsController.cs]"]
  node_decks_api["Deck Extensions API"]
  node_stats_api["Statistics API<br/>[StatsController.cs]"]
end

subgraph group_game["Real-time Game"]
  node_lobby_service["Lobby Service<br/>[LobbyService.cs]"]
  node_lobby_handler["Lobby Handler<br/>[LobbyHandler.cs]"]
  node_game_model["Game Rules<br/>[Game.cs]"]
  node_player_model["Player State<br/>[Player.cs]"]
  node_game_dto["Game Data<br/>[GameDto.cs]"]
end

subgraph group_data["Persistence and Media"]
  node_repositories["Repository Facade<br/>[Repository.cs]"]
  node_db[("Application Database<br/>[AppDbContext.cs]")]
  node_domain_models["Game and Account Records"]
  node_blob_service["Image Storage"]
end

node_player(("Player"))
node_blob_store[("Blob or Local Assets")]

node_player -.->|"uses"| node_app
node_app -->|"renders"| node_auth_ui
node_app -->|"renders"| node_lobby_ui
node_app -.->|"renders"| node_game_ui
node_app -->|"renders"| node_cards_ui
node_app -->|"renders"| node_stats_ui
node_lobby_ui -.->|"uses"| node_hub_client
node_game_ui -.->|"uses"| node_hub_client
node_auth_ui -.->|"uses"| node_api_client
node_cards_ui -.->|"uses"| node_api_client
node_stats_ui -.->|"uses"| node_api_client
node_api_client -.->|"HTTP requests"| node_auth_api
node_api_client -.->|"HTTP requests"| node_cards_api
node_api_client -.->|"HTTP requests"| node_decks_api
node_api_client -.->|"HTTP requests"| node_stats_api
node_hub_client -.->|"real-time messages"| node_lobby_service
node_lobby_service -->|"uses"| node_lobby_handler
node_lobby_handler -->|"manages"| node_game_model
node_game_model -->|"updates"| node_player_model
node_game_model -.->|"loads and saves"| node_repositories
node_game_model -->|"sends game data"| node_game_dto
node_auth_api -->|"reads and writes"| node_repositories
node_auth_api -->|"uploads profile image"| node_blob_service
node_cards_api -->|"reads and writes"| node_repositories
node_cards_api -->|"uploads card image"| node_blob_service
node_decks_api -->|"reads and writes"| node_repositories
node_stats_api -->|"reads results"| node_repositories
node_repositories -->|"queries"| node_db
node_db -->|"persists"| node_domain_models
node_blob_service -->|"uploads images"| node_blob_store

click node_app "https://github.com/ma813/trekking/blob/main/Frontend/src/App.tsx"
click node_game_ui "https://github.com/ma813/trekking/blob/main/Frontend/src/components/Game.tsx"
click node_lobby_ui "https://github.com/ma813/trekking/blob/main/Frontend/src/components/Lobby.tsx"
click node_auth_ui "https://github.com/ma813/trekking/blob/main/Frontend/src/components/AuthPage.tsx"
click node_cards_ui "https://github.com/ma813/trekking/blob/main/Frontend/src/components/AllCardsPage.tsx"
click node_stats_ui "https://github.com/ma813/trekking/blob/main/Frontend/src/components/StatsPage.tsx"
click node_api_client "https://github.com/ma813/trekking/blob/main/Frontend/src/controllers/apiClient.ts"
click node_hub_client "https://github.com/ma813/trekking/blob/main/Frontend/src/services/LobbyHubClient.ts"
click node_auth_api "https://github.com/ma813/trekking/blob/main/Backend/Controllers/AuthController.cs"
click node_cards_api "https://github.com/ma813/trekking/blob/main/Backend/Controllers/CardsController.cs"
click node_decks_api "https://github.com/ma813/trekking/blob/main/Backend/Controllers/DeckExtensionsController.cs"
click node_stats_api "https://github.com/ma813/trekking/blob/main/Backend/Controllers/StatsController.cs"
click node_lobby_service "https://github.com/ma813/trekking/blob/main/Backend/Services/LobbyService.cs"
click node_lobby_handler "https://github.com/ma813/trekking/blob/main/Backend/Handlers/LobbyHandler.cs"
click node_game_model "https://github.com/ma813/trekking/blob/main/Backend/Models/Game.cs"
click node_player_model "https://github.com/ma813/trekking/blob/main/Backend/Models/Player.cs"
click node_game_dto "https://github.com/ma813/trekking/blob/main/Backend/DTO/GameDto.cs"
click node_repositories "https://github.com/ma813/trekking/blob/main/Backend/Repositories/Repository.cs"
click node_db "https://github.com/ma813/trekking/blob/main/Backend/AppDbContext.cs"
click node_domain_models "https://github.com/ma813/trekking/tree/main/Backend/Models"
click node_blob_service "https://github.com/ma813/trekking/blob/main/Backend/Services/BlobStorageService.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_app,node_game_ui,node_lobby_ui,node_auth_ui,node_cards_ui,node_stats_ui,node_api_client,node_hub_client toneBlue
class node_auth_api,node_cards_api,node_decks_api,node_stats_api,node_blob_store toneAmber
class node_lobby_service,node_lobby_handler,node_game_model,node_player_model,node_game_dto toneMint
class node_repositories,node_db,node_domain_models,node_blob_service toneRose
class node_player toneIndigo
```

## Components

### Frontend

- [App and Pages](https://github.com/ma813/trekking/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [Game UI](https://github.com/ma813/trekking/blob/main/Frontend/src/components/Game.tsx): `Frontend/src/components/Game.tsx`
- [Lobby UI](https://github.com/ma813/trekking/blob/main/Frontend/src/components/Lobby.tsx): `Frontend/src/components/Lobby.tsx`
- [Authentication UI](https://github.com/ma813/trekking/blob/main/Frontend/src/components/AuthPage.tsx): `Frontend/src/components/AuthPage.tsx`
- [Card and Deck UI](https://github.com/ma813/trekking/blob/main/Frontend/src/components/AllCardsPage.tsx): `Frontend/src/components/AllCardsPage.tsx`
- [Stats UI](https://github.com/ma813/trekking/blob/main/Frontend/src/components/StatsPage.tsx): `Frontend/src/components/StatsPage.tsx`
- [API Controllers](https://github.com/ma813/trekking/blob/main/Frontend/src/controllers/apiClient.ts): `Frontend/src/controllers/apiClient.ts`
- [Hub Client](https://github.com/ma813/trekking/blob/main/Frontend/src/services/LobbyHubClient.ts): `Frontend/src/services/LobbyHubClient.ts`

### Backend APIs

- [Authentication API](https://github.com/ma813/trekking/blob/main/Backend/Controllers/AuthController.cs): `Backend/Controllers/AuthController.cs`
- [Cards API](https://github.com/ma813/trekking/blob/main/Backend/Controllers/CardsController.cs): `Backend/Controllers/CardsController.cs`
- [Deck Extensions API](https://github.com/ma813/trekking/blob/main/Backend/Controllers/DeckExtensionsController.cs): `Backend/Controllers/DeckExtensionsController.cs`
- [Statistics API](https://github.com/ma813/trekking/blob/main/Backend/Controllers/StatsController.cs): `Backend/Controllers/StatsController.cs`

### Real-time Game

- [Lobby Service](https://github.com/ma813/trekking/blob/main/Backend/Services/LobbyService.cs): `Backend/Services/LobbyService.cs`
- [Lobby Handler](https://github.com/ma813/trekking/blob/main/Backend/Handlers/LobbyHandler.cs): `Backend/Handlers/LobbyHandler.cs`
- [Game Rules](https://github.com/ma813/trekking/blob/main/Backend/Models/Game.cs): `Backend/Models/Game.cs`
- [Player State](https://github.com/ma813/trekking/blob/main/Backend/Models/Player.cs): `Backend/Models/Player.cs`
- [Game Data](https://github.com/ma813/trekking/blob/main/Backend/DTO/GameDto.cs): `Backend/DTO/GameDto.cs`

### Persistence and Media

- [Repository Facade](https://github.com/ma813/trekking/blob/main/Backend/Repositories/Repository.cs): `Backend/Repositories/Repository.cs`
- [Application Database](https://github.com/ma813/trekking/blob/main/Backend/AppDbContext.cs): `Backend/AppDbContext.cs`
- [Game and Account Records](https://github.com/ma813/trekking/tree/main/Backend/Models): `Backend/Models`
- [Image Storage](https://github.com/ma813/trekking/blob/main/Backend/Services/BlobStorageService.cs): `Backend/Services/BlobStorageService.cs`

### Other components

- **Player**
- **Blob or Local Assets**

## Connections

- Player → App and Pages: uses
- App and Pages → Authentication UI: renders (evidence: `Frontend/src/App.tsx`)
- App and Pages → Lobby UI: renders (evidence: `Frontend/src/App.tsx`)
- App and Pages → Game UI: renders
- App and Pages → Card and Deck UI: renders (evidence: `Frontend/src/App.tsx`)
- App and Pages → Stats UI: renders (evidence: `Frontend/src/App.tsx`)
- Lobby UI → Hub Client: uses
- Game UI → Hub Client: uses
- Authentication UI → API Controllers: uses
- Card and Deck UI → API Controllers: uses
- Stats UI → API Controllers: uses
- API Controllers → Authentication API: HTTP requests
- API Controllers → Cards API: HTTP requests
- API Controllers → Deck Extensions API: HTTP requests
- API Controllers → Statistics API: HTTP requests
- Hub Client → Lobby Service: real-time messages
- Lobby Service → Lobby Handler: uses (evidence: `Backend/Services/LobbyService.cs`)
- Lobby Handler → Game Rules: manages (evidence: `Backend/Handlers/LobbyHandler.cs`)
- Game Rules → Player State: updates (evidence: `Backend/Models/Game.cs`)
- Game Rules → Repository Facade: loads and saves (evidence: `Backend/Repositories/Repository.cs`)
- Game Rules → Game Data: sends game data (evidence: `Backend/Models/Game.cs`)
- Authentication API → Repository Facade: reads and writes (evidence: `Backend/Controllers/AuthController.cs`)
- Authentication API → Image Storage: uploads profile image (evidence: `Backend/Controllers/AuthController.cs`)
- Cards API → Repository Facade: reads and writes (evidence: `Backend/Controllers/CardsController.cs`)
- Cards API → Image Storage: uploads card image (evidence: `Backend/Controllers/CardsController.cs`)
- Deck Extensions API → Repository Facade: reads and writes (evidence: `Backend/Controllers/DeckExtensionsController.cs`)
- Statistics API → Repository Facade: reads results (evidence: `Backend/Controllers/StatsController.cs`)
- Repository Facade → Application Database: queries (evidence: `Backend/Repositories/Repository.cs`)
- Application Database → Game and Account Records: persists (evidence: `Backend/AppDbContext.cs`)
- Image Storage → Blob or Local Assets: uploads images (evidence: `Backend/Services/BlobStorageService.cs`)
