# joaopsoliveira03/estg-ed architecture

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

- Interactive diagram: https://gitdiagram.com/joaopsoliveira03/estg-ed
- Repository: https://github.com/joaopsoliveira03/estg-ed

## Overview

##### Project type and purpose
- This is a Java-based monolithic application that bundles:
- A custom “Java Data Structures” library (Collections, Graphs, Lists, Queues, Stacks, Trees, HashTables)
- A “Game” core API that uses those data structures to implement game logic (Entities, Utilities, Exceptions)
- A console-based management UI (“GameManagement” menus for players, locals, routes, shortest paths)
- A PlayerSimulator/demo module
- JSON-based persistence (gameData.json, players.json, etc.) loaded via json-simple
- A Maven build (pom.xml) with unit tests (GameTest.java)

##### File structure and infer layers
- src/main/java/Collections → custom data structures library
- src/main/java/Game → core game API and model (Entities, CustomCollections extension, Enumerations, Exceptions, Utilities)
- src/main/java/GameManagement → console UI layer (menus, commands, shortest-path computation)
- src/main/java/PlayerSimulator → sample client/demo that drives the Game API
- src/main/java/Main.java → application entry point that ties the GameManagement menus and PlayerSimulator
- src/main/resources → external dependencies (json-simple) and JSON files for persistence

1. Collections Library Module
– Packages: Collections/Graphs, …/Lists, …/Queues, …/Stacks, …/Trees, /HashTables, /Exceptions, SortSearch
– Provides ADTs and algorithms
2. Game Core Module
– Game/API: Game.java, GameImpl.java
– Game/Entities: domain objects (Player, Local, Portal, Connector, Team, associations)
– Game/CustomCollections: ExtendedNetwork
– Game/Utilities, Game/Exceptions
3. Persistence & Configuration
– JSON files (gameData.json, players.json, locals.json, routes.json, shortestPath.json)
– JSON-simple library (json-simple-1.1.1.jar)
4. Console UI / Application Layer
– GameManagement: MainMenu, PlayersManagementMenu, LocalsManagementMenu, RoutesManagementMenu, ShortestPaths
– Main.java entry point
5. Client / Simulator
– PlayerSimulator/PlayerDemo.java
6. Build & Test
– Maven (pom.xml)
– Unit tests (GameTest.java)

- Console UI → invokes → Game Core API
- PlayerSimulator → invokes → Game Core API
- Game Core → delegates to → Collections Library for data structures and graph algorithms
- Game Core ↔ Persistence Layer (loads/saves JSON via JSON-simple)
- GameManagement & PlayerSimulator ← configuration/read JSON files
- Main ← wires up UI menus and/or Simulator calls

##### Architectural patterns & principles
- Layered architecture:
- Data Structures layer (low-level, reusable)
- Domain / Core layer (business rules, Entities, Exceptions)
- Application / UI layer (console menus, user workflows)
- Infrastructure layer (JSON persistence, external lib)
- Separation of concerns: each module has a clear responsibility
- Dependency direction: higher layers depend on lower layers; no cyclic dependencies

##### Technology call-outs
- Java 8+
- Maven for build, dependency management (pom.xml)
- JSON-simple for parsing JSON configuration/persistence
- JUnit (or similar) for unit testing

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers as subgraphs
    subgraph "Data Structures Layer"
        direction TB
        CollectionsLib["Collections Library Module"]:::collections
    end

    subgraph "Domain / Core Layer"
        direction TB
        GameAPI["Game API"]:::core
        GameImpl["GameImpl"]:::core
        Entities["Game Entities"]:::core
        CustomColl["ExtendedNetwork & ADT"]:::core
        Utilities["Validations"]:::core
        Exceptions["Game Exceptions"]:::core
        Enumerations["Game Enumerations"]:::core
    end

    subgraph "Infrastructure / Persistence Layer"
        direction TB
        Persistence["JSON Persistence & Config"]:::persistence
        JSONFiles["JSON Files"]:::persistence
        JSONLib["json-simple library"]:::persistence
    end

    subgraph "Application / UI Layer"
        direction TB
        UIMenus["Console UI Menus"]:::ui
        MainMenu["MainMenu"]:::ui
        GameMgmtMenu["GameManagementMenu"]:::ui
        ShortestPaths["ShortestPaths UI"]:::ui
        PlayersMgmt["PlayersManagement"]:::ui
        LocalsMgmt["LocalsManagement"]:::ui
        RoutesMgmt["RoutesManagement"]:::ui
        MainEntry["Main"]:::ui
    end

    subgraph "Client / Simulator"
        direction TB
        Simulator["PlayerSimulator"]:::client
        PlayerDemo["PlayerDemo"]:::client
    end

    subgraph "Build & Test"
        direction TB
        Pom["pom.xml"]:::infra
        Tests["GameTest"]:::infra
    end

    %% Dependencies and data flows
    UIMenus -->|"invokes"| GameAPI
    Simulator -->|"invokes"| GameAPI
    GameAPI -->|"uses data structures"| CollectionsLib
    GameAPI -->|"load/save JSON"| Persistence
    UIMenus -->|"reads config"| JSONFiles
    Simulator -->|"reads config"| JSONFiles
    Persistence -->|"parses via"| JSONLib
    MainEntry -->|"wires up"| UIMenus
    MainEntry -->|"wires up"| Simulator

    %% Shortest path flow
    ShortestPaths -->|"computeShortestPath()"| GameImpl
    GameImpl -->|"delegates to"| CustomColl
    CustomColl -->|"graph algorithms"| CollectionsLib
    CustomColl -->|"writes result"| JSONFiles

    %% UI menus composition
    UIMenus --> MainMenu
    UIMenus --> GameMgmtMenu
    UIMenus --> ShortestPaths
    UIMenus --> PlayersMgmt
    UIMenus --> LocalsMgmt
    UIMenus --> RoutesMgmt

    %% Build & Test relations
    Pom --> GameAPI
    Pom --> CollectionsLib
    Pom --> UIMenus
    Tests --> GameAPI

    %% Click Events
    click CollectionsLib "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/Collections"
    click GameAPI "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/Game/API/Game.java"
    click GameImpl "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/Game/API/GameImpl.java"
    click Entities "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/Game/Entities"
    click CustomColl "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/Game/CustomCollections/ExtendedNetwork.java"
    click Utilities "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/Game/Utilities/Validations.java"
    click Exceptions "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/Game/Exceptions"
    click Enumerations "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/Game/Enumerations"
    click JSONFiles "https://github.com/joaopsoliveira03/estg-ed/blob/main/gameData.json"
    click JSONLib "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/resources/json-simple-1.1.1.jar"
    click MainMenu "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/GameManagement/MainMenu.java"
    click GameMgmtMenu "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/GameManagement/GameManagement/GameManagementMenu.java"
    click ShortestPaths "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/GameManagement/GameManagement/ShortestPaths.java"
    click PlayersMgmt "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/GameManagement/PlayersManagement"
    click LocalsMgmt "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/GameManagement/LocalsManagement"
    click RoutesMgmt "https://github.com/joaopsoliveira03/estg-ed/tree/main/src/main/java/GameManagement/RoutesManagement"
    click MainEntry "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/Main.java"
    click PlayerDemo "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/main/java/PlayerSimulator/PlayerDemo.java"
    click Pom "https://github.com/joaopsoliveira03/estg-ed/blob/main/pom.xml"
    click Tests "https://github.com/joaopsoliveira03/estg-ed/blob/main/src/test/java/GameTest.java"

    %% Styles
    classDef collections fill:#ADD8E6,stroke:#000;
    classDef core fill:#90EE90,stroke:#000;
    classDef ui fill:#FFA500,stroke:#000;
    classDef persistence fill:#D3D3D3,stroke:#000;
    classDef client fill:#FFD700,stroke:#000;
    classDef infra fill:#DCDCDC,stroke:#000;
```
