# memelon220/scgprpg architecture

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

- Interactive diagram: https://gitdiagram.com/memelon220/scgprpg
- Repository: https://github.com/memelon220/scgprpg

## Overview

##### Project type and its main purpose
- The README reveals that SCGPRPG is focused on managing RPG character sheets for a role-playing game.
- The project uses object-oriented design principles and is structured in layers, which can be broadly mapped to a full-stack or layered desktop/Java application (even though it isn’t a web app, the separation of concerns remains).

##### File structure to determine the architectural components
- The source code is organized into several key packages:
- The “iu” package: Contains various Tela* classes (e.g., TelaLogin, TelaPrincipal, TelaBatalha, etc.), clearly serving as the User Interface layer.
- The “fachada” package: Acts as a facade layer. It includes classes like FachadaJogador, FachadaNarrador, and the SCGPRPG main facade. This is meant to mediate between the UI and the business logic, simplifying interactions.
- The “servico” package: Hosts the Service layer. It includes:
∙ Business logic classes such as ServicoCampanha, ServicoJogador, and ServicoPersonagem.
∙ The “entidade” sub-package defines the core domain objects (entities) — examples include Campanha, Personagem, Jogador, and various character classes (e.g., Mago, Guerreiro, etc.).
∙ The “excecao” sub-package houses custom exception classes for different domains (campanha, jogador, personagem), ensuring robust error handling.
- The “dados” package: Implements the Data Access layer. It provides interfaces (e.g., IRepositorioCampanhas, IRepositorioJogadores, IRepositorioPersonagens) and concrete repository classes (both file-based and ArrayList-based versions) for managing persistence of the RPG data.
- The “main” package: Contains the Main class which serves as the entry point for launching the application.
- There is also a “tests” package, which indicates that unit testing is integral to the architecture.

- User Interface (IU): Represented by all Tela* classes.
- Facade Layer: Includes FachadaJogador, FachadaNarrador, and SCGPRPG.
- Service/Business Layer: Comprised of ServicoCampanha, ServicoJogador, ServicoPersonagem, and related custom exceptions.
- Data Access Layer: Show interfaces and concrete implementations for repositories in the “dados” package.
- Application Entry Point: Include Main.java.
- Testing: Optional, but you may also include a simplified representation of the tests to indicate testing coverage.

b. Relationships and interactions:
- UI Layer (screens) interacts with the Facade layer, which then directs calls to the Service layer.
- The Service layer processes the core business logic and uses Domain Entities.
- The Data Access layer (repositories) is consumed by the Service layer to persist or retrieve data.
- Exceptions flow upward from the Service layer to the Facade/UI for appropriate handling.

c. Architectural patterns and design principles:
- Facade Pattern: The “fachada” package abstracts and simplifies the interactions between the UI and complex business logic.
- Layered Architecture: Clear separation among UI, Facade, Service, Domain, and Data layers.
- Repository Pattern: Data persistence is managed via interface-based repositories, with multiple implementations (file-based or in-memory).
- Exception Handling: Dedicated exception classes in the “servico/excecao” packages enforce a robust error-handling mechanism.

d. Relevant technologies and frameworks:
- This is a Java project, likely using basic Java SE libraries.
- The naming (Tela*) hints at a GUI framework such as Swing or another similar library, even if not explicitly stated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    mainMain["Main.java"]:::mainStyle
    ui["User Interface (iu)"]:::uiStyle
    facade["Facade (fachada)"]:::facadeStyle
    service["Service/Business (servico)"]:::serviceStyle
    domain["Domain Entities (entidade)"]:::domainStyle
    data["Data Access (dados)"]:::dataStyle
    exc["Exceptions (servico/excecao)"]:::excStyle
    testing["Testing (tests)"]:::testStyle

    %% Flow of control
    mainMain -->|"launches"| ui
    ui -->|"calls"| facade
    facade -->|"delegates"| service
    service -->|"uses"| domain
    service -->|"accesses"| data
    service -->|"throws"| exc
    exc -->|"propagates"| facade
    testing -->|"tests"| service

    %% Click Events
    click mainMain "https://github.com/memelon220/scgprpg/blob/main/src/main/Main.java"
    click ui "https://github.com/memelon220/scgprpg/tree/main/src/iu"
    click facade "https://github.com/memelon220/scgprpg/tree/main/src/fachada"
    click service "https://github.com/memelon220/scgprpg/tree/main/src/servico"
    click domain "https://github.com/memelon220/scgprpg/tree/main/src/servico/entidade"
    click exc "https://github.com/memelon220/scgprpg/tree/main/src/servico/excecao"
    click data "https://github.com/memelon220/scgprpg/tree/main/src/dados"
    click testing "https://github.com/memelon220/scgprpg/tree/main/src/tests"

    %% Styles
    classDef mainStyle fill:#ffcccc,stroke:#880000,stroke-width:2px
    classDef uiStyle fill:#cce5ff,stroke:#1a75ff,stroke-width:2px
    classDef facadeStyle fill:#ffe6cc,stroke:#cc6600,stroke-width:2px
    classDef serviceStyle fill:#d0f0c0,stroke:#33cc33,stroke-width:2px
    classDef domainStyle fill:#ffffcc,stroke:#cccc00,stroke-width:2px
    classDef dataStyle fill:#f4ccff,stroke:#9933ff,stroke-width:2px
    classDef excStyle fill:#ffcccb,stroke:#ff0000,stroke-width:2px
    classDef testStyle fill:#e6e6e6,stroke:#8c8c8c,stroke-width:2px
```
