# falvojr/lab-banco-digital-oo architecture

> Architecture diagram of the GitHub repository falvojr/lab-banco-digital-oo, 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/falvojr/lab-banco-digital-oo
- Repository: https://github.com/falvojr/lab-banco-digital-oo

## Overview

##### Project type and purpose
- This is a small Java console application that models a “Digital Bank” domain using object-oriented principles.
- Its goal is to let users deposit, withdraw and transfer money between two types of accounts (checking and savings) encapsulated in an OOP design.

##### File structure
- src/ contains all Java source files:
- IConta.java – the account interface
- Conta.java – abstract base class implementing common logic
- ContaCorrente.java and ContaPoupanca.java – concrete account types
- Cliente.java – represents a bank customer
- Banco.java – holds and manages a collection of accounts; orchestrates operations
- Main.java – entry point (presentation layer)
- There is no external persistence layer or configuration files; state is kept in memory.

##### README for architectural hints
- Emphasis on OOP pillars: abstraction, encapsulation, inheritance, polymorphism.
- No mention of databases or external services; purely an in-process domain model.

##### Components
a. Presentation Layer: Main.java
– CLI or console input → invokes methods on Banco
b. Service/Orchestration Layer: Banco.java
– Maintains a collection (e.g., Map<id, IConta>)
– Exposes methods createAccount(), deposit(), withdraw(), transfer()
c. Domain Model
– IConta (interface)
– Conta (abstract) implements IConta
– ContaCorrente and ContaPoupanca extend Conta
– Cliente associated with Conta (1-to-1 or 1-to-many)
d. Data/State
– In-memory collection of accounts inside Banco
– No external DB or file storage

##### Relationships and interactions
- Main → Banco (calls)
- Banco → IConta (manages references)
- IConta ←– ContaCorrente, ContaPoupanca (implements)
- Conta has a reference to Cliente (aggregation)
- Transfer: Banco retrieves two IConta instances and calls withdraw() and deposit()

##### Architectural patterns and principles
- Interface-based programming: IConta decouples code from concrete account types
- Inheritance: common code in abstract Conta
- Polymorphism: Banco treats all accounts via IConta
- Single-Responsibility: classes each have a single well-defined role

##### Essential elements to capture
- Clear naming of each component
- Interface vs. abstract vs. concrete distinctions
- Aggregation/composition links (e.g., account → client)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        Main["Main"]:::presentation
    end

    %% Service Layer
    subgraph "Service/Orchestration Layer"
        Banco["Banco"]:::service
    end

    %% Domain Model
    subgraph "Domain Model"
        IConta["«interface» IConta"]:::interface
        Conta["«abstract» Conta"]:::abstract
        ContaCorrente["ContaCorrente"]:::concrete
        ContaPoupanca["ContaPoupanca"]:::concrete
        Cliente["Cliente"]:::entity
    end

    %% Relationships
    Main -->|"calls createAccount(), deposit(), withdraw(), transfer()"| Banco
    Banco -->|"manages IConta instances"| IConta
    ContaCorrente -->|extends| Conta
    ContaPoupanca -->|extends| Conta
    ContaCorrente -->|implements| IConta
    ContaPoupanca -->|implements| IConta
    Conta -->|"has Cliente"| Cliente

    %% Click Events
    click Main "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/Main.java"
    click Banco "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/Banco.java"
    click IConta "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/IConta.java"
    click Conta "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/Conta.java"
    click ContaCorrente "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/ContaCorrente.java"
    click ContaPoupanca "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/ContaPoupanca.java"
    click Cliente "https://github.com/falvojr/lab-banco-digital-oo/blob/master/src/Cliente.java"

    %% Styles
    classDef presentation fill:#ffeadb,stroke:#ce7534
    classDef service fill:#e0f7fa,stroke:#007c91
    classDef interface fill:#bbdefb,stroke:#1e88e5
    classDef abstract fill:#eeeeee,stroke:#757575,stroke-dasharray:5 5
    classDef concrete fill:#c8e6c9,stroke:#2e7d32
    classDef entity fill:#fff9c4,stroke:#f9a825
```
