I've been exploring a question in software architecture:
Can we build a modular monolith today and gradually move towards microservices without rewriting our application?
I decided to build something around this idea.
Introducing Module-Switch — an open-source Java library for Spring Boot that makes it possible to switch individual application modules between local execution and independent HTTP-based deployment through configuration.
The idea is simple.
Instead of starting with distributed systems complexity, start with a well-structured modular monolith.
As the application evolves, extract modules when there's an actual architectural or operational reason to do so.
Here's what Module-Switch brings to the table:
- Selective module loading: Modules are disabled by default. Only locally enabled modules are loaded into the Spring application context.
- Interface-based communication: Modules interact through dedicated API interfaces rather than depending on each other's implementations.
- Local or remote execution: The same interface works whether a module runs inside the application or in another deployment.
- Configuration-driven extraction: Move a module into its own service by changing configuration instead of rewriting business logic.
- Architectural validation: Detect invalid module dependencies and structural violations during application startup.
- Built-in infrastructure: HTTP client generation, timeouts, retries, idempotency handling, Micrometer observations and trace-context propagation.
One architectural decision I particularly like is that the consuming module doesn't need to know whether its dependency is local or remote.
It simply depends on an interface. Module-Switch handles the rest.
I believe there's an interesting space between a traditional monolith and a distributed microservices architecture that deserves more attention.
Building this library has been a great exercise in exploring modular architecture, Spring Boot internals, dependency boundaries, HTTP communication and distributed systems trade-offs.
The project is open source and available under the Apache 2.0 license.
GitHub: https://github.com/ilyaslabs/module-switch
Technology: Java 25 | Spring Boot 4 | Spring Framework 7 | Modular Monolith | Microservices Architecture
I'd be interested in hearing how other engineers approach modular monoliths and gradual service extraction.
#Java #SpringBoot #SoftwareArchitecture #Microservices #ModularMonolith #DistributedSystems #OpenSource #BackendEngineering