Difficulty: General understanding of structured programming, git, reading knowledge of TypeScript and the fundamentals of databases and data structures
Estimated Time: 15 minutes


The objective of this scenario is to implement and analyze a simple example of the Command Query Responsibility Segregation pattern.

What you'll be doing

In this scenario you'll work with a demonstration microservice that allows users to save and view orders.

In this scencario order management will be separated into two data sources. One data source will accept and store write data. The other data source will store and publish read data. Separating write from read acivity is the essential concept driving the CQRS pattern.

Basic CQRS

In this scenario you'll be doing the following steps:

  • Step 1: Installing the lesson code
  • Step 2: Getting the code up and running
  • Step 3: Analyzing the application
  • Step 4: Identifying opportunities for improvement

Executing command line instructions

This scenario is completely interactive. The instructions you'll be given will be executed directly in the terminal window that is embedded directly in the Katacoda interactive learning environment. In the steps to come, when you see a command line instruction with a black background and check mark at the end, like so:

Katacoda command line

just click on it and the command will execute in the interative terminal window.

Click the START SCENARIO button to start.

Congratulations! You've completed the scenario that describes the essential concepts behind implementing a basic version of the Command Query Responsibility Segregation (CQRS) pattern.

The interactive scenario you:

  • Installed the lesson code
  • Got the code up and running
  • Analyzed the application
  • Viewed the write and read data sources
  • Identified opportunities for improvement

In next lesson you'll take a look at how to implement a more advanced example of the Command Query Responsibility Segregation (CQRS) pattern that takes a event-driven approach to data management.

Take the next lab is this series, Part 3-Taking an Event Driven Approach to CQRS.

Microservice Database Design: Part 2-Implementing the CQRS Pattern

Step 1 of 5

Cloning the Code from GitHub


The objective of this lesson is demonstrate how to clone from GitHub the project code you'll be using in this lab.


Step 1: Get the code from GitHub:

git clone https://github.com/reselbob/simplecqrs.git

Step 2: Navigate to the working directory of the code just cloned. This directory contains all the assets for the lab's demonstration application.

cd ~/simplecqrs && pwd

Step 3: Check out the git branch that contains the source code for this lesson:

git checkout 02-implement-read-write-datasources.0.0.1

You'll see output as follows:

Branch 02-implement-read-write-datasources.0.0.1 set up to track remote branch 02-implement-read-write-datasources.0.0.1 fromorigin.
Switched to a new branch '02-implement-read-write-datasources.0.0.1'

Next: Getting the code up and running