# fabriciofx/mandacarupark architecture

> Architecture diagram of the GitHub repository fabriciofx/mandacarupark, 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/fabriciofx/mandacarupark
- Repository: https://github.com/fabriciofx/mandacarupark

## Overview

##### Project Type and Purpose
- This is a self-contained, full-stack Java application for managing an automobile parking lot (“Mandacaru Park”), designed as a teaching example of a complete system.
- It exposes three user interfaces (CLI, GUI, Web), a domain model, persistence via an embedded H2 database, plus a set of utility modules (code‐generation, templating, ticket/image generation, text formatting).

##### File Structure Analysis
- Top-level layers and packages:
- com.github.fabriciofx.mandacarupark.cli – command‐line UI (App, Menu, Opcao*)
- …gui – desktop UI (Launcher, Dashboard)
- …web – HTTP server, pages, browser integration
- …adapter – mapping JDBC ResultSet → domain objects
- …db – low-level persistence: Session, Statement, Script, Pagination, data sources (H2File/H2Memory), connections
- core domain under com.github.fabriciofx.mandacarupark: Entrada, Locacao, Pagamento, Saida, Regras, etc.
- utility packages: datahora, dinheiro, id, media, template, text, ticket/imagem
- Resources: SQL schema (mandacarupark.sql), HTML/CSS templates under src/main/resources/webapp.

##### Architectural Patterns
- Layered/Hexagonal architecture
- Domain at the center (pure business entities and interfaces)
- Adapters/Repositories on one side (ResultSetAs*, SQL implementations)
- Multiple input/output ports: CLI, GUI, Web UI, Ticket image generators
- Use of “Fake” vs “Sql” implementations for in-memory testing or real DB persistence (dependency inversion)

##### Main Components & Relationships
- UI Layer
- CLI → calls domain services directly, prints to Console (Unix/Windows)
- GUI → Launcher starts Dashboard, invokes domain services, renders Swing/JavaFX components
- Web → WebServer binds HTTP routes, uses Template engine + HttpPage to render HTML, drives a browser process
- Application/Server Layer
- Server (main entrypoint) wires UI, adapters, session, data sources
- Domain Layer
- Core model classes (Entrada, Locacao, Pagamento, etc.) and rules (Regra implementations)
- Interfaces for repositories (EntradaSql, PagamentoSql, etc.) and “Of”/“Fake” for testing
- Persistence Layer
- H2 database (file or memory) accessed via JDBC Session/Statement
- Scripts for schema setup
- Utility Modules
- Code generation (EAN13, QR)
- Template rendering (HtmlTemplate)
- Ticket/image creation (ImagemCodeQr, ImagemTexto)
- DataHora, Dinheiro, Id providers
- Text formatting, pagination support

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "UI Layer"
        CLI["CLI UI\n(App, Menu, Opcao*)"]:::ui
        GUI["GUI UI\n(Launcher, Dashboard)"]:::ui
        Web["Web UI\n(App, HttpPage, Browser, Pages)"]:::ui
    end

    subgraph "Server/Application Layer"
        Server["Server\n(Server.java)"]:::server
        ServerH2["H2 Servers\n(ServerH2, WebServer)"]:::server
    end

    subgraph "Domain Layer"
        Domain["Domain Model\n(Entrada, Locacao, Pagamento, Saida, Regra, etc.)"]:::domain
        RepositoryIface["Repository Interfaces"]:::domain
    end

    subgraph "Persistence Layer" 
        Entrada["Entrada Sql/Fake/Html"]:::persistence
        Locacao["Locacao Sql/Fake/Html"]:::persistence
        Pagamento["Pagamento Sql/Fake/Html"]:::persistence
        Saida["Saida Sql/Fake/Html"]:::persistence
    end

    subgraph "Adapter Layer"
        Adapters["JDBC Adapters\n(ResultSetAs*)"]:::adapter
    end

    subgraph "Database Infrastructure"
        DBInfra["DB Infra\n(Session, Statement, Script, Pagination)"]:::db
        DataSrc["DataSources\n(H2File, H2Memory)"]:::db
        Script["Schema Script\n(mandacarupark.sql)"]:::db
    end

    subgraph "Utilities"
        CodeGen["Code Generation\n(CodeBarEan13, CodeQr)"]:::util
        Template["Template Engine\n(HtmlTemplate)"]:::util
        TicketImg["Ticket/Image Utils\n(ImagemCodeQr, ImagemTexto, ImagemPapel)"]:::util
        DataHora["Date/Time Providers"]:::util
        Dinheiro["Money Handling"]:::util
        IdGen["ID Generation"]:::util
        Media["Media Abstraction"]:::util
        TextFmt["Text Formatting"]:::util
    end

    CLI -->|"invokes"| Server
    GUI -->|"invokes"| Server
    Web -->|"HTTP GET/POST"| Server
    Server -->|"calls"| RepositoryIface
    RepositoryIface -->|"implemented by"| Entrada
    RepositoryIface -->|"implemented by"| Locacao
    RepositoryIface -->|"implemented by"| Pagamento
    RepositoryIface -->|"implemented by"| Saida
    Entrada -->|"uses JDBC"| Adapters
    Locacao -->|"uses JDBC"| Adapters
    Pagamento -->|"uses JDBC"| Adapters
    Saida -->|"uses JDBC"| Adapters
    Adapters -->|"runs SQL"| DBInfra
    DBInfra -->|"reads/writes"| DataSrc
    Server -->|"executes"| Script
    Web -->|"renders via"| Template
    Template -->|"loads templates"| Web
    TicketImg -->|"uses"| Media
    TicketImg -->|"uses"| CodeGen

    classDef ui fill:#ADD8E6,stroke:#000
    classDef server fill:#98FB98,stroke:#000
    classDef domain fill:#90EE90,stroke:#000
    classDef persistence fill:#FFA500,stroke:#000
    classDef adapter fill:#DDA0DD,stroke:#000
    classDef db fill:#F0E68C,stroke:#000
    classDef util fill:#D3D3D3,stroke:#000

    click CLI "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/cli"
    click GUI "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/gui"
    click Web "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/web"
    click Server "https://github.com/fabriciofx/mandacarupark/blob/main/src/main/java/com/github/fabriciofx/mandacarupark/Server.java"
    click Entrada "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/entrada"
    click Locacao "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/locacao"
    click Pagamento "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/pagamento"
    click Saida "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/saida"
    click Adapters "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/adapter"
    click DBInfra "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/db"
    click DataSrc "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/db/ds"
    click Script "https://github.com/fabriciofx/mandacarupark/blob/main/src/main/resources/mandacarupark.sql"
    click CodeGen "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/code"
    click Template "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/template"
    click TicketImg "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/ticket/imagem"
    click DataHora "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/datahora"
    click Dinheiro "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/dinheiro"
    click IdGen "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/id"
    click Media "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/media"
    click TextFmt "https://github.com/fabriciofx/mandacarupark/tree/main/src/main/java/com/github/fabriciofx/mandacarupark/text"
```
