Optimal Architecture
- Mircea Girigan, Backend Engineer at BoatyardX
In recent years, software architectures have evolved rapidly, reflecting the changing needs of software developers and the business environment. The shift from traditional monoliths to microservices has brought numerous benefits, but even their proponents acknowledge that using them involves significant costs, making them useful only in the context of an extraordinarily complex system.
Traditionally, application frameworks have provided structural guidance, such as annotations in the Spring Framework (@Controller, @Service, @Repository).
However, recently, there has been a shift to a paradigm where it is recommended that the code structure aligns as closely as possible with the problem domain the application addresses, leading to better-structured applications that are easier to understand and maintain.Microservice-based systems have become ubiquitous in recent years. However, modular monolithic systems have recently regained popularity.
“You shouldn't start a new project with microservices, even if you're sure your application will be big enough to make it worthwhile.”
In this context, the concept of “Modular Monoliths” has emerged as an intermediate solution that combines the simplicity and coherence of a monolith with modular structure and organisation. In this article, we will explore what a modular monolith is, its advantages and disadvantages, and discuss scenarios where this architecture can be considered optimal.

What are Modular Monoliths?
A modular monolith is an architectural approach where an application is developed as a single artifact but is divided into distinct and autonomous modules, while maintaining a single codebase and deployment. Each module has clear responsibilities and is developed, tested, and maintained independently of the other modules. This allows teams to retain the advantages of a traditional monolith, such as version management simplicity, while benefiting from a modular structure that facilitates organisation, scalability, and maintainability of the application.

Key Features
- Separation of Responsibilities: Each module has a well-defined responsibility and is isolated from other modules.
- Well-Defined Interfaces: Modules communicate with each other through clearly defined interfaces, reducing tight dependencies.
- Independent Development: Each module can be developed and tested separately, allowing teams to work in parallel without interfering with each other.
- Single Artifact: All modules are combined into a single artifact, simplifying the deployment and monitoring process.
Advantages of Modular Monoliths
- Simplicity of Implementation and Deployment: Modular monoliths allow for the deployment of a single artifact in a production environment, reducing infrastructure complexity. This is particularly beneficial for small teams or organisations that do not want to manage the complexity of a microservices architecture.
- Consistency and Maintenance: Managing a single codebase facilitates applying updates and maintaining consistency. Since all modules are part of the same application, synchronisation and compatibility between modules are guaranteed.
- Performance and Efficiency: Modular monoliths can offer superior performance by avoiding network latencies associated with microservice communication. Additionally, data consistency is easier to ensure in a monolithic architecture.
- Dependency Management: Dependencies between modules are easier to manage since they are all part of the same artifact. This reduces the risk of incompatibilities and facilitates refactoring.
Disadvantages of Modular Monoliths
- Scalability Limitations: Although modular monoliths offer a degree of scalability, they cannot achieve the flexibility and granularity provided by microservices. For applications that require independent scalability of components, the modular monolith can become a constraint.
- Code Management Complexity: As the application grows, managing a large codebase can become complicated. It requires strict discipline in development and a clearly defined module structure to avoid “spaghetti code.”
- Technology and Language Restrictions: All modules in a modular monolith must be developed using the same technologies and programming languages, which can limit the flexibility of teams to choose the most suitable tools for each component.
- Development and Deployment Time: Although modular monoliths can reduce initial development time, eventually, managing and deploying updates can become more time-consuming, especially if modules are not well isolated.
When to Implement a Modular Monolith?
- Small or Medium-Sized Projects: For small or medium-sized applications, where the complexity and volume of code do not justify the infrastructure complexity required for microservices, the modular monolith is an ideal choice. It allows for rapid development and simplified deployment.
- Small Development Teams: Small development teams can benefit from the modular monolith, as it simplifies coordination and collaboration. By avoiding the need to manage a distributed ecosystem, teams can work more efficiently.
- Rapidly Evolving Projects: In the initial stages of product development, where requirements are constantly changing, the modular monolith allows for rapid and iterative adaptation without introducing the additional complexity of microservices. It provides a solid foundation that can be scaled and refactored as the application evolves.
- High-Performance Systems: For applications that require high performance and low latency, the modular monolith can offer a more efficient solution compared to distributed architectures. Network latencies are reduced, and data consistency is easier to manage within a single application.
Implementation – Spring Modulith
Spring Modulith is a project from Spring, in our opinion, second in importance only to Spring Boot, which supports program developers in building modular monolithic applications.
It helps structure code around domains, making it easier to manage and evolve.

Application Modules
We can consider the domain or business modules of our application as direct sub-packages of the main application package. In a Spring Boot application, a module is a unit of functionality consisting of the following parts:
- An API exposed to other modules, implemented through Spring bean instances or events published by the module.
- Internal implementation components that should not be accessed by other modules.
- References to APIs exposed by other modules in the form of Spring bean dependencies or configuring an event listener that listens for events generated by other modules.
├───pom.xml
├───src
├───main
│ ├───java
│ │ └───main-package
│ │ └───module A
│ │ └───module B
│ │ ├───sub-module B
│ │ └───module C
│ │ ├───sub-module C
│ │ │ MainApplication.java
Verifying the Modular Structure
We can use the verify() method from ApplicationModules to identify if our code’s modularity respects the intended constraints. Spring Modulith uses the ArchUnit project to provide this capability.
@Test
void verifiesModularStructure() {
ApplicationModules modules = ApplicationModules.of(Application.class);
modules.verify();
}
Documenting Modules
We can document the relationships between the modules of a project. Spring Modulith offers the generation of diagrams based on PlantUML.
@Test
void createModuleDocumentation() {
ApplicationModules modules = ApplicationModules.of(Application.class);
new Documenter(modules)
.writeDocumentation()
.writeIndividualModulesAsPlantUml();
}
Conclusion
Modular monoliths represent a balanced approach in software architecture, combining the simplicity and efficiency of the traditional monolith with the organisational benefits of microservices. In the right context, they can offer an optimal solution for developing and scaling applications, allowing teams to focus on delivering functionality quickly without sacrificing performance or internal flexibility. Although not a universal solution, modular monoliths are worth considering for projects that fit the discussed scenarios, offering a viable compromise between monolithic structure and microservices complexity.
This approach provides development teams with an efficient way to manage application complexity as they evolve, ensuring that performance and maintenance remain manageable. Modular monoliths, therefore, represent an important step in the evolution of software architectures, offering a welcome balance between tradition and innovation.
Need help architecting your next software project? Our team at BoatyardX specialises in building scalable, maintainable applications. Get in touch!
References
- “Modular Monolith: A Primer”, Simon Brown, 2019.
- “Microservices For Greenfield?”, Sam Newman, 2015.
- “MonolithFirst”, Martin Fowler, 2015.
- “Microservices vs. Monoliths: The Case for a Symbiotic Design”, Mark Richards, 2016.
Read more tech topics
In recent years, software architectures have evolved rapidly, reflecting the changing needs of software developers and the business environment.
There’s a common belief in the digital world: paying for something guarantees a better experience. But is this always true?
How convenient would it be to have a quick solution at hand for developing a static web page, a proof-of concept application, a single-page application, or even a complete web app built with microservices?
Building a cloud-based product can be daunting for startups, especially when faced with a plethora of choices, trade-offs, and challenges.
Proud of your product but sense it hasn’t quite hit its stride? UX audits are an essential tool to ensure it hits its full potential.
At Adminovate 2024, Karolina Coates, Head of Design at BoatyardX, joined industry leaders to discuss the evolving landscape of user experience (UX) and fintech innovation.
The BoatyardX DiscoverX workshop is a collaborative, interactive experience where clients have the opportunity to explore product and technology concepts.
In today's fast-paced digital landscape, businesses are continually seeking innovative solutions to manage their infrastructure efficiently – and for good reason.
Within the sphere of modern applications, prioritising user experience has become paramount.
Whether you are a startup or a large corporation, it's likely you will face many of the same challenges in building the first version of a new product or application. We explore some of the critical success factors and lessons learned from supporting a broad range of clients in bringing new products to life.
We live in the times when seamless user experiences (UI/UX) are the cornerstone of digital success, businesses are strategically leveraging the nearshore advantage to bolster their design teams.
Before solution and implementation are merged into the upstream branch, a code review is a crucial stage in the software development cycle to obtain a second viewpoint.
Computer vision has become a significant influence in the remaking of numerous sectors in a time when technological innovation is the driving force.
In today's rapidly evolving digital landscape, the success of a product or service hinges on the user experience (UX) it delivers.
With over four years of experience as a .NET developer under his belt, Petru felt it was time to explore the growing demand for DevOps expertise, specifically in technologies.
WebRTC (Web Real-Time Communication) is an open-source transformative technology that revolutionizes real-time audio, video, and data sharing within web browsers.
What do startup founders and enterprise technology leaders have in common? Nightmare stories about unintended consequences of technology decisions.
Cognitive biases can have a significant impact on the quality and effectiveness of software being developed. How can software developers mitigate this impact?
At a recent Microsoft event speakers and attendees struggled to best describe the significance of AI and its potential impact on enterprise.
More organisations are starting to realise that the cloud is a great enabler for innovation, not just a more efficient way of running IT applications and services.
Skill gaps, high employee turnover and fierce competition for limited talent have only added to the pressure that businesses are facing from inflation. Though it may seem counter intuitive, it’s actually a good time to modernise or even replace applications, because they could be compounding your skills challenges.
Meta has called 2023 ‘a year of efficiency’ and they are far from alone in the corporate world. Many businesses are knuckling down, shedding staff and focussing on the old adage of ‘doing more with less’. Belt tightening is a business initiative again, like the bad old days of 2008.
Factors to consider when deciding whether or not to automate your QA.
At close to 4 years old BoatyardX has, for most of its short life, been a remote-first organisation.
How design helps you validate your product ideas within our Discovery Framework.
Have you ever wondered what it takes to have that genius spark that leads to groundbreaking, brilliant ideas?
This article briefly highlights the challenges faced by many software companies, and elements of the solutions we’ve helped map out with them.
This article briefly highlights the challenges faced by many software companies, and elements of the solutions we’ve helped map out with them.
De-risk your product build by answering fundamental product and technology questions up front
Often entrepreneurs skip brand development because of budget limitations or lack of available skillset. A solid brand strategy is, however, the foundation of a successful venture which stands out from the crowd.
An active player on the IT scene, BoatyardX was featured by Today Software Magazine (RO) in tech related topics as a subject matter expert.
When technology isn’t your core business it makes sense to go to an external partner such as BoatyardX. Discover how this approach works for Toronto-based Global Solutions Team.
We were recently interviewed by a new Software Insider website using a Reporter BOT, and it didn't go great! Sometimes #articialintelligence isn't as smart as we'd expect! See what you think.
Irish technology company BoatyardX delivers a compelling case for moving to the cloud to ensure the viability of your operations for the future.
As a growing start up, it’s important not to lose sight of the security and controls required on the IT systems that underpin the business. See how a recent Pen Test has resulted in significant cost savings at BoatyardX.
Pushing a new product live and then helping to demonstrate to early beta customers is a fantastic experience for a software development team.
BoatyardX’s approach to the cloud uses scalable, flexible Kubernetes technology. For businesses undergoing digital transforming, it is the wisest strategy.
Covid-19 represents both a driver and an opportunity for businesses to use digital innovation and build new products and applications more rapidly.