# yogendra095/sudoku_cpp architecture

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

- Interactive diagram: https://gitdiagram.com/yogendra095/sudoku_cpp
- Repository: https://github.com/yogendra095/sudoku_cpp

## Overview

##### Project Type and Purpose
- This is a monolithic, native C++ desktop application: a Sudoku game built on top of the SFML 3.0.0 multimedia library.
- The README confirms compilation and runtime steps, showing dependencies on SFML’s graphics, window, system, and audio modules.

##### File‐Structure Analysis
- Top‐Level
- SFML‐3.0.0/ – local copy of the SFML SDK (includes headers, libs, docs, examples)
- Src/ – application source and assets
- Readme.md, Proposal.pdf, .gitignore
- Src/
- main.cpp → application entry point & state machine
- login.cpp/.hpp → authentication logic (reads/writes users.txt)
- Menu.cpp/.hpp, LevelSelection.cpp/.hpp → UI screens
- SudokuGame.cpp/.hpp → core puzzle logic
- User.cpp/.hpp → user model & persistence via users.txt
- assets/fonts, assets/images → static resource files

##### Key Insights from README
- Uses g++ to compile all CPP files in Src/, linking against SFML libraries via ‑I (include) and ‑L (lib) flags.
- Runtime is a single executable that opens an SFML RenderWindow and drives the game loop.

##### Main Architectural Components
A. Presentation Layer (UI Screens)
- MenuView, LevelSelectionView, GameView
- Invokes SFML Window and Graphics APIs for rendering and event handling
B. Controller / Application Layer
- main.cpp orchestrates initialization, screen transitions, and game loop
- Routes SFML events (keyboard/mouse) to the active View
C. Domain / Business Logic
- SudokuGame: puzzle generation, validation, game state
- User: model of player data (name, progress)
D. Data Access Layer
- UserManager (within login.cpp/User.cpp): reads/writes users.txt on disk
- ResourceManager: loads fonts/images from assets/ into SFML Textures, Fonts
E. External Libraries
- SFML modules: Window, Graphics, System, Audio
- Underlying OS (display, input, file system)

##### Relationships & Data Flow
- User → SFML Event → Application Controller → Active View
- View → calls Game Logic API (e.g., SudokuGame::checkMove())
- Game Logic → updates Domain Model (User progress)
- Domain Model → persists via Data Access (users.txt)
- Views & Logic → request resources via ResourceManager → SFML loads from disk

##### Architectural Patterns & Principles
- Layered architecture: clear separation of UI, application flow, domain logic, and data persistence
- Single Responsibility: each class/file addresses exactly one concern
- Dependency direction: higher layers depend on lower-level SFML/OS, not vice versa

##### Step-by-Step Guidance for the Engineer
1. Sketch the outer process boundary (“SudokuGame.exe”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "SudokuGame.exe"
        direction TB

        subgraph "Presentation Layer"
            direction TB
            MenuView["MenuView (Menu.cpp/.hpp)"]:::ui
            LevelSelectionView["LevelSelectionView (LevelSelection.cpp/.hpp)"]:::ui
            GameView["GameView (SudokuGame.cpp/.hpp)"]:::ui
        end

        subgraph "Controller Layer"
            direction TB
            Controller["Application Entry & State Machine (main.cpp)"]:::controller
        end

        subgraph "Domain Layer"
            direction TB
            SudokuGame["SudokuGame (puzzle generation & validation)"]:::domain
            User["User (User.cpp/.hpp)"]:::domain
        end

        subgraph "Data Access Layer"
            direction TB
            UserManager["UserManager (login.cpp/.hpp)"]:::data
            ResourceManager["ResourceManager (loads assets)"]:::data
            DiskUsers["User Store (users.txt)"]:::storage
            DiskAssetsFonts["Fonts Folder"]:::storage
            DiskAssetsImages["Images Folder"]:::storage
        end
    end

    subgraph "External Libraries & OS"
        direction TB
        SFMLWindow["SFML Window"]:::external
        SFMLGraphics["SFML Graphics"]:::external
        SFMLSystem["SFML System"]:::external
        SFMLAudio["SFML Audio"]:::external
        OS["Operating System"]:::external
    end

    %% Connections
    OS --> SFMLWindow
    OS --> SFMLGraphics
    OS --> SFMLSystem
    OS --> SFMLAudio

    SFMLWindow --> Controller
    Controller --> MenuView
    Controller --> LevelSelectionView
    Controller --> GameView

    MenuView --> SudokuGame
    LevelSelectionView --> SudokuGame
    GameView --> SudokuGame

    SudokuGame --> User
    SudokuGame --> ResourceManager

    User --> UserManager
    UserManager --> DiskUsers

    ResourceManager --> DiskAssetsFonts
    ResourceManager --> DiskAssetsImages

    ResourceManager --> SFMLGraphics
    MenuView --> SFMLWindow
    LevelSelectionView --> SFMLWindow
    GameView --> SFMLWindow

    %% Click Events
    click MenuView "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/Menu.cpp"
    click LevelSelectionView "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/LevelSelection.cpp"
    click GameView "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/SudokuGame.cpp"
    click Controller "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/main.cpp"
    click SudokuGame "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/SudokuGame.cpp"
    click User "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/User.cpp"
    click UserManager "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/login.cpp"
    click DiskUsers "https://github.com/yogendra095/sudoku_cpp/blob/main/Src/users.txt"
    click DiskAssetsFonts "https://github.com/yogendra095/sudoku_cpp/tree/main/Src/assets/fonts/"
    click DiskAssetsImages "https://github.com/yogendra095/sudoku_cpp/tree/main/Src/assets/images/"
    click SFMLWindow "https://github.com/yogendra095/sudoku_cpp/tree/main/SFML-3.0.0/include/"
    click SFMLGraphics "https://github.com/yogendra095/sudoku_cpp/tree/main/SFML-3.0.0/include/"
    click SFMLSystem "https://github.com/yogendra095/sudoku_cpp/tree/main/SFML-3.0.0/include/"
    click SFMLAudio "https://github.com/yogendra095/sudoku_cpp/tree/main/SFML-3.0.0/include/"

    %% Styles
    classDef ui fill:#D0E6FF,stroke:#0366D6,stroke-width:1px
    classDef controller fill:#E8F4FF,stroke:#0366D6,stroke-width:1px
    classDef domain fill:#DFFFE0,stroke:#228B22,stroke-width:1px
    classDef data fill:#FFEFD5,stroke:#FF8C00,stroke-width:1px
    classDef storage fill:#FFDAB9,stroke:#FF8C00,stroke-width:1px,stroke-dasharray: 2 2
    classDef external fill:#F0F0F0,stroke:#A9A9A9,stroke-width:1px,stroke-dasharray: 2 2
```
