How jmgarridopaz/bluezone works
Purpose and shape
BlueZone is a Java 11/Maven multi-module example of hexagonal architecture for remote city parking. Drivers obtain rates and purchase tickets; inspectors check whether a car has a valid ticket. The business core is isolated from UI, storage, payment, and rate-provider implementations.
Runtime entry and composition
The operational entry point is the startup module, launched by scripts/run_bluezone.sh. It selects implementations declared in scripts/ports-adapters.properties, creates the application, and injects adapters:
• src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/BlueZoneRunner.java
• src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/AdapterSelector.java
• src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/DependencyConfigurator.java
Core application boundary
bluezone-hexagon owns use cases, domain orchestration, and port contracts; it must not depend on concrete adapters. BlueZoneApp is the core factory/composition-facing API, while configuration is exposed separately.
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/factory/BlueZoneApp.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/AppConfigurator.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/AppFromDrivenSide.java
Parking workflows
CarParker implements the driver-facing parking flow: retrieve available rates, accept a purchase request, calculate ticket validity from rate/amount, take payment, and persist the resulting ticket. Its inbound contract is ForParkingCars; payment, rates, and persistence cross outbound interfaces rather than concrete dependencies.
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/CarParker.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driving/forparkingcars/ForParkingCars.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/RateCalculator.java
Inspector workflow
CarChecker implements the second inbound use case: determine illegal parking by finding tickets for the car/rate and evaluating their validity against current time.
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/CarChecker.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driving/forcheckingcars/ForCheckingCars.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forstoringtickets/Ticket.java
Driven ports and supplied infrastructure
Outbound dependencies are explicit contracts for rates, payments, and tickets. The provided runtime implementations are a stub rate source, payment spy, and fake in-memory-like ticket store; they are replaceable through startup selection.
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forobtainingrates/ForObtainingRates.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forpaying/ForPaying.java
• src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forstoringtickets/ForStoringTickets.java
User-facing adapters
The primary interactive adapter is a Spring Boot web UI with MVC controllers and server-rendered templates for rate/ticket operations. It drives the ForParkingCars boundary, not core classes directly. A terminal-oriented checking-cars driver exists for inspector use, with test-oriented implementation shown in the repository.
• src/bluezone-adapter-forparkingcars-webui/src/main/bluezone.adapter.forparkingcars.webui/io/github/jmgarridopaz/bluezone/adapter/forparkingcars/webui/WebUISpringBootApp.java
• src/bluezone-adapter-forparkingcars-webui/src/main/bluezone.adapter.forparkingcars.webui/io/github/jmgarridopaz/bluezone/adapter/forparkingcars/webui/PurchaseTicketController.java
• src/bluezone-driver-forcheckingcars-test/src/main/bluezone.driver.forcheckingcars.test/io/github/jmgarridopaz/bluezone/driver/forcheckingcars/test/ForCheckingCarsTestDriver.java
Main entry points: DependencyConfigurator.java DependencyConfigurator · CarParker.java CarParker · CarChecker.java CarChecker · BlueZoneApp.java BlueZoneApp
Components 20
Startup
Selects and wires adapters at runtime.
- Run script
scripts/run_bluezone.sh - BlueZoneRunner
src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/BlueZoneRunner.java - AdapterSelector
src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/AdapterSelector.java - DependencyConfigurator
src/bluezone-startup/src/main/bluezone.startup/io/github/jmgarridopaz/bluezone/startup/DependencyConfigurator.java
Hexagon Core
Use cases and port contracts, independent of adapters.
- BlueZoneApp
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/factory/BlueZoneApp.java - AppConfigurator
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/AppConfigurator.java - ForParkingCars
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driving/forparkingcars/ForParkingCars.java - CarParker · Gets rates, calculates validity, pays, and stores tickets.
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/CarParker.java - RateCalculator
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/RateCalculator.java - ForCheckingCars
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driving/forcheckingcars/ForCheckingCars.java - CarChecker
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/CarChecker.java - ForObtainingRates
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forobtainingrates/ForObtainingRates.java - ForPaying
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forpaying/ForPaying.java - ForStoringTickets
src/bluezone-hexagon/src/main/bluezone.hexagon/io/github/jmgarridopaz/bluezone/hexagon/ports/driven/forstoringtickets/ForStoringTickets.java
Driving Adapters
User-facing parking and inspection entry points.
- Spring Boot Web UI · MVC rate and ticket interface.
src/bluezone-adapter-forparkingcars-webui/src/main/bluezone.adapter.forparkingcars.webui/io/github/jmgarridopaz/bluezone/adapter/forparkingcars/webui/WebUISpringBootApp.java - PurchaseTicketController
src/bluezone-adapter-forparkingcars-webui/src/main/bluezone.adapter.forparkingcars.webui/io/github/jmgarridopaz/bluezone/adapter/forparkingcars/webui/PurchaseTicketController.java - Checking-cars test driver · Terminal-oriented inspection driver.
src/bluezone-driver-forcheckingcars-test/src/main/bluezone.driver.forcheckingcars.test/io/github/jmgarridopaz/bluezone/driver/forcheckingcars/test/ForCheckingCarsTestDriver.java
Driven Infrastructure
Replaceable rate, payment, and ticket implementations.
- Stub rate source
- Payment spy
- Fake ticket store · In-memory-like ticket persistence.
Connections 24
- Run script → BlueZoneRunner: launches
- BlueZoneRunner → AdapterSelector: selects adapters
- AdapterSelector → DependencyConfigurator: provides selections
- DependencyConfigurator → BlueZoneApp: creates
- DependencyConfigurator → AppConfigurator: configures
- BlueZoneApp → CarParker: exposes
- BlueZoneApp → CarChecker: exposes
- PurchaseTicketController → ForParkingCars: drives
- Spring Boot Web UI → PurchaseTicketController: hosts
- Checking-cars test driver → ForCheckingCars: drives
- ForParkingCars → CarParker: implemented by
- ForCheckingCars → CarChecker: implemented by
- CarParker → RateCalculator: calculates validity
- CarParker → ForObtainingRates: obtains rates
- CarParker → ForPaying: takes payment
- CarParker → ForStoringTickets: stores ticket
- CarChecker → ForStoringTickets: finds tickets
- CarChecker → ForObtainingRates: checks rate
- Stub rate source → ForObtainingRates: implements
- Payment spy → ForPaying: implements
- Fake ticket store → ForStoringTickets: implements
- DependencyConfigurator → Stub rate source: injects
- DependencyConfigurator → Payment spy: injects
- DependencyConfigurator → Fake ticket store: injects