The concept Structure by capability, not by layer
A project structure should make responsibilities easy to find. Many applications start with four folders: controllers, services, repositories and models. As they grow, business rules scatter across all four, and one change to payments touches every folder. A better structure follows business capabilities and the architecture’s boundaries.
textA starting repository structure for Apex
apex-reconciliation/
├── backend/
│ ├── src/main/java/com/apex/reconciliation/
│ │ ├── payment/ api/ application/ domain/ infrastructure/
│ │ ├── settlement/ api/ application/ domain/ infrastructure/
│ │ ├── reconciliation/ application/ domain/ infrastructure/
│ │ ├── exceptioncase/ api/ application/ domain/ infrastructure/
│ │ ├── audit/
│ │ ├── security/
│ │ └── shared/
│ ├── src/main/resources/
│ │ ├── db/migration/
│ │ └── application.yml
│ └── src/test/
├── frontend/
│ └── src/
│ ├── features/ dashboard/ payments/ reconciliation/ exceptions/ audit/
│ ├── components/
│ ├── api/
│ └── types/
├── infrastructure/ local/ aws/
├── docs/ architecture/ adr/ api/ operations/
└── README.mdThis is a starting structure, not a universal standard. Inside each capability, api holds the HTTP boundary, application the workflows, domain the business rules and infrastructure the database and messaging code. The domain depends on nothing outside itself.
Decision A modular monolith first
Start with one modular Spring Boot application. Apex has not shown a need for independently deployed services for every capability. A modular monolith gives clear business boundaries, easy local development, simple database transactions, low operational overhead and faster first delivery. Separate a service later, when workload, scaling, team ownership or reliability needs justify it, as Module 06 recorded in its ADR.
Agree early Engineering standards
| Standard | An example decision for Apex |
|---|---|
| Java and Spring Boot versions | A current long-term-support Java release and a supported Spring Boot line, pinned in the build file |
| Dependency management | One build file with versions managed in one place |
| Formatting | One formatter, enforced in the build |
| Error response format | errorCode, message and correlationId, for every error |
| Logging | Structured JSON logs with correlation IDs; never secrets or raw payloads |
| Test naming | Named after the business behavior, for example rejectsSameTransactionIdWithDifferentAmount |
| Database migrations | Numbered, reviewed migration files; never hand edits in shared databases |
| API versioning | /api/v1 in the path; additive changes only within a version |
| Configuration and secrets | Profiles per environment; secrets from a secret store, never from Git |
Reproducible The local development environment
Another engineer should be able to clone the repository, follow the README and run everything without configuring a cloud account: the Spring Boot backend, PostgreSQL, the message broker or a local substitute, the React development server and the test tools. A container compose file usually starts the infrastructure with one command. Add a health endpoint on day one (Spring Boot Actuator provides liveness and readiness checks) so every environment can prove it is up.
Practice Establish the foundation
Practical exercise
Exercise 02: a reproducible development environment
Set up the project so a new engineer is productive on day one.
- Create the backend and frontend projects.
- Start PostgreSQL locally and add configuration profiles.
- Set up database migrations.
- Write a README with startup instructions.
- Add a health endpoint and one command that runs all tests.
Show a sample README checklist
- Prerequisites: a Java LTS JDK, Node LTS, a container runtime.
- Start infrastructure: one compose command starts PostgreSQL and the broker.
- Run backend: the build tool’s run command with the local profile; migrations run on startup.
- Check: GET /actuator/health returns UP.
- Run all tests: one command; integration tests use a real PostgreSQL container.
2 questions
Check your understanding
What you can do now
- Structure a repository by business capability.
- Justify a modular monolith and keep its boundaries enforced.
- List the engineering standards to agree early.
- Make the local environment reproducible.
← Lesson 01: Convert the Architecture into an Engineering Plan