From monolith portlets to modular architecture
A monolithic portal starts simple, but over time it becomes a tightly coupled system where even small changes can trigger unexpected side effects. Every deployment carries the full system, so risk scales with size, not change.
The real problem is not code volume but dependency entanglement. Features that should be independent end up sharing services, database access layers, and even UI components, making isolation almost impossible.
What modular architecture changes
Modular architecture aims to fix this by introducing clear boundaries. Instead of one large deployable unit, the system is split into smaller, independently deployable modules that own their own responsibilities.
In Liferay-based systems, this usually maps to OSGi modules. Each module encapsulates a specific capability like services, APIs, or UI components, and communicates through well-defined contracts instead of direct coupling.
Map the system before rewriting
The first step in migration is not rewriting anything, but mapping the system. Identify business capabilities first, not technical layers. Features like user management, billing, reporting, or content handling become natural module candidates.
Sequence the migration
Once boundaries are defined, sequencing becomes critical. You cannot migrate everything at once. Start with low-risk, high-isolation modules that have minimal dependencies, and gradually move toward core systems.
During migration, a strangler pattern works best. New modules gradually replace parts of the monolith while both systems run in parallel. This reduces risk and allows continuous delivery instead of a big-bang release.
Own your data and contracts
Data ownership is usually the hardest part. In monoliths, tables are shared freely. In modular systems, each module should ideally own its data model or at least expose controlled access through services.
Communication between modules should avoid direct database access or internal class calls. Instead, use service contracts, events, or APIs. This keeps boundaries clean and prevents hidden coupling from creeping back in.
// api module: the only thing other modules depend on
public interface BillingService {
Invoice createInvoice(long accountId, BigDecimal amount);
}
// impl module: registered as an OSGi component, hidden behind the API
@Component(service = BillingService.class)
public class BillingServiceImpl implements BillingService {
@Override
public Invoice createInvoice(long accountId, BigDecimal amount) {
// owns its own data model, exposed only through this contract
}
}Trade-offs and testing
Trade-offs are unavoidable. Modular systems introduce overhead in communication, deployment complexity, and version management. But they pay off in scalability, maintainability, and team autonomy.
Testing strategy also changes. Instead of testing one large system, you test modules independently and then validate integration points separately. This reduces debugging time when issues occur.
In the end, modularization is not a one-time migration but an ongoing discipline. Systems tend to drift back into monolith-like structures unless boundaries are actively maintained and enforced.