# ldelaforet/projetred architecture

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

- Interactive diagram: https://gitdiagram.com/ldelaforet/projetred
- Repository: https://github.com/ldelaforet/projetred

## Overview

##### Project type and purpose
- From the file tree and README, this is a standalone, text-based RPG/game engine (“Projet RED”) implemented in Go.
- It reads JSON “database” files (items, maps, story, quizz, etc.), runs game logic (crafting, combat, map traversal), handles user I/O, and persists state to a save file.

##### File structure
- Top-level:
- README.md, docs/ (roadmap), misc/ (assignment questions), push.bat
- src/—all source code and assets
- src/
- Database/ — JSON data files
- Internals/ — core modules (crafting, display, fightSystem, JSON manager, map utilities, save utilities, data structures, user input)
- main.go — entry point
- save.sav — runtime save file
- testLeo.go, testLili.go — test harnesses
- No external services or network; single binary.

##### README for additional insights
- Minimal README; no architecture section. We infer roles of modules from names.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Actors
    Player(("Player")):::actor
    Leo(["Test Harness - Leo"]):::test
    Lili(["Test Harness - Lili"]):::test

    %% Data Layer
    subgraph "Data Layer"
        DB["JSON Database\n(crafts.json, items.json,\nmaps.json, menu.json,\nquizz.json, story.json,\nstrings.json)"]:::datastore
    end

    %% Go Binary
    subgraph "Go Binary"
        Main["Entry Point\n(main.go)"]:::module
        JSONMgr["JSON Manager"]:::module

        subgraph "Logic Modules"
            Craft["Crafting Logic"]:::module
            Combat["Combat System"]:::module
            MapUtils["Map Utilities"]:::module
        end

        subgraph "I/O Modules"
            Display["Display Module"]:::module
            Input["User Input Module"]:::module
        end

        subgraph "Persistence"
            SaveUtil["Save Utilities"]:::module
        end

        subgraph "Data Structures"
            Structs["Shared Data Structures"]:::module
            Pointer["In-Memory State Container"]:::module
        end
    end

    %% Save File
    SaveFile["Save File\n(save.sav)"]:::datastore

    %% Relationships
    Player -->|plays| Main
    Leo -->|tests| Main
    Lili -->|tests| Main

    DB -->|Load JSON| JSONMgr
    JSONMgr -->|Populate| Structs
    JSONMgr -->|Populate| Pointer

    Main -->|initialize| JSONMgr
    Main -->|render| Display
    Main -->|input| Input
    Display <-->|interact| Input

    Main -->|craft action| Craft
    Main -->|combat action| Combat
    Main -->|move/map| MapUtils

    Main -->|save action| SaveUtil
    SaveUtil -->|Write Save| SaveFile

    %% Click Events
    click DB "https://github.com/ldelaforet/projetred/tree/master/src/Database/"
    click SaveFile "https://github.com/ldelaforet/projetred/blob/master/src/save.sav"
    click Main "https://github.com/ldelaforet/projetred/blob/master/src/main.go"
    click JSONMgr "https://github.com/ldelaforet/projetred/blob/master/src/Internals/jsonManager.go"
    click Craft "https://github.com/ldelaforet/projetred/blob/master/src/Internals/craft.go"
    click Combat "https://github.com/ldelaforet/projetred/blob/master/src/Internals/fightSystem.go"
    click MapUtils "https://github.com/ldelaforet/projetred/blob/master/src/Internals/mapUtils.go"
    click SaveUtil "https://github.com/ldelaforet/projetred/blob/master/src/Internals/saveUtils.go"
    click Display "https://github.com/ldelaforet/projetred/blob/master/src/Internals/display.go"
    click Input "https://github.com/ldelaforet/projetred/blob/master/src/Internals/userInput.go"
    click Structs "https://github.com/ldelaforet/projetred/blob/master/src/Internals/structures.go"
    click Pointer "https://github.com/ldelaforet/projetred/blob/master/src/Internals/pointerContainer.go"
    click Leo "https://github.com/ldelaforet/projetred/blob/master/src/testLeo.go"
    click Lili "https://github.com/ldelaforet/projetred/blob/master/src/testLili.go"

    %% Styles
    classDef module fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef datastore fill:#DFFFE0,stroke:#28A745,color:#28A745,stroke-width:2px;
    classDef actor fill:#FFE0F0,stroke:#D6336C,color:#D6336C;
    classDef test fill:#F0F0F0,stroke:#888888,color:#888888,stroke-dasharray: 5 5;
```
