# viethann/game-giai-ma-kho-bau architecture

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

- Interactive diagram: https://gitdiagram.com/viethann/game-giai-ma-kho-bau
- Repository: https://github.com/viethann/game-giai-ma-kho-bau

## Overview

##### Project type and purpose
- This is a full-stack monolithic web application built with Flask.
- Purpose: an educational “Treasure Hunt” decryption game where users progress through levels by decrypting messages with various algorithms (Caesar, Vigenère, RSA, AES), track progress, and view history.

##### File structure
- Top-level:
- app.py – defines Flask routes (controllers)
- main.py – application entry point (starts Flask)
- crypto_algorithms.py – business logic for encryption/decryption
- game_data.py – holds level- and practice-mode configurations (models)
- game_history.py – manages persistence of play history (models)
- game_history.json – flat file store for history (data storage)
- Directories:
- templates/ – Jinja2 HTML templates (views)
- static/
– css/style.css (presentation)
– js/game.js (client-side interactivity)
– image/ (assets)
- No external database or microservices: file-based persistence, single Python process.

##### README for further insights
- Tech stack: Flask, PyCryptodome
- Features highlight MVC pattern: controllers in app.py, views in templates, models in game_data.py & game_history.py
- Game modes (levels vs. practice) drive route logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Side
    Browser["Web Browser"]:::client

    %% Server Side
    subgraph "Flask Monolith"
        direction TB
        EntryPoint["main.py"]:::entry
        Controllers["app.py"]:::controller

        subgraph "Presentation Layer"
            direction TB
            Templates["templates/"]:::view
            StaticCSS["static/css/style.css"]:::css
            StaticJS["static/js/game.js"]:::js
            StaticImg["static/image/"]:::img
        end

        subgraph "Application Logic Layer"
            direction TB
            Crypto["crypto_algorithms.py"]:::logic
            GameData["game_data.py"]:::logic
        end

        subgraph "Data Layer"
            direction TB
            GameHistoryModel["game_history.py"]:::model
            GameHistoryStore[("game_history.json")]:::storage
        end

        subgraph "External Libraries"
            direction TB
            PyCrypto["PyCryptodome"]:::external
        end
    end

    %% Connections
    Browser -->|"HTTP GET/POST"| Controllers
    Controllers -->|"render"| Templates
    Browser -->|"fetch CSS"| StaticCSS
    Browser -->|"fetch JS"| StaticJS
    Browser -->|"fetch Images"| StaticImg
    Controllers -->|"invoke"| Crypto
    Controllers -->|"invoke"| GameData
    Crypto -->|"uses"| PyCrypto
    Controllers -->|"read/write"| GameHistoryModel
    GameHistoryModel -->|"load/save"| GameHistoryStore
    StaticJS -->|"AJAX"| Controllers

    %% Click Events
    click EntryPoint "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/main.py"
    click Controllers "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/app.py"
    click Crypto "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/crypto_algorithms.py"
    click GameData "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/game_data.py"
    click GameHistoryModel "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/game_history.py"
    click GameHistoryStore "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/game_history.json"
    click Templates "https://github.com/viethann/game-giai-ma-kho-bau/tree/main/templates/"
    click StaticCSS "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/static/css/style.css"
    click StaticJS "https://github.com/viethann/game-giai-ma-kho-bau/blob/main/static/js/game.js"
    click StaticImg "https://github.com/viethann/game-giai-ma-kho-bau/tree/main/static/image/"

    %% Styles
    classDef client fill:#a2d5f2,stroke:#333,stroke-width:1px;
    classDef entry fill:#b3cde0,stroke:#333,stroke-width:1px;
    classDef controller fill:#6497b1,stroke:#333,stroke-width:1px;
    classDef view fill:#fbb4ae,stroke:#333,stroke-width:1px,shape:parallelogram;
    classDef css fill:#fdd0a2,stroke:#333,stroke-width:1px,shape:parallelogram;
    classDef js fill:#fdb863,stroke:#333,stroke-width:1px,shape:parallelogram;
    classDef img fill:#fdc086,stroke:#333,stroke-width:1px,shape:parallelogram;
    classDef logic fill:#ccebc5,stroke:#333,stroke-width:1px;
    classDef model fill:#decbe4,stroke:#333,stroke-width:1px;
    classDef storage fill:#b3e2cd,stroke:#333,stroke-width:1px,shape:cylinder;
    classDef external fill:none,stroke:#e41a1c,stroke-dasharray: 5 5,stroke-width:2px;
    class EntryPoint,Controllers,Crypto,GameData,GameHistoryModel,GameHistoryStore,Templates,StaticCSS,StaticJS,StaticImg,Browser,PyCrypto entry,controller,logic,model,storage,view,css,js,img,external
```
