CQRS in Python: Clean Reads, Clean Writes
From ArjanCodes · · 22 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.
If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.
Description
💡 Check out MongoDB Atlas: https://www.mongodb.com/atlas.
When your FastAPI list endpoint starts pulling full documents just to compute derived fields, it’s usually a sign your read and write models are drifting apart.
In this video, I refactor a tickets API (FastAPI + MongoDB) using CQRS, explain projections and eventual consistency, and show when this architecture is worth the added complexity, and when it’s not.
🔥 GitHub Repository: https://git.arjan.codes/2026/cqrs.
🎓 ArjanCodes Courses: https://www.arjancodes.com/courses.
💬 Join my Discord server: https://discord.arjan.codes.
⌨️ Keyboard I’m using: https://amzn.to/49YM97v.
🔖 Chapters: 0:00 Intro 0:48 The Starting Point: A Perfectly Reasonable FastAPI App 3:53 Where the First Real Pain Shows Up 5:28 CQRS Explained 6:50 Example: Requirements Change 7:59 Separate Command Intent 12:36 Split Write Storage and Read Storage 13:00 Why MongoDB Fits Nicely 14:33 Step 4: Add a Projector 18:49 What Improves After the Refactor 20:39 When to Use CQRS 21:09 When Not to Use CQRS 21:44 Final Thoughts
#arjancodes #softwaredesign #python