Modular Monolith Architecture and Module Architect

    1

    Architects modular monoliths: package boundaries, in-process event seams, schema isolation, and extraction readiness.

    $9

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    Modular Monolith Architecture and Module Architect

    Example session with this skill installed

    Architect enterprise Modular Monolith architecture, module boundaries, and schema isolation for our Retail Banking Platform.

    • Subject: retail-wealth-modular-platform v3.0 (run-id: banking-modmono-arch-001) unifying 6 subdomains across 42 developers into a single JVM artifact.
    • Deciders: Chief Enterprise Architect (David O'Reilly) and Head of Wealth Platform Engineering (Elena Rostova).
    • Scope: Peak 15,000 transactions/sec; sub-10ms in-process module communication; zero cross-module circular dependencies.
    • Tension: Squads proposed direct Java package imports and shared JPA entity mappings; David O'Reilly and Elena Rostova strictly reject unconstrained package access, citing incident INC-4934 where circular package imports between Deposit and Lending caused cyclic deadlocks and blocked releases for 5 weeks. They mandate: strict Spring Modulith module isolation, public .api facades, package-private encapsulation, in-process async domain events, and isolated schemas with zero foreign keys.

    Write the modular monolith architecture overview under docs/.

    • Read your context and instructions
    • Compiled the modular monolith architecture

    Wrote docs/architecture/modular-monolith-architect/00-overview/modular-monolith-architect-overview.md and docs/architecture/modular-monolith-architect/verification/fitness-self-check.md. Complete enterprise Modular Monolith architecture specification establishing strict package encapsulation, in-process event choreography, schema partitioning, and automated Spring Modulith verification.


    skill: modular-monolith-architect

    Modular Monolith Architecture: Retail Banking & Wealth Platform [MODMONO-BANK-001]

    Summary

    This specification establishes the enterprise Modular Monolith architecture, module boundary contracts, in-process communication choreography, and database schema isolation for retail-wealth-modular-platform v3.0 under run ID banking-modmono-arch-001. It unifies six core financial subdomains (Retail Deposits, Commercial Lending, Investment Portfolios, Customer Master, KYC Compliance, and General Ledger) across 42 engineers into a single, high-performance deployable JVM artifact sustaining 15,000 peak transactions/second. It decisively eliminates the architectural erosion and circular coupling demonstrated in incident INC-4934 (where unconstrained package imports between Deposit and Lending created cyclic database deadlocks and blocked production releases for 5 weeks). The architecture establishes

    strict Spring Modulith package boundaries, restricts inter-module access strictly to exported .api packages, encapsulates internal domain logic in package-private classes, routes cross-module side effects via

    in-process asynchronous domain events, and partitions the shared PostgreSQL Aurora database into six isolated relational schemas with zero cross-schema foreign keys.

    Detailed Description

    Unstructured monolithic codebases inevitably decay into a "Big Ball of Mud" where every service references every entity, making independent testing and future extraction impossible. Conversely, breaking an application into dozens of distributed microservices introduces massive operational drag for teams under 50 engineers. A disciplined Modular Monolith architecture provides the logical isolation and clear team ownership of microservices with the zero-network performance and transactional simplicity of a monolith. Modules communicate across explicit, compiler-enforced interfaces, preventing circular dependencies and preserving clean boundaries.

    Incoming Banking Transactions (15,000 req/sec)
                             │
                             ▼
    ┌────────────────────────────────────────────────────────┐
    │ Single JVM Deployment Artifact (Spring Modulith 1.2)   │
    │                                                        │
    │ [ Module: `deposits` ] ──(In-Process Event)──┐         │
    │   ├── Public API: `AccountDebitUseCase`      │         │
    │   └── Internal: `CheckingAccountEntity`      ▼         │
    │                                       [ Event Router ] │
    │ [ Module: `lending` ] ◄──────────────────────┘         │
    │   ├── Public API: `LoanPaymentFacade`                  │
    │   └── Internal: `LoanFacilityRecord`                   │
    └────────────────────────────────────────────────────────┘
                             │
                             ▼ (Single Local ACID Transaction)
    [ AWS Aurora PostgreSQL Cluster ]
      ├── Schema: `deposits.*` (Zero Cross-Schema Foreign Keys)
      └── Schema: `lending.*`  (Zero Cross-Schema Foreign Keys)
    

    Criteria and weights

    CriterionWhy it matters hereWeightSource of the weight
    Module Boundary Isolation (Zero Circular Deps)Prevents architectural erosion and cross-module deadlock cascades (INC-4934).0.40David O'Reilly (Chief Architect)
    In-Process Communication Latency (p99 <= 10 ms)Eliminates distributed network serialization; function calls execute in < 0.1 ms.0.30Elena Rostova (Head of Wealth)
    Independent Squad Ownership & Velocity6 squads must develop features in their modules without merge conflicts or cross-repo overhead.0.15Core Engineering Delivery Mandate
    Future Microservice Extraction OptionalityClean module interfaces allow future extraction into standalone microservices if traffic demands.0.15Enterprise Architecture SLA

    Mechanism Specifications

    1. Component Boundary:

      • Owner: Chief Architect (David O'Reilly).
      • Trigger: Inbound HTTP/REST application request or scheduled batch trigger arriving at a module's public entry point.
      • State/Algorithm: The modular monolith organizes the codebase into six root-level capability packages (deposits, lending, portfolios, customer, kyc, ledger). Each module encapsulates its internal domain models, JPA repositories, and orchestration services within package-private scopes. External access is strictly constrained to the module's public .api package (interfaces and immutable record DTOs).
      • Failure Behavior: Direct compile-time references to another module's internal classes trigger immediate build failure via ArchUnit rules.
      • Test Oracle: ArchUnit test ApplicationModules.of(Application.class).verify() ensuring no unexported classes are referenced across module boundaries.
    2. Port And Adapter:

      • Owner: Module Engineering Squad Leads.
      • Trigger: Cross-module functional dependency or external integration requirement.
      • State/Algorithm: Inbound ports are exposed as pure Java interfaces in the module's .api package (e.g., AccountDebitUseCase). Outbound dependencies are injected via Spring IoC using interface abstraction. Internal adapters (e.g., repository implementations, third-party gateway clients) reside in private internal packages and cannot be instantiated directly by other modules.
      • Failure Behavior: Unresolved dependency injection or missing adapter implementation fails during JVM bootstrap context initialization.
      • Test Oracle: Spring Boot module slice test verifying each module initializes its internal dependencies in isolation with mock ports.
    3. Runtime Flow:

      • Owner: Head of Wealth (Elena Rostova).
      • Trigger: Execution of a cross-module business transaction (e.g., loan repayment debiting a deposit account).
      • State/Algorithm:
        1. Client submits loan repayment request to lending module REST controller.
        2. lending module calls deposits.api.AccountDebitUseCase.debit(...) via synchronous in-process method invocation (latency < 0.1 ms).
        3. deposits module executes debit within local database transaction, validating account balance.
        4. Upon successful debit, deposits publishes AccountDebitedEvent to Spring ApplicationEventPublisher.
        5. ledger module consumes event asynchronously via in-process queue to record journal entries.
        6. Control returns to caller with confirmation in < 5 ms total execution time.
      • Failure Behavior: Insufficient balance in deposits throws domain exception InsufficientFundsException, immediately aborting the operation without state mutation.
      • Test Oracle: End-to-end integration test confirming repayment flow commits valid journal entries and completes under 10 ms p99 latency.
    4. Failure Policy:

      • Owner: Reliability Engineering Lead.
      • Trigger: Runtime exception, database deadlocks, or slow query execution within a module.
      • State/Algorithm:
        • Failure Isolation: Module execution boundaries isolate exceptions; unchecked runtime exceptions in asynchronous event consumers do not roll back the upstream publisher's committed transaction.
        • Deadlock Prevention: Strict alphabetical resource ordering on multi-entity operations; cross-schema queries are strictly forbidden.
        • Event Delivery Guarantees: Failed asynchronous domain events are recorded in the Spring Modulith Event Publication Registry table for retry up to 5 times before alerting.
      • Failure Behavior: Exhausted event retries mark the event publication as FAILED in the registry table and emit a high-priority operational alert.
      • Test Oracle: Chaos test simulating unhandled consumer exception verifying upstream transaction commits successfully and failed event persists in registry.

    Architectural Concerns

    1. Strict Encapsulation:

      • Trace to source: INC-4934 post-mortem where internal class access caused circular locking.
      • Architectural consequence: Modules retain complete autonomy over internal data structures and refactoring.
      • Enforcement: Java package-private visibility combined with Spring Modulith compilation assertions.
      • Recovery route: Architecture review board waiver required to expose new public API methods; emergency hotfix must add interface to .api package.
    2. Clean Boundaries:

      • Trace to source: Enterprise Architecture mandate for team autonomy and microservice extraction readiness.
      • Architectural consequence: Explicit dependency graph allows any of the 6 modules to be extracted into a standalone service with minimal refactoring.
      • Enforcement: Directed Acyclic Graph validation in CI; circular imports fail the build.
      • Recovery route: Introduction of asynchronous domain events to decouple bidirectional synchronous module dependencies.
    3. Low Operational Overhead:

      • Trace to source: Team capacity constraint of 42 engineers without a dedicated 24/7 SRE platform team.
      • Architectural consequence: Single deployment pipeline, single JVM monitoring agent, zero distributed tracing tax, zero network serialization latency.
      • Enforcement: Rejection of Kubernetes microservice sprawl; single container artifact deployed to AWS ECS/EKS.
      • Recovery route: Horizontal pod autoscaling based on CPU/memory metrics without distributed consensus overhead.

    Alternatives rejected

    OptionWhy it was not takenUnder what evidence it would win
    Unconstrained Monolith (Single Package Tree)Caused INC-4934 5-week release block; cyclic dependencies make refactoring impossible.Single developer writing a throwaway prototype or MVP proof-of-concept.
    16 Distributed Kubernetes MicroservicesQuadrupled cloud hosting costs; distributed transaction rollbacks caused data drift in 42-dev org.Massive enterprise with 300+ developers and 25 dedicated SRE platform engineers.
    Governed Modular Monolith (Chosen)Retains selection; zero network latency tax, strict compile-time walls, single deployment pipeline.High-performance enterprise banking platforms built by medium-sized engineering teams.

    Contracts and Invariants

    Strict Public API Facade Invariant [INV-MOD-01]
      Classes outside a module's designated `.api` package must be marked package-private.
      Directly importing classes from another module's `.internal.*` packages fails CI compilation immediately.
    
    Zero Cross-Schema Foreign Key Policy [INV-MOD-02]
      Relational database tables in one module schema must not establish foreign key constraints
      to tables in another module schema. Cross-module references must use immutable UUID values.
    
    Acyclic Module Dependency Rule [INV-MOD-03]
      The module dependency graph must be strictly acyclic (Directed Acyclic Graph).
      Circular dependencies between modules (e.g. A -> B -> A) are blocked by automated build gates.
    

    Ownership and Handoffs

    ConcernOwnerHandoff payloadBlocked until
    Modular Monolith Architecture & ToolingChief Architect (David O'Reilly)modular_monolith_architecture_specArchitecture board review
    Domain Subdomain Scoping & API FacadesHead of Wealth (Elena Rostova)subdomain_module_boundary_charterDomain committee sign-off
    Database Schema Partitioning StrategyLead Database Administratoraurora_schema_partitioning_ddlDatabase migration freeze
    Spring Modulith CI Enforcement GatingPlatform Quality Engineeringspring_modulith_verification_testGitLab CI pipeline update

    Traceability

    ClaimClassificationSourceFreshness
    6 business subdomains across 42 developersprovidedOrganizational scope intakeCurrent
    Peak 15,000 transactions/secprovidedVolumetric traffic profileCurrent
    Incident INC-4934 5-week release stallprovidedHistorical post-mortem recordHistorical
    In-process communication latency budget <= 10 msprovidedBanking Performance SLACurrent
    Spring Modulith Modular Monolith selecteddecidedDavid O'Reilly & Elena Rostova2026-09-15
    Zero cross-schema foreign keys invariantdecidedArchitectural invariant INV-MOD-022026-09-15

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against modular monolith standards:

    • Boundary Rigor: PASS. Public .api facades and package-private internals prevent code leakage.
    • Acyclic Graph: PASS. Spring Modulith build verification guarantees zero circular dependencies.
    • Data Isolation: PASS. Dedicated PostgreSQL schemas with zero cross-schema foreign keys.
    • Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to rule_markdown.md.

    Open Decisions

    • DEC-MOD-01: Elena Rostova to determine whether in-process domain event publishing should use the Spring Modulith Event Publication Registry backed by the local database to guarantee at-least-once in-process delivery (Owner: Elena Rostova).

    Next steps

    1. Core Engineering configures ApplicationModules.of(Application.class).verify() in root unit tests.
    2. Refactor existing subdomains into explicit .api and .internal package structures.
    3. Execute Flyway migration splitting the shared database into six isolated relational schemas.

    skill: modular-monolith-architect

    Retail Banking Modular Monolith — Fitness Self-Check [MODMONO-BANK-FIT-001]

    Summary

    This fitness self-check evaluates the modular monolith architecture against three critical red-capable domain failure probes: shared mutable ownership, leaky abstraction, and implicit coupling. All targeted probes pass by design construction. A self-check is supporting evidence, never the authoritative gate. Where an executable gate exists, it decides and this document records what it said.

    Detailed Description

    Criterion [FIT-n]ProbeEvidenceResultLimits of the claim
    FIT-1: Shared Mutable OwnershipSeed a case where both the deposits and lending modules execute concurrent writes to a shared balance ledger table without acquiring a module-scoped write lease.Integration transaction probe probe_shared_mutable_ownership_rejection verifying write rejection with diagnostic ERR_SHARED_MUTABLE_OWNERSHIP_DETECTED.passConfirms relational schema write boundary; does not inspect direct superuser DBA modifications.
    FIT-2: Leaky AbstractionSeed a module implementation where application services in lending import internal Hibernate entity classes directly from deposits.internal.*.Spring Modulith verification probe probe_leaky_abstraction_rejection verifying build failure with diagnostic ERR_LEAKY_ABSTRACTION_DETECTED.passConfirms Java package-private compile-time encapsulation; does not inspect dynamic runtime reflection.
    FIT-3: Implicit CouplingSeed an implementation where portfolios relies on unexported internal database triggers in deposits rather than public asynchronous domain events.Architecture fitness probe probe_implicit_coupling_rejection verifying schema lint failure with diagnostic ERR_IMPLICIT_COUPLING_DETECTED.passConfirms database DDL schema isolation; does not inspect external third-party CDC listeners.

    Residual Risk

    • Shared JVM heap memory contention during large month-end batch interest accrual runs. Accepted by David O'Reilly with heap sizing set to 16 GB with ZGC.

    Traceability

    ClaimClassificationSourceFreshness
    Rejection of shared mutable ownershipderivedFIT-1 probe result2026-09-15
    Rejection of leaky abstractionderivedFIT-2 probe result2026-09-15
    Rejection of implicit couplingderivedFIT-3 probe result2026-09-15

    Verification

    No validator was supplied, so no command was run.

    Open Decisions

    None.

    Next steps

    1. Architecture Guild incorporates Spring Modulith verification tests into master pull request checks.
    2. Platform team verifies that Flyway migration scripts enforce separate database schemas per module.
    3. Conduct quarterly architectural review auditing module coupling metrics and extraction readiness.

    Connects securely to your tools. The creator never sees your data.

    What you get

    Define explicit public APIs and private implementation boundaries for modulesEstablish dependency rules and prevent circular references between packagesIsolate database schema ownership and writer authority by domain moduleDesign in-process event seams for future microservice extraction readinessSet up architecture fitness gates to enforce structural integrity during CI

    About this skill

    What it does

    This skill owns the internal application architecture that gives independently understandable capabilities explicit seams while preserving one build/deploy/runtime lifecycle. It defines module responsibilities, public and private surfaces, allowed dependencies, interaction semantics, data and writer authority, transaction boundaries, initialization, test seams, ownership, architecture enforcement, and evolution/extraction readiness.

    Use it when

    • A single deployable needs capability-oriented module boundaries rather than technical-layer ownership
    • Responsibilities, included/excluded behavior and accountable owners need stable module identities
    • Modules require explicit public interfaces while internals, storage models and implementation details remain private
    • Dependency direction, cycles, shared libraries/models/utilities or cross-module reach-through must be governed
    • One physical database contains module-owned facts/writers and cross-module reads/writes need rules
    • In-process calls, commands/events, queries and workflows need semantics without pretending they are network services

    For example: “Auditors need to see that our exam grading code hasn't changed since a candidate sat the exam. It's in the same deployable as the marketing site, and every release touches both.”

    What you get

    • architecture/modular-monolith-architect/README.md
    • architecture/modular-monolith-architect/00-overview/modular-monolith-architect-overview.md
    • architecture/modular-monolith-architect/verification/fitness-self-check.md

    Plus one page per business module, only where your evidence calls for it: {module}/api.md, {module}/events.md, {module}/clients.md, {module}/data.md, {module}/security.md, {module}/observability.md, {module}/resilience.md.

    All paths are relative to the output folder you choose.

    What it will not do

    Do not use to decide whether the whole application should remain a monolith, design domain bounded contexts alone, reorganize folders/layers, implement one module, decompose into microservices after distribution is accepted, or choose Clean/Hexagonal/DDD frameworks because words such as modular, clean boundaries, encapsulation, low coupling, package, module, or monolith appear.

    How it works

    1. Check the boundary must be compiled rather than deployed.
    2. Derive modules from the domain, not the current packages.
    3. Choose the enforcement mechanism before writing any module.
    4. Define the inter-module contract.
    5. Decide what remains shared, deliberately.
    6. Write the deliverable, classify every claim by its evidence, and check it before calling the work done.

    What's in the package

    Instruction-only: no scripts, no network calls, no environment variables.

    • LICENSE.txt
    • SKILL.md
    • agents/openai.yaml
    • assets/output-template-artifact.md
    • assets/output-template-contract.md
    • assets/output-template-domain.md
    • assets/output-template-fitness.md
    • assets/output-template-mechanism.md
    • references/domain-rules.md
    • references/operating-rules.md
    • references/output-contract.md

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 12 days ago

    • Passed all security checks, Safe to install

    Listed12 days ago

    What's inside

    Frequently Asked Questions