# saifahmed34/the-guess-game architecture

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

- Interactive diagram: https://gitdiagram.com/saifahmed34/the-guess-game
- Repository: https://github.com/saifahmed34/the-guess-game

## Overview

##### Project type and purpose
- This is a full-stack web application: an ASP .NET Core REST API backend with a static HTML/CSS/JS frontend that implements a two-player, turn-based word guessing game.
- The README confirms: RESTful API (ASP.NET Core), EF Core with SQL Server, frontend served via static files.

##### File structure
- Top-level:
- Controllers/  → HTTP endpoints (gameController.cs)
- Data/         → EF Core DbContext (AppDbContext.cs)
- Dtos/         → Request models for API calls
- Models/       → Domain entities (Game, Player, Turn)
- Migrations/   → EF Core migrations
- wwwroot/      → Static HTML/CSS/JS (index.html, game.html, .css, .js)
- Program.cs    → App startup, middleware registration
- appsettings.json & launchSettings.json → Configuration
- Patterns:
- Layered architecture (Presentation → API → Business/Domain → Data)
- EF Core Code-First for persistence
- Static file middleware for frontend

##### Key insights from README
- Clearly separates game logic (Models + Controller) from API request/response (DTOs).
- No separate service layer—Controller handles orchestration.
- Future: migrate frontend to React.

##### Main components
a. Frontend (Browser)
- Static files: index.html, game.html, CSS, JS
- Technology: vanilla JS, HTML/CSS
b. Backend API (ASP .NET Core)
- gameController.cs exposes POST endpoints: /api/game/create, /join, /question, /answer, /guess
- Program.cs configures routing, EF Core, static files
c. Data Access Layer
- AppDbContext (EF Core)
- Migrations folder
d. Database
- SQL Server
e. External/deployment
- Kestrel / IIS hosting
- Configuration (appsettings.json)

##### Relationships and data flow
- Browser → HTTP(S) → ASP .NET Core Controller
- Controller → EF Core DbContext → SQL Server
- EF Core returns entities → Controller → DTOs → JSON → Browser
- Static middleware serves HTML/JS directly to Browser

##### Architectural patterns & design principles
- Layered architecture:
- Presentation layer (static frontend)
- API layer (Controllers + DTOs)
- Domain layer (Models + business logic)
- Data layer (EF Core + Migrations)
- Code-First ORM approach for persistence.

##### Technologies to note
- ASP .NET Core 6+ (C#)
- Entity Framework Core
- SQL Server
- Static Web Assets (HTML/CSS/JS)
- .NET CLI, launchSettings.json for hosting ports

##### Detail
- Which technologies live in each (e.g., “EF Core” next to DbContext).
- Configuration boundary (appsettings.json) feeding connection string into DbContext.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Browser / Frontend"
        direction TB
        index["index.html"]:::frontend
        game["game.html"]:::frontend
        css1["css/index.css"]:::frontend
        css2["css/game.css"]:::frontend
        js1["js/index.js"]:::frontend
        js2["js/game.js"]:::frontend
    end

    subgraph "ASP.NET Core App"
        direction TB
        Controllers["Controllers"]:::backend
        GameController["GameController"]:::backend
        DTOs["Dtos"]:::backend
        AR["AnswerRequest"]:::backend
        CJ["CreateAndJoinRequest"]:::backend
        QR["QuestionRequest"]:::backend
        Models["Models"]:::backend
        Gm["Game"]:::backend
        Pl["Player"]:::backend
        Tn["Turn"]:::backend
        Data["AppDbContext"]:::backend
        Migrations["Migrations"]:::backend
        Mi1["20250608161855_InitialCreate"]:::backend
        Snapshot["AppDbContextModelSnapshot"]:::backend
        Program["Program.cs"]:::backend
        Config["appsettings.json/.Development.json"]:::backend
        Launch["launchSettings.json"]:::backend

        Controllers --> GameController
        Controllers --> DTOs
        DTOs --> AR
        DTOs --> CJ
        DTOs --> QR
        Controllers --> Models
        Models --> Gm
        Models --> Pl
        Models --> Tn
        Controllers --> Data
        Data --> Migrations
        Migrations --> Mi1
        Migrations --> Snapshot
        Program -.-> Controllers
        Program -.-> Data
        Program -.-> Config
        Program -.-> Launch
    end

    subgraph "Database"
        direction TB
        SQLServer[(SQL Server Database)]:::db
        SQLServer --> Tables["Games, Players, Turns"]:::db
    end

    js1 -->|"API Calls"| GameController
    js2 -->|"API Calls"| GameController
    GameController -->|"uses EF Core"| Data
    Data --> SQLServer
    SQLServer --> Data
    GameController -->|"JSON Response"| js1

    click index "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/index.html"
    click game "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/game.html"
    click css1 "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/css/index.css"
    click css2 "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/css/game.css"
    click js1 "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/js/index.js"
    click js2 "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/wwwroot/js/game.js"
    click GameController "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Controller/gameController.cs"
    click AR "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Dtos/Request Models/AnswerRequest.cs"
    click CJ "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Dtos/Request Models/CreateAndJoinRequest.cs"
    click QR "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Dtos/Request Models/QuestionRequest.cs"
    click Gm "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Models/Game.cs"
    click Pl "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Models/Player.cs"
    click Tn "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Models/Turn.cs"
    click Data "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Data/AppDbContext.cs"
    click Migrations "https://github.com/saifahmed34/the-guess-game/tree/main/Guessing-Game/Guessing-Game/Migrations/"
    click Mi1 "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Migrations/20250608161855_Intial Create.cs"
    click Snapshot "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Migrations/AppDbContextModelSnapshot.cs"
    click Program "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Program.cs"
    click Config "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/appsettings.json"
    click Launch "https://github.com/saifahmed34/the-guess-game/blob/main/Guessing-Game/Guessing-Game/Properties/launchSettings.json"

    classDef frontend fill:#D0E8FF,stroke:#000;
    classDef backend fill:#DFFFD0,stroke:#000;
    classDef db fill:#FFE0B2,stroke:#000;
```
