# alexis2707/projet_divercite architecture

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

- Interactive diagram: https://gitdiagram.com/alexis2707/projet_divercite
- Repository: https://github.com/alexis2707/projet_divercite

## Overview

##### Project Type and Purpose
- This is a monolithic Python‐based board‐game application (“Divercite”) that bundles:
- A game engine (board rules, game‐state management, scoring, validation)
- A set of player implementations (random, greedy, advanced AI, legacy agents)
- A controller/CLI entry‐point (main_divercite.py, master_divercite.py)
- A GUI frontend (static HTML/CSS/JS)
- An optional networking layer for remote multiplayer (via aiohttp)
- Its goal is to let users run local matches (human vs. human or AI), host/join remote games, and experiment with AI strategies.

##### File‐Structure Analysis
- Top‐Level Python Modules:
- board_divercite.py – Board representation & rule enforcement
- game_state_divercite.py – State transitions, move validation, scoring
- player_divercite.py – Base class for any player
- random_player_divercite.py, greedy_player_divercite.py, my_player.py – Concrete strategies
- legacy_agent/ – Historical variants (v0 → v3) of an agent for benchmarking
- master_divercite.py – Orchestrates a full match, declares winner
- main_divercite.py – CLI/parser, selects mode (local, human_vs_computer, host/join, human_vs_human)
- GUI Directory:
- index.html, main.css, main.js, assets – Static SPA for interactive play
- Config & Docs: requirements.txt, .gitignore, project PDFs for design/rapport

##### README Insights
- Supports four play modes: local, human_vs_computer, human_vs_human, remote multiplayer (host/connect)
- Emphasizes modular players—swapping strategy by passing different .py files on the command line
- Mentions logging/state‐recording, hints at extensibility through base player class and legacy agents

a. Main Components to Include
- Controller Layer
– CLI Handler (main_divercite.py + seahorse parser)
– Match Manager (master_divercite.py)
- Game Engine (Core)
– Board Module (board_divercite.py)
– Game State Manager (game_state_divercite.py)
– Rule & Scoring Subsystem
- Player Components
– Base Player Interface (player_divercite.py)
– Strategy Plugins (random, greedy, my_player, legacy_agent/*)
- UI Layer
– CLI Output (colorama + loguru)
– GUI Frontend (index.html, main.js served locally or via aiohttp)
- Networking Layer (aiohttp)
– Host Service (listening socket)
– Client Connector (outbound)
- Logging & Persistence
– loguru logger writing to console/files

b. Relationships & Data Flows
- Controller → Game Engine: “startMatch(config)”, “nextTurn()”
- Game Engine ↔ Player: “requestMove(state) → move”, “validateMove”
- Game Engine → State Manager → Scoring → Controller
- Controller ↔ UI Layer: updates, user input events
- Controller ↔ Networking: emit/receive move events for remote play
- All components → Logger: event logs

c. Architectural Patterns & Principles
- Modular design: Swappable player strategies via a common interface (Strategy pattern)
- Separation of concerns:
– Model (board & state)
– Controller (match orchestration)
– View (CLI, GUI)
- Plugin architecture for AI agents (drop-in .py scripts)
- Event-driven IO for multiplayer (async via aiohttp)

d. Key Technologies/Frameworks
- Python modules & packages
- asyncio + aiohttp for networking
- seahorse for CLI command parsing & interactive shell
- loguru for structured logging
- colorama for CLI coloring
- Vanilla Web tech (HTML/CSS/JS) for front end

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        CLI_Handler["CLI Handler\n(main_divercite.py)"]:::controller
        Match_Manager["Match Manager\n(master_divercite.py)"]:::controller
    end

    %% Game Engine Core
    subgraph "Game Engine" 
        direction TB
        Board_Module["Board Module\n(board_divercite.py)"]:::core
        Game_State["Game State Manager & Scoring\n(game_state_divercite.py)"]:::core
    end

    %% Player Components
    subgraph "Player Components"
        direction TB
        Base_Player["Base Player Interface\n(player_divercite.py)"]:::player
        Random_Player["Random Strategy\n(random_player_divercite.py)"]:::player
        Greedy_Player["Greedy Strategy\n(greedy_player_divercite.py)"]:::player
        Advanced_AI["Advanced AI Strategy\n(my_player.py)"]:::player
        subgraph "Legacy Agents"
            direction TB
            Legacy_v0["v0 Abyss\n(legacy_agent/v0_abyss.py)"]:::player
            Legacy_v1["v1 Abyss\n(legacy_agent/v1_abyss.py)"]:::player
            Legacy_v2["v2 Abyss\n(legacy_agent/v2_abyss.py)"]:::player
            Legacy_v3["v3 Abyss\n(legacy_agent/v3_abyss.py)"]:::player
        end
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        CLI_Output["CLI Output\n(colorama + loguru)"]:::ui
        GUI_HTML["index.html"]:::ui
        GUI_CSS["main.css"]:::ui
        GUI_JS["main.js"]:::ui
        GUI_Assets["assets/"]:::ui
    end

    %% Networking Layer
    subgraph "Networking Layer"
        direction TB
        Host_Service["Host Service\n(aiohttp)"]:::network
        Client_Connector["Client Connector\n(aiohttp)"]:::network
    end

    %% Logging & Persistence
    Logger["Loguru Logger"]:::logging

    %% Config & Documentation
    subgraph "Configuration & Documentation"
        direction TB
        Requirements["requirements.txt"]:::config
        README["README.md"]:::config
        Rapport["rapport.pdf"]:::config
        ProjetPDF["Projet_Divercite_H2025.pdf"]:::config
    end

    %% Connections
    CLI_Handler -->|"invoke startMatch"| Match_Manager
    Match_Manager -->|"init board"| Board_Module
    Match_Manager -->|"init state"| Game_State
    Match_Manager -->|"requestMove"| Base_Player
    Base_Player --> Random_Player
    Base_Player --> Greedy_Player
    Base_Player --> Advanced_AI
    Base_Player --> Legacy_v0
    Base_Player --> Legacy_v1
    Base_Player --> Legacy_v2
    Base_Player --> Legacy_v3

    CLI_Handler -->|"user input"| CLI_Output
    GUI_HTML -->|"user events"| Match_Manager
    GUI_JS --> GUI_HTML
    GUI_CSS --> GUI_HTML
    GUI_Assets --> GUI_HTML

    CLI_Output --> Match_Manager
    Match_Manager --> CLI_Output
    Match_Manager --> Host_Service
    Match_Manager --> Client_Connector
    Host_Service --> Match_Manager
    Client_Connector --> Match_Manager

    Board_Module --> Game_State
    Game_State -->|"scoring"| Match_Manager

    CLI_Handler --> Logger
    Match_Manager --> Logger
    Board_Module --> Logger
    Game_State --> Logger
    Base_Player --> Logger
    Host_Service --> Logger
    Client_Connector --> Logger

    Requirements --- README
    README --- Rapport
    README --- ProjetPDF

    %% Click Events
    click CLI_Handler "https://github.com/alexis2707/projet_divercite/blob/main/main_divercite.py"
    click Match_Manager "https://github.com/alexis2707/projet_divercite/blob/main/master_divercite.py"
    click Board_Module "https://github.com/alexis2707/projet_divercite/blob/main/board_divercite.py"
    click Game_State "https://github.com/alexis2707/projet_divercite/blob/main/game_state_divercite.py"
    click Base_Player "https://github.com/alexis2707/projet_divercite/blob/main/player_divercite.py"
    click Random_Player "https://github.com/alexis2707/projet_divercite/blob/main/random_player_divercite.py"
    click Greedy_Player "https://github.com/alexis2707/projet_divercite/blob/main/greedy_player_divercite.py"
    click Advanced_AI "https://github.com/alexis2707/projet_divercite/blob/main/my_player.py"
    click Legacy_v0 "https://github.com/alexis2707/projet_divercite/blob/main/legacy_agent/v0_abyss.py"
    click Legacy_v1 "https://github.com/alexis2707/projet_divercite/blob/main/legacy_agent/v1_abyss.py"
    click Legacy_v2 "https://github.com/alexis2707/projet_divercite/blob/main/legacy_agent/v2_abyss.py"
    click Legacy_v3 "https://github.com/alexis2707/projet_divercite/blob/main/legacy_agent/v3_abyss.py"
    click GUI_HTML "https://github.com/alexis2707/projet_divercite/blob/main/GUI/index.html"
    click GUI_CSS "https://github.com/alexis2707/projet_divercite/blob/main/GUI/main.css"
    click GUI_JS "https://github.com/alexis2707/projet_divercite/blob/main/GUI/main.js"
    click GUI_Assets "https://github.com/alexis2707/projet_divercite/tree/main/GUI/assets/"
    click Requirements "https://github.com/alexis2707/projet_divercite/blob/main/requirements.txt"
    click README "https://github.com/alexis2707/projet_divercite/blob/main/README.md"
    click Rapport "https://github.com/alexis2707/projet_divercite/blob/main/rapport.pdf"
    click ProjetPDF "https://github.com/alexis2707/projet_divercite/blob/main/Projet_Divercite_H2025.pdf"

    %% Styles
    classDef controller fill:#AED6F1,stroke:#3498DB,color:#1B4F72;
    classDef core fill:#ABEBC6,stroke:#27AE60,color:#145A32;
    classDef player fill:#F9E79F,stroke:#F4D03F,color:#7D6608;
    classDef ui fill:#D6EAF8,stroke:#5DADE2,color:#1A5276;
    classDef network fill:#E8DAEF,stroke:#A569BD,color:#4A235A;
    classDef logging fill:#D5DBDB,stroke:#979A9A,color:#424949;
    classDef config fill:#FADBD8,stroke:#EC7063,color:#78281F;
```
