# shenmareparas/chess architecture

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

- Interactive diagram: https://gitdiagram.com/shenmareparas/chess
- Repository: https://github.com/shenmareparas/chess

## Overview

##### Project type and purpose
- This is a standalone mobile chess game built with Flutter (Dart) and the Flame engine.
- It targets Android and iOS (see top-level android/ and ios/ folders).
- There is no separate backend or server—everything runs on the device.
- Key features: 1-player (AI via minimax + αβ pruning) or 2-player offline, theme/piece customization.

##### File structure
- Top-level dirs:
- android/: Flutter’s Android embedding + Gradle build scripts
- ios/: iOS embedding + CocoaPods + Xcode projects
- lib/: All Dart source code
- assets/: Static files (images, fonts, audio)
- Under lib/:
- logic/: Core game engine and AI move calculation
- model/: App-wide state (app_model.dart) and theming
- views/: Presentation layer, broken into main_menu_view, settings_view, chess_view, plus UI components
- Configuration files:
- pubspec.yaml (deps: Flame, Flutter SDK, etc.)
- android/gradle.properties, ios/Podfile

##### README for additional insights
- Confirms use of Flame engine for rendering.
- Explains AI difficulty levels mapped to search depth.
- No mention of networking or external services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User(("User")):::external
    User -->|taps UI| MainMenuView

    %% Platform Embedders
    subgraph "Platform Embedders"
        direction TB
        AndroidEmbedder["Android Embedder"]:::platform
        iOSEmbedder["iOS Embedder"]:::platform
    end
    AndroidEmbedder --> FlutterEngine
    iOSEmbedder --> FlutterEngine
    click AndroidEmbedder "https://github.com/shenmareparas/chess/tree/main/android/"
    click iOSEmbedder "https://github.com/shenmareparas/chess/tree/main/ios/"

    %% Core Platform
    FlutterEngine["Flutter Engine & Dart VM\n(lib/main.dart)"]:::platform
    click FlutterEngine "https://github.com/shenmareparas/chess/blob/main/lib/main.dart"

    %% Asset Manager
    AssetManager["Asset Manager\n(assets/)"]:::asset
    AssetManager -->|provides textures/audio/fonts| PresentationLayer
    FlutterEngine --> AssetManager
    click AssetManager "https://github.com/shenmareparas/chess/tree/main/assets/"
    click AssetsAudio "https://github.com/shenmareparas/chess/tree/main/assets/audio/"
    click AssetsFont "https://github.com/shenmareparas/chess/tree/main/assets/font/"
    click AssetsIcons "https://github.com/shenmareparas/chess/tree/main/assets/icons/"
    click AssetsImages "https://github.com/shenmareparas/chess/tree/main/assets/images/"

    %% Presentation Layer
    subgraph "Presentation Layer (lib/views)" 
        direction TB
        ViewsDir["Directory: lib/views/"]:::component
        MainMenuView["MainMenuView"]:::layer
        SettingsView["SettingsView"]:::layer
        ChessView["ChessView"]:::layer
        ComponentsDir["Components"]:::component
    end
    FlutterEngine --> PresentationLayer
    PresentationLayer["Presentation Layer"]:::layer
    PresentationLayer --> ViewsDir
    ViewsDir --> MainMenuView
    ViewsDir --> SettingsView
    ViewsDir --> ChessView
    ViewsDir --> ComponentsDir
    MainMenuView -->|routes to| AppModel
    SettingsView -->|updates| AppModel
    ChessView -->|renders board| AppModel
    click ViewsDir "https://github.com/shenmareparas/chess/tree/main/lib/views/"
    click MainMenuView "https://github.com/shenmareparas/chess/blob/main/lib/views/main_menu_view.dart"
    click SettingsView "https://github.com/shenmareparas/chess/blob/main/lib/views/settings_view.dart"
    click ChessView "https://github.com/shenmareparas/chess/blob/main/lib/views/chess_view.dart"
    click ComponentsDir "https://github.com/shenmareparas/chess/tree/main/lib/views/components/"

    %% State & Domain Layer
    subgraph "State & Domain Layer (lib/model)" 
        direction TB
        AppModel["AppModel"]:::layer
        ThemesSettings["Themes & Settings"]:::layer
    end
    PresentationLayer --> AppModel
    AppModel --> ThemesSettings
    AppModel --> LogicLayer
    click AppModel "https://github.com/shenmareparas/chess/blob/main/lib/model/app_model.dart"
    click ThemesSettings "https://github.com/shenmareparas/chess/blob/main/lib/model/app_themes.dart"

    %% Game Logic Layer
    subgraph "Game Logic Layer (lib/logic)"
        direction TB
        subgraph "Core Engine"
            ChessBoard["ChessBoard"]:::layer
            ChessGame["ChessGame"]:::layer
            ChessPiece["ChessPiece"]:::layer
            ChessSprite["ChessPieceSprite"]:::layer
            SharedFuncs["Shared Functions"]:::layer
        end
        subgraph "Move Calculation & AI"
            AIcalc["AI Move Calculation"]:::layer
            MoveCalc["Move Calculation"]:::layer
            MoveClasses["Move Classes"]:::component
            Openings["Openings"]:::layer
            PSTables["Piece-Square Tables"]:::layer
        end
    end
    LogicLayer["Logic Layer"]:::layer
    LogicLayer --> ChessBoard
    ChessBoard --> ChessGame
    ChessGame --> ChessPiece
    ChessPiece --> ChessSprite
    ChessGame --> SharedFuncs
    ChessGame --> AIcalc
    AIcalc --> MoveCalc
    MoveCalc --> MoveClasses
    MoveCalc --> Openings
    MoveCalc --> PSTables
    AIcalc --> ChessBoard
    ChessGame --> PresentationLayer
    click ChessBoard "https://github.com/shenmareparas/chess/blob/main/lib/logic/chess_board.dart"
    click ChessGame "https://github.com/shenmareparas/chess/blob/main/lib/logic/chess_game.dart"
    click ChessPiece "https://github.com/shenmareparas/chess/blob/main/lib/logic/chess_piece.dart"
    click ChessSprite "https://github.com/shenmareparas/chess/blob/main/lib/logic/chess_piece_sprite.dart"
    click SharedFuncs "https://github.com/shenmareparas/chess/blob/main/lib/logic/shared_functions.dart"
    click AIcalc "https://github.com/shenmareparas/chess/blob/main/lib/logic/move_calculation/ai_move_calculation.dart"
    click MoveCalc "https://github.com/shenmareparas/chess/blob/main/lib/logic/move_calculation/move_calculation.dart"
    click MoveClasses "https://github.com/shenmareparas/chess/tree/main/lib/logic/move_calculation/move_classes/"
    click Openings "https://github.com/shenmareparas/chess/blob/main/lib/logic/move_calculation/openings.dart"
    click PSTables "https://github.com/shenmareparas/chess/blob/main/lib/logic/move_calculation/piece_square_tables.dart"

    %% External Services
    GooglePlay["Google Play Store"]:::external
    AppStore["App Store"]:::external
    GooglePlay -.->|distribute app| User
    AppStore -.->|distribute app| User

    %% Connections
    FlutterEngine --> PresentationLayer
    FlutterEngine --> LogicLayer
    FlutterEngine --> AppModel

    %% Styles
    classDef platform fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef layer fill:#ccddff,stroke:#333,stroke-width:1px;
    classDef asset fill:#ffffcc,stroke:#333,stroke-width:1px;
    classDef external stroke-dasharray:5 5,fill:none,stroke:#333;
    classDef component fill:#eeeeee,stroke:#666,stroke-width:1px;
```
