CQRS
CQRS (Command and Query Responsibility Segregation) is a pattern that splits a system's actions into commands and queries. Greg Young first described it. The core idea is separating them, because they play very different roles, so each side is optimized as needed. It's like a restaurant with 2 counters: one only takes orders and the other only hands them out; neither slows the other at rush hour.
CQRS is often used together with event sourcing. In that case, the event store is the write model and the official source of truth. The read model is built from the events, as materialized views ready to read. It's like an accounting ledger (the events) and the monthly statement your bank sends (the view): the statement is built from the ledger, and if it's lost, it's rebuilt.
CQRS has advantages: reads and writes scale separately, optimizing and changing the architecture is easier, it stays close to business logic with loose coupling, queries avoid complex JOINs and the boundaries of the system's behavior are clear. It's like a supermarket with tills only for paying and aisles only for browsing: if 10 times more people are browsing, you add aisles, not tills.
CQRS helps when: read performance must be tuned separately from write performance; the system will change over time, with several model versions or business rules that change often; it integrates with other systems, especially with event sourcing, where the failure of 1 part shouldn't take down the others; and for more security, controlling who can write. In a small app with 10 users, though, it's extra complexity. It's like having a separate kitchen and dining room: worth it in a restaurant, not at home.
