Backend Implementation Strategy¶
Purpose¶
The Backend Implementation Strategy defines how future backend work should turn Algosure architecture into a Spring Boot Modulith implementation.
Strategy¶
| Principle | Implementation Direction |
|---|---|
| Modulith first | Build one Spring Boot backend with explicit application modules. |
| DDD aligned | Modules mirror Domains and own their source facts. |
| API contract aligned | Controllers implement approved API specifications only. |
| Database ownership | PostgreSQL tables and Liquibase migrations belong to owning modules. |
| Event coordinated | Cross-module workflows use internal events where appropriate. |
| Secure by default | Spring Security validates Keycloak tokens before business work. |
| Multi-tenant by default | Tenant and OrganizationId context are mandatory for customer data. |
| Future extraction ready | Dependencies, persistence, events, and APIs support later microservice extraction. |
Dependency Direction¶
flowchart TB
Api[api]
Application[application]
Domain[domain]
Infrastructure[infrastructure]
External[External Providers]
Api --> Application
Application --> Domain
Infrastructure --> Application
Infrastructure --> Domain
Infrastructure --> External
Implementation Rules¶
- The domain layer must not depend on API, persistence, messaging, or provider implementation details.
- Application services coordinate transactions, authorization context, repositories, events, and external ports.
- Infrastructure implements persistence, messaging, integration, and provider adapters.
- Controllers translate HTTP contracts into commands and queries.
- Shared kernel remains minimal and must not become a generic utility or business dumping ground.
Delivery Sequencing¶
- Define module boundary and package structure.
- Define commands, queries, DTOs, and application services.
- Define domain model and policies.
- Define persistence ownership and migrations.
- Define internal events and outbox requirements.
- Add security, validation, exception, and test coverage.