How do you structure your traditional (non-modular) monolith applications?
architecting modular monolithI’ve written a series of posts about modular monoliths. But I recently realized that it’s been a long time since I’ve written anything about traditional monoliths, except to say that their primary organizing principle is technical. For example, a technically layered architecture or hexagonal architecture.
But beyond this, there’s lots of options.
One key question is how to organize the monolith’s codebase into Maven modules or Gradle projects? There are many ways to do this. Here are some options I’ve seen.
Singular Maven or Gradle project
The simplest option is a Maven project consisting of a single module or a Gradle project with no sub-projects. This is what start.spring.io gives you, for example. It’s great for small applications but can become unwieldy as the application grows.
Maven/Gradle multi-module project: one per layer
Another common option is to have a Maven module or Gradle sub-project per layer. I have vague memories of starting the development of a few applications this way:
mkdir application
cd application
mkdir main web domain infrastructure
...
Each subdirectory is a Maven module or Gradle sub-project.
Maven/Gradle multi-module project: domain + feature modules/projects
There are various other ways to structure a Maven multi-module or Gradle multi-project build. For example, I’ve seen applications with the following structure:
persistence
orinfrastructure
module/projectdomain
module/project containing the entities and value objects of a rich domain model- Multiple ‘feature’ module/projects, each one containing the service and (HTTP) controller classes for a given slice of functionality
This structure is perhaps the most modular although the domain
module can be rather large.
How do you structure your traditional monoliths?
How do you structure your traditional monoliths? I’d love to hear about it in the comments below.
Need help with accelerating software delivery?
I’m available to help your organization improve agility and competitiveness through better software architecture: training workshops, architecture reviews, etc.