# nikita-ynov/projet-red_console-game architecture

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

- Interactive diagram: https://gitdiagram.com/nikita-ynov/projet-red_console-game
- Repository: https://github.com/nikita-ynov/projet-red_console-game

## Overview

##### Project type and purpose
- This is a monolithic, console‐based RPG game written in Go.
- There is no client/server split; it’s a single binary that runs in a terminal, handling user input, game state, and rendering text/ASCII art.

##### File-structure analysis
- src/main.go – entry point and core game loop (invokes menus, handles user input).
- src/structure/structure.go – domain models (Player, Goblin, Inventory, Equipment, Achievement, etc.).
- src/functions/ – “service” layer implementing game mechanics, grouped by feature:
- menu.go → main menu controller
- characterCreation.go, initCharacter.go → character setup
- initGoblin.go, traningFight.go, characterTurn.go → combat handling
- merchant.go → shop interactions
- blacksmith.go → crafting/forging
- equipment.go, DisplayEquipment.go → equipment management
- achievement.go, DisplayAchievement.go → success system
- displayInfo.go → HUD/stats rendering
- takePot.go, takeSkill.go → item/skill usage
- randomWeapon.go, additional helpers
- src/utils/ – cross-cutting helpers (inventory ops, adding/removing stats or coins, death & respawn, exit/pause, success checks).
- src/data/gameData.go – static data definitions (monsters, items, skill parameters).
- src/image/goblinImage.go – ASCII art renderer for goblins.

##### Key architectural patterns
- Layered modular design:
- Presentation/CLI layer (main.go + displayInfo, DisplayEquipment, DisplayAchievement).
- Controller/Service layer (functions/*).
- Domain/Model layer (structure/* + data/*).
- Utility layer (utils/*).
- In-memory state: all game state lives in Go structs passed around by reference.

##### Main components
- CLI Interface (User I/O)
- Main Orchestrator (main.go)
- Domain Models (structure package)
- Game Data (data package)
- Services / Feature Modules (functions package, subdivided into CombatService, MerchantService, BlacksmithService, AchievementService, CharacterService, MenuService)
- Utilities (utils package)
- ASCII Art Renderer (image package)

##### Interactions and data flow
- User → CLI Interface → Main Orchestrator
- Main calls MenuService → depending on choice, delegates to the appropriate service.
- Services read/write Domain Models (player struct, inventory, monsters) and reference static Game Data.
- Services invoke Utility functions for state mutations (add/remove HP, coins, inventory ops, death checks).
- Services (displayInfo, DisplayEquipment, DisplayAchievement) read model state and output to CLI.
- ASCII Art Renderer may be called during combat to show monster art.

##### Technologies
- Go modules and packages (src/functions, src/utils, src/structure, src/data, src/image)
- In-memory Go structs, no external DB
- Terminal I/O via fmt.Scan, fmt.Print

##### Essential elements
- Don’t omit the utils layer—it centralizes state mutations.
- That services depend on both domain models and static data.
- Monolithic, in-process architecture: everything lives in the Go binary.
- Keep components coarse enough for clarity but fine enough to show separation of concerns.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    CLI["CLI Interface"]:::presentation
    Main["Main Orchestrator\n(main.go)"]:::presentation
    CLI -->|"user input/output"| Main
    Main -->|"delegate to MenuService"| MenuService

    %% Services Layer
    subgraph "Services Layer"
        MenuService["Menu Service\n(menu.go)"]:::service
        CharacterService["Character Service\n(characterCreation.go,\ninitCharacter.go)"]:::service
        CombatService["Combat Service\n(initGoblin.go,\ntraningFight.go,\ncharacterTurn.go,\nrandomWeapon.go)"]:::service
        MerchantService["Merchant Service\n(merchant.go)"]:::service
        BlacksmithService["Blacksmith Service\n(blacksmith.go)"]:::service
        AchievementService["Achievement Service\n(achievement.go,\nDisplayAchievement.go)"]:::service
        EquipmentService["Equipment Service\n(equipment.go,\nDisplayEquipment.go)"]:::service
    end

    Main --> MenuService
    MenuService -->|"choose character"| CharacterService
    MenuService -->|"choose combat"| CombatService
    MenuService -->|"choose merchant"| MerchantService
    MenuService -->|"choose blacksmith"| BlacksmithService
    MenuService -->|"choose achievement"| AchievementService
    MenuService -->|"choose equipment"| EquipmentService

    %% Domain and Data
    Domain["Domain Models\n(structure.go)"]:::domain
    GameData["Game Data\n(gameData.go)"]:::data
    ASCII["ASCII Art Renderer\n(goblinImage.go)"]:::image

    CharacterService -->|"reads/writes Player struct"| Domain
    CombatService -->|"reads/writes Player & Monster"| Domain
    MerchantService -->|"reads/writes Inventory"| Domain
    BlacksmithService -->|"reads/writes Equipment"| Domain
    AchievementService -->|"reads/writes Achievement"| Domain
    EquipmentService -->|"reads/writes Equipment"| Domain

    CharacterService -->|"references static data"| GameData
    CombatService -->|"references static data"| GameData
    MerchantService -->|"references static data"| GameData
    BlacksmithService -->|"references static data"| GameData
    AchievementService -->|"references static data"| GameData
    EquipmentService -->|"references static data"| GameData

    CombatService -->|"calls renderGoblin()"| ASCII

    %% Utilities Layer
    Utils["Utilities\n(add.go, addcoin.go,\nremove.go, inventory.go,\nisWasted.go, exit.go)"]:::utils
    CharacterService -->|"calls helper"| Utils
    CombatService -->|"calls helper"| Utils
    MerchantService -->|"calls helper"| Utils
    BlacksmithService -->|"calls helper"| Utils
    AchievementService -->|"calls helper"| Utils
    EquipmentService -->|"calls helper"| Utils

    %% Display back to CLI
    DisplayService["Display Service\n(displayInfo.go)"]:::presentation
    CharacterService -->|"display stats"| DisplayService
    EquipmentService -->|"display equipment"| DisplayService
    AchievementService -->|"display achievements"| DisplayService
    DisplayService -->|"output to CLI"| CLI

    %% Click Events
    click Main "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/main.go"
    click Domain "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/structure/structure.go"
    click GameData "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/data/gameData.go"
    click MenuService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/menu.go"
    click CharacterService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/characterCreation.go"
    click CombatService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/initGoblin.go"
    click MerchantService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/merchant.go"
    click BlacksmithService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/blacksmith.go"
    click AchievementService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/achievement.go"
    click EquipmentService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/equipment.go"
    click DisplayService "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/functions/displayInfo.go"
    click ASCII "https://github.com/nikita-ynov/projet-red_console-game/blob/main/src/image/goblinImage.go"
    click Utils "https://github.com/nikita-ynov/projet-red_console-game/tree/main/src/utils"

    %% Styles
    classDef presentation fill:#FFA500,stroke:#333,stroke-width:1px
    classDef service fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef domain fill:#98FB98,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef utils fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef image fill:#DDA0DD,stroke:#333,stroke-width:1px
```
