Package Structure¶
Executive Summary¶
Package Structure defines the Java package convention for Algosure Spring Boot Modulith modules.
Base Convention¶
Use the following convention unless a future engineering decision improves it:
com.algoza.algosure.<module>
application
command
query
service
domain
model
event
service
policy
infrastructure
persistence
integration
messaging
api
rest
dto
mapper
Package Responsibilities¶
| Package | Responsibility |
|---|---|
application.command |
State-changing use-case commands and command handlers. |
application.query |
Read-oriented query objects, query services, and projection access. |
application.service |
Use-case orchestration, transactions, policies, event publication, AIOS and integration coordination. |
domain.model |
Aggregates, entities, value objects, domain state, and invariants. |
domain.event |
Domain-owned events in past-tense business language. |
domain.service |
Domain behavior that does not belong to one aggregate. |
domain.policy |
Domain policies, eligibility rules, approval rules, and decision rules. |
infrastructure.persistence |
Module-owned persistence adapters and repository implementations. |
infrastructure.integration |
Module-owned calls to the Integration Gateway or provider abstractions. |
infrastructure.messaging |
Event publication, subscription, outbox integration, and message adapters. |
api.rest |
REST controller boundary owned by the module. |
api.dto |
Request and response DTOs for API contracts. |
api.mapper |
API mapping between DTOs and application command/query models. |
Test Package Convention¶
src/test/java/com/algoza/algosure/<module>
application
domain
infrastructure
api
modulith
Rules¶
| Rule | Requirement |
|---|---|
| Module internals are private | Other modules do not use internal domain, repository, or infrastructure classes. |
| APIs do not expose aggregates | API DTOs are contract objects, not domain entities. |
| Infrastructure depends inward | Infrastructure implements ports and adapters; it does not define business ownership. |
| Tests mirror package structure | Tests should make boundaries and responsibilities obvious. |