# nestor-florehs/practica1_fase1_dpo architecture

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

- Interactive diagram: https://gitdiagram.com/nestor-florehs/practica1_fase1_dpo
- Repository: https://github.com/nestor-florehs/practica1_fase1_dpo

## Overview

##### Project Type and Purpose
- This is a Java application that clearly follows a layered architecture. The source files are split into three broad categories: Business (domain logic), Persistence (data access), and Presentation (user interface).
- The database directory shows that JSON files (for characters, items, stats, teams) are used as the persistent data store, suggesting that the application reads from and writes to JSON-based "databases."
- Although the README is minimal, the project name “Pr-ctica-1_DPO_Fase2” indicates it might be an academic or practical exercise focusing on data operations, domain modeling, and separation of concerns.

##### Analyzing the File Structure
- The src directory is divided into:
- Business: Contains domain models (e.g., Character, Battle, Item, Team) and their managers, as well as utility classes like JsonValidation.
- Persistence: Defines the DAO (Data Access Object) interfaces (e.g., CharacterDao, ItemDao) and provides JSON-specific implementations. This reflects a clear DAO pattern.
- Presentation: Includes user interface components such as Controller, Input, Output, and options menus.
- There is also a Main.java that likely ties together all these components.
- The database folder holds the actual JSON files that act as the datastore.

- Main Components to Represent:
- Presentation Layer (UI): Contains Controller, Input, Output, etc. These handle user interactions.
- Business Layer (Domain Logic): Includes core domain classes (e.g., Character, Battle, Team) and corresponding managers. This layer encapsulates the application’s logic.
- Persistence Layer (DAO): Contains DAO interfaces and their JSON implementation classes. This layer abstracts data storage/retrieval.
- Database: JSON files (characters, items, stats, teams) serving as the low-level datastore.
- Data Flow / Interactions:
- The Presentation layer passes user inputs to the Business layer.
- The Business layer manages the application logic and, when required, calls the Persistence layer for data operations.
- The Persistence layer’s DAO implementations interact with the JSON files in the database folder to perform read/write operations.
- Architectural Patterns:
- Layered Architecture: Clear separation between Presentation, Business, and Persistence.
- DAO Pattern: Abstracts the data sources via interfaces and concrete JSON implementations.
- MVC/MVP Elements: Though not fully separated explicitly, the Presentation layer serves as the interface and delegates tasks to the Business logic.

##### Emphasizing Essential Architectural Elements
- This level of granularity helps in understanding each layer’s responsibility and how data flows from the user input (Presentation) all the way to data persistence (JSON files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Main["Main.java"]:::entry

    subgraph "Presentation Layer"
        pres1["Controller"]:::presentation
        pres2["Input"]:::presentation
        pres3["Output"]:::presentation
        pres4["OptionManageTeam"]:::presentation
        pres5["OptionStartingMenu"]:::presentation
    end

    subgraph "Business Layer"
        biz1["Character"]:::business
        biz2["Battle"]:::business
        biz3["Item"]:::business
        biz4["Team"]:::business
        biz5["CharacterManager"]:::business
        biz6["BattleManager"]:::business
        biz7["ItemManager"]:::business
        biz8["TeamManager"]:::business
        biz9["JsonValidation"]:::business
    end

    subgraph "Persistence Layer"
        pers1["CharacterDao"]:::persistence
        pers2["ItemDao"]:::persistence
        pers3["StatDao"]:::persistence
        pers4["TeamDao"]:::persistence
        pers5["CharacterJsonDao"]:::persistence
        pers6["ItemJsonDao"]:::persistence
        pers7["StatJsonDao"]:::persistence
        pers8["TeamJsonDao"]:::persistence
    end

    subgraph "Database"
        db1["characters.json"]:::database
        db2["items.json"]:::database
        db3["stats.json"]:::database
        db4["teams.json"]:::database
    end

    %% Connections between layers
    Main -->|"starts"| pres1
    pres1 -->|"invokes"| biz5
    biz5 -->|"reads/writes"| pers5
    pers5 -->|"accesses"| db1

    biz7 -->|"reads/writes"| pers6
    pers6 -->|"accesses"| db2

    biz8 -->|"reads/writes"| pers8
    pers8 -->|"accesses"| db4

    %% DAO interfaces linked to their implementations
    pers1 -->|"implemented_by"| pers5
    pers2 -->|"implemented_by"| pers6
    pers3 -->|"implemented_by"| pers7
    pers4 -->|"implemented_by"| pers8

    %% Click Events for Application Entry Point and Presentation Layer
    click Main "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Main.java"
    click pres1 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Presentation/Controller.java"
    click pres2 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Presentation/Input.java"
    click pres3 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Presentation/Output.java"
    click pres4 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Presentation/OptionManageTeam.java"
    click pres5 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Presentation/OptionStartingMenu.java"

    %% Click Events for Business Layer
    click biz1 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/Character.java"
    click biz2 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/Battle.java"
    click biz3 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/Item.java"
    click biz4 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/Team.java"
    click biz5 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/CharacterManager.java"
    click biz6 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/BattleManager.java"
    click biz7 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/ItemManager.java"
    click biz8 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/TeamManager.java"
    click biz9 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Business/JsonValidation.java"

    %% Click Events for Persistence Layer
    click pers1 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/CharacterDao.java"
    click pers2 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/ItemDao.java"
    click pers3 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/StatDao.java"
    click pers4 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/TeamDao.java"
    click pers5 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/implementations/CharacterJsonDao.java"
    click pers6 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/implementations/ItemJsonDao.java"
    click pers7 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/implementations/StatJsonDao.java"
    click pers8 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/src/Persistence/implementations/TeamJsonDao.java"

    %% Click Events for Database
    click db1 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/database/characters.json"
    click db2 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/database/items.json"
    click db3 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/database/stats.json"
    click db4 "https://github.com/nestor-florehs/practica1_fase1_dpo/blob/main/database/teams.json"

    %% Styles
    classDef entry fill:#fcc,stroke:#333,stroke-width:2px;
    classDef presentation fill:#f9c,stroke:#333,stroke-width:2px;
    classDef business fill:#bbf,stroke:#333,stroke-width:2px;
    classDef persistence fill:#bfb,stroke:#333,stroke-width:2px;
    classDef database fill:#ffb,stroke:#333,stroke-width:2px;
```
