23/180: Case Study — Microservices Design

Navneet Ojha
2 min readApr 12, 2021

I have taken a course on udemy for microservices architecture and I am going to describe the case study given over there. We will go through the main steps of architecture process:

  1. Functional Requirements
  2. Non Functional Requirements
  3. Mapping the components
  4. Define communication pattern

We are going to discuss Library Management Case study today

Library Management

  1. Manages books inventory
  2. Manages books borrowing
  3. Manages Customer
  4. Display Notifications
  5. Charge Annual Fee

Requirements can be divided into two parts

Functional requirements:

What the system should do?

  1. Web based
  2. Manage books inventory
  3. Manages customers
  4. Manages book borrowing
  5. Display Notification
  6. Charge Annual Fee

Non Functional Requirements:

What the system should deal with?

  1. How many expected concurrent users — 10
  2. How many books will be managed-10000
  3. How many borrowing in a day — 500
  4. What’s the desired SLA — 9/5, i.e. 9hrs 5 days

Data Volume

1 book record = 1kb

10000 books = 10 MB

1 borrowing record = 500 bytes

500 borrowing/day

182k borrowing/year -> 91 MB/year

Mapping the Components

Microservices -> Organized around business capabilities. We have well defined entities, so lets try and design the service around them.

Business Entities: Books, Borrowing, Customers

Utilites: Notifications, Payments, View

Book Service

Used to manage books inventory in the library.

  1. Used by libraries
  2. Has a database storage
  3. Should be synchronous (immediate response)
  4. Does not depend on other services.

APIs ->

  1. Get Books Details. GET /api/v1/book/{bookId}
  2. Add new book POST /api/v1/book
  3. Update Book PUT /api/v1/book/{bookId}
  4. Remove Book DELETE /api/v1/book/{bookId}

Borrowing Service

  1. Add a borrowing. POST /api/v1/borrowing
  2. Add a return POST /api/v1/borrowing
  3. Get Borrowing by customer GET /api/v1/borrowing/{customerId}

Customer Service

  1. Manage Library customers
  2. Used by librarians
  3. Has a storage
  4. Should be synchronous
  5. Doesn't depend on other service (Although refers to books and borrowings)

Notification Service

  1. Used to send notifications to the library customers
  2. Books was returned, new books added etc
  3. Used by other services
  4. Asynchronous
  5. Might experience load (send notifications to all users)
  6. We will use queue
  7. No immediate response required
  8. Distributed load

Payment Service

  1. Used to send payment instructions to external service
  2. Used by other services (for example customer joins the library)
  3. Asynchronous
  4. High Reliability is must
  5. We will use queue
  6. No immediate response required
  7. High availability

View Service

Used to serve static content to the web browser. HTML/CSS/JS. No API required, work directly with the browser.

--

--

Navneet Ojha

I am Indian by birth, Punjabi by destiny. Humanity is my religion. Love to eat, travel, read books and my million dreams keep me alive.