How fabriciofx/mandacarupark works
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