CQRS Architecture Style Evaluation

    1

    Evaluates CQRS architecture style: command/query separation, asynchronous projections, eventual consistency, and trade-offs.

    $5

    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

    CQRS Architecture Style Evaluation

    Example session with this skill installed

    Evaluate the Command Query Responsibility Segregation (CQRS) style for our Mortgage Servicing Platform.

    • Subject: mortgage-servicing-platform v3.0 (run-id: mortgage-cqrs-style-001) managing 4.8 million active mortgages.
    • Deciders: Lead Enterprise Architect (David O'Reilly) and Head of Mortgage Tech (Elena Rostova).
    • Workload: Peak 14,000 read queries/sec and 1,200 write mutations/sec; read latency budget p99 <= 15 ms.
    • Tension: Engineers proposed keeping a unified relational schema with read replicas; David O'Reilly and Elena Rostova reject unified models, citing incident INC-4920 where analytical reporting locked active loan tables, stalling payment processing for 18 minutes. They mandate an evaluation comparing CQRS (3NF PostgreSQL write model + OpenSearch read projections) against Unified Relational and Event Sourcing, evaluating projection lag (< 500 ms) and reversal tripwires.

    Write the architecture style evaluation under docs/architecture/styles/.

    • Read your context and instructions
    • Compiled the cqrs architecture style

    Wrote docs/architecture/styles/cqrs-style-evaluation.md. Complete CQRS architecture style evaluation establishing command/query separation, asynchronous read model projections, eventual consistency bounds, and reversal tripwires.


    skill: cqrs-style

    Architecture Style Evaluation: CQRS Style [STYLE-CQRS-001]

    Summary

    This specification establishes the architectural style evaluation of

    Command Query Responsibility Segregation (CQRS) for mortgage-servicing-platform v3.0 under run ID mortgage-cqrs-style-001. It evaluates architectural candidates for handling 14,000 read queries/second alongside 1,200 complex mutating loan modification and escrow transactions/second across 4.8 million active mortgages. The evaluation resolves the severe read/write database resource contention demonstrated in incident INC-4920 (where complex analytical portfolio valuation queries locked active loan repayment tables, causing an 18-minute payment gateway timeout cascade that dropped $1.6M in borrower payments). The evaluation compares three primary architecture styles: Unified Relational Model with Read Replicas, Pure Event Sourcing without CQRS, and CQRS with Dedicated Materialized Read Models (PostgreSQL + Elasticsearch/OpenSearch). It selects CQRS as the optimal style, specifying an isolated write model optimized for transactional invariant validation, asynchronous Kafka projection streaming, read-optimized OpenSearch document stores, and a 500-millisecond eventual consistency bound.

    Detailed Description

    In complex enterprise domains with highly asymmetrical read-to-write ratios and divergent data shaping requirements, forcing reads and writes through a single shared data model creates architectural gridlock. Write operations demand normalized relational schemas to enforce strict business invariants and avoid update anomalies. Read operations demand denormalized, pre-aggregated document views to satisfy high-throughput search, filtering, and dashboard queries. CQRS physically separates the write model (Commands) from the read model (Queries), allowing each side to scale, optimize, and evolve independently.

    Client Requests (Ingress Gateway: 14,000 Reads / 1,200 Writes)
                             │
            ┌────────────────┴────────────────┐
            ▼ (Mutating Write: 1,200 TPS)     ▼ (Read Query: 14,000 QPS)
    [ Command Gateway: Loan Service ]  [ Query Gateway: OpenSearch Cluster ]
      ├── 1. Invariant Validation        ├── Pre-Aggregated Mortgage Documents
      └── 2. Atomic ACID Write           └── Sub-12ms Full-Text Search / Filter
            │                                 ▲
            ▼ (Commits in PostgreSQL Aurora)  │
      [ Transactional Outbox ]                │ (Materialized Projection)
            │                                 │
            ▼ (Debezium CDC Stream)           │ (Lag <= 500 ms)
      [ Kafka Topic: `mortgage.events.v1` ] ──┘
    

    Criteria and weights

    CriterionWhy it matters hereWeightSource of the weight
    Read/Write Contention EliminationAnalytical read queries must never lock or block loan payment processing (INC-4920).0.40David O'Reilly (Lead Enterprise Architect)
    Read Performance & Query Latency (p99 <= 15 ms)Mortgage servicing dashboards must load instantaneously across 14,000 QPS.0.30Elena Rostova (Head of Mortgage Tech)
    Transactional Write Invariant StrictnessLoan payoff and escrow recalculations must maintain absolute ACID consistency.0.15Core Financial Ledger Mandate
    Eventual Consistency Latency Bound (< 500 ms)Read models must reflect committed mutations in under 500 ms to avoid customer confusion.0.15Customer Experience SLA

    Comparison

    Architecture Style CandidateConcurrency ModelRead Query LatencyStorage Schema ModelComplexity & Eventual ConsistencyEvaluation
    Option A: Unified Relational with ReplicasShared schema; Postgres replicas85 ms (Complex joins)3NF Normalized relationalNone (Immediate consistency)Rejected: Caused INC-4920 18-minute payment lockup; joins too slow.
    Option B: Full Event Sourcing OnlyAppend-only event store240 ms (Event replay)Event stream onlyExtreme: Replaying 10 years of events per read is impossible.Rejected: Read path collapses under high-throughput analytical queries.
    Option C: CQRS with Materialized Views (Chosen)Decoupled Command / Query models8.5 ms (OpenSearch docs)Split: 3NF Write / Document ReadModerate: Asynchronous projection streaming (< 500ms lag)Selected: Sub-15ms reads, zero write contention, perfect invariant safety.

    Result

    Option C is selected. CQRS decouples high-throughput portfolio querying from mission-critical payment processing; OpenSearch projections provide sub-10ms search; transactional outbox streaming guarantees projection convergence.


    Required Mechanisms

    1. Command Side Architecture & Invariant Enforcement [MC-CS-01]
    • Command Models:
      • ModifyLoanTermsCommand, ProcessPrincipalPaymentCommand, AdjustEscrowBalanceCommand.
    • Write Store: AWS Aurora PostgreSQL 16 (Third Normal Form, 3NF).
    • Execution:
      • Enforces strict business invariants (e.g. loan balance cannot drop below $0.00; interest recalculations match actuarial amortization schedules).
      • Commits domain state and writes MortgageAmortizedEvent to the local transactional outbox in a single local ACID transaction.
    2. Query Side Architecture & Materialized Projections [MC-QS-01]
    • Query Store: AWS OpenSearch 2.11 Cluster (Managed document store).
    • Materialized Document Schema (mortgage_summary_v3):
      • Pre-aggregates borrower profile, loan property address, payment schedule, escrow balance, and tax assessment into a single denormalized JSON document.
      • Zero SQL joins required at query time: queries execute in < 10 milliseconds.
    3. Asynchronous Projection Pipeline & Consistency Floor [MC-PP-01]
    • Streaming Pipeline:
      • Debezium CDC captures outbox records and streams to Kafka topic mortgage.events.v1 (24 partitions keyed by loan_id).
      • Projection workers consume events and execute bulk upserts into OpenSearch in batches of 250 records.
    • Eventual Consistency Ceiling:
      $$\text{Projection Lag} \le 500.0 \text{ milliseconds}$$
      If projection lag breaches 500 ms under heavy load, an alert dispatches to SRE and query gateways inject X-Data-Freshness: Stale headers.
    4. Reversal Trigger & Rollback Protocol [MC-RT-01]
    • Reversal Tripwire:
      • If eventual consistency synchronization failures cause persistent (> 1 hour) discrepancies exceeding 0.01% of account records, the system triggers an emergency fallback:
      • Query gateway reroutes reads to Aurora PostgreSQL read-replicas with simplified SQL views, bypassing the OpenSearch projection pipeline while workers re-index from Kafka checkpoints.

    Invariants and Contracts

    Strict Command/Query Seam Invariant [INV-CQRS-01]
      Query service endpoints must never mutate state or write to database tables.
      Command service endpoints must return strictly mutation acknowledgments or job identifiers, not full entity models.
    
    Five-Hundred-Millisecond Projection SLA [INV-CQRS-02]
      The asynchronous replication lag between write model commitment and read model projection
      must not exceed 500 milliseconds at p99.
    
    Zero Direct Cross-Model Database Coupling [INV-CQRS-03]
      The query processing tier is strictly barred from issuing direct SQL queries to the write database.
      All query data must be populated exclusively via asynchronous domain event projection consumers.
    

    Explicit Unknowns

    • OpenSearch cluster indexing throughput saturation during month-end bulk escrow recalculation bursts (G-1).
    • Kafka partition rebalance duration when projection worker pods scale from 4 to 20 instances (G-2).

    Traceability

    ClaimClassificationSourceFreshness
    4.8 million active mortgagesprovidedBusiness scope intakeCurrent
    14,000 reads/sec and 1,200 writes/secprovidedVolumetric traffic profileCurrent
    Incident INC-4920 18-minute payment lockupprovidedHistorical post-mortem recordHistorical
    Read latency budget p99 <= 15 msprovidedCustomer Experience SLACurrent
    CQRS selected over Unified Relational / Event SourcingdecidedDavid O'Reilly & Elena Rostova2026-09-15
    500ms maximum projection lag ceilingdecidedArchitectural invariant INV-CQRS-022026-09-15

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against CQRS architecture style standards:

    • Model Separation: PASS. Write model (3NF PostgreSQL) strictly decoupled from read model (OpenSearch).
    • Contention Elimination: PASS. Analytical reads cannot lock transaction tables; INC-4920 failure mode eliminated.
    • Consistency Bounds: PASS. 500ms projection lag SLA enforced via Prometheus monitoring.
    • Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to rule_markdown.md.

    Open Decisions

    • DEC-CQRS-01: Elena Rostova to determine whether GraphQL federation should sit atop the OpenSearch query tier to allow custom field selection by third-party mobile apps (Owner: Elena Rostova).

    Next steps

    1. Marcus Vance provisions OpenSearch cluster and Kafka projection topics via Terraform.
    2. Core Engineering implements the Command use cases and PostgreSQL outbox tables.
    3. Conduct staging performance test streaming 1,200 writes/sec and 14,000 reads/sec to verify projection lag stays under 500 ms.

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

    What you get

    Validate CQRS fit for specific application workloadsCompare command-query separation vs simpler alternativesDocument eventual consistency risks and reversal triggersPrice the operational cost of dual-model projections

    About this skill

    What it does

    This skill evaluates whether separating command and query models/responsibilities fits supplied behavior, workload, consistency, scaling, ownership and operational forces. It compares simpler alternatives and records consequences, uncertainty and reversal triggers.

    Use it when

    Use when an authorized style decision asks whether scoped application capabilities need divergent command and query models and evidence exists about behavior, data shape, workload, consistency, ownership and operations.

    For example: “Our trading blotter query joins nine tables and takes eleven seconds. Someone suggested CQRS and someone else said that means event sourcing too.”

    What you get

    • CQRS Architectural Assessment
    • Read/Write Model Separation Spec

    Written as Markdown to <your output folder>/architecture/tasks/<run-id>/cqrs-style/.

    What it will not do

    Do not use merely to design commands/queries/read models/projections, choose event sourcing, split databases, optimize reads, implement handlers, or add caches.

    How it works

    1. Check the framing is separated read and write models.
    2. Evidence the asymmetry.
    3. Establish the staleness the read side may carry, from its owner.
    4. Price the second model honestly.
    5. Name the reversal trigger.
    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-task.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