Designing Microservices
Start course
2h 20m

Interested in microservices, and how they can be used for increased agility and scalability?

Microservices is an architectural style and pattern that structures an application as a collection of coherent services. Each service is highly maintainable, testable, loosely coupled, independently deployable, and precisely focused.

This course takes a hands-on look at microservices using Python, Flask, and Docker. You'll learn how Flask can be used to quickly prototype and build microservices, as well as how to use Docker to host and deploy them.

We start by looking at various problems associated with monolithic architectures and how microservices address them. We then move on to designing and building a basic shopping cart system, focusing on each of the microservices that make up the overall system.

If you have any feedback relating to this course, feel free to get in touch with us at

Learning Objectives

  • Obtain a solid understanding of microservices: the benefits, the challenges, and how using microservices differs from a monolithic approach
  • Learn how to design and build microservices using Python and Flask
  • Learn how to deploy microservices using Docker

Intended Audience

This course is intended for anyone who wants to build and deploy microservices using Python, Flask, and Docker.


Python 3.x programming experience is required to get the most out of this course. If you want to follow along with this course, you'll need Python 3.7, an IDE (PyCharm Community Edition - free), and Docker (Docker Desktop).


The complete source code for the project demonstrated within the course is located here:

The repository contains the following 4 projects:

  1. user-service
  2. product-service
  3. order-service
  4. frontend




In this lecture, we are going to examine the requirements of our System. Firstly, we look into the overall design of our system. The end result of this course is the system where the user can register himself and place orders. 

The basic requirement of our system is, it should be based on microservices architecture. Each service should have its own business domain. Each service should not be tightly coupled to another service and it should be able to run independently.

We have three Services here:

  1. User Service
  2. Product Service
  3. Order Service

And a Frontend app consisting of a user interface utilizing those services.

Overall Requirements of the system are:

  1. A user can log in.
  2. A user can register.
  3. A user can log out.
  4. A user can browse products.
  5. A user can add a product to an order.
  6. A user can adjust the quantity of an order item.
  7. A user can place an order.

We also define some rules for our services like:

  1. If a product service goes down, a user must still be able to register
  2. If the order service fails, all products must still be shown
  3. Users should be able to log in even if the order or product services are down.

Let’s look at the design of microservices.

  1. Each service should be self-contained.
  2. A service should not depend on other services to function.
  3. Services should be lightweight in terms of code.
  4. Each service has its own database and its own processes.
  5. The ‘frontend’ should be shown regardless of service state.
  6. Service data should be held within the service.
  7. Service processes should only be performed within the service.

Let’s take a look at features of user-service, A user can register. A user can log in. A user can logout. User-service uses a database to hold user information. Each user has a unique username. API endpoints of user-service are:

  • POST request with ‘/api/user/create’ route, registers the user.
  • GET request with ‘/api/users’ route retrieves the information of users.
  • POST request with ‘/api/user/login’ route used for user’s login.
  • POST request with ‘/api/user/logout’ route used for user’s logout.
  • GET request with ‘/api/user/<username>/exists’ route checks if the username already exists, we use this route during registration to check if a username is available or not.
  • GET request with ‘/api/user’ route gets the current user information.

Let’s look at the design of Product Service. Product service has two features. It returns all the products. It returns a single product. We can enter new products during development. We can also extend our frontend application to enter new products by the admin users, but this functionality is out of scope of this training.

API endpoints of product service are:

  • GET request with ‘/api/products’ route to retrieve all products.
  • GET request with ‘/api/product/<id>’ route to retrieve a single product based on ID.
  • POST request with ‘/api/product/create’ route adds a new product.

Frontend functionality for this route is out of scope for this training.

Let’s look into the design of order service, Orders can be created. An item can be added to an order. An order can be updated. Also, only logged in users can create orders.

The API Endpoints for order service are:

  • GET request with ‘/api/orders’ route gets all open orders.
  • POST request with ‘/api/order/add-item’ route, creates a new order, and adds items in it. It also checks if there is already an open order associated with the user, it will update that order.
  • GET request with ‘/api/order’ route to get the order information of an authorized user.
  • POST request with ‘/api/order/checkout’ route to check out the order.

Now we look into the features of the frontend. Our frontend application has forms to submit data of users, products, and orders. These forms communicate with APIs via Helper API Clients. API Clients handle API requests to microservices. is used to communicate with user microservice. is used to communicate with product microservice. is used to communicate with order microservice. Sessions are used to store user and order data.

About the Author

Saqib is a member of the content creation team at Cloud Academy. He has over 15 years of experience in IT as a Programmer, with experience in Linux and AWS admin. He's also had DevOps engineer experience in various startups and in the telecommunications sector. He loves developing Unity3D games and participating in Game Jams.