System-Design-Question

feat: new library FR-NFR system design interview

Category: system_design Date: 2026-02-18

Feat: New Library FR-NFR System Design Interview

Problem Statement: Design a system for a new library management application. The system should allow users to:

Requirements:

Functional Requirements (FR):

  1. Users can create, read, update, and delete books.
  2. Users can manage library branches.
  3. Users can track book availability.
  4. Users can log in and log out of the system.

Non-Functional Requirements (NFR):

  1. Scalability: The system should be able to handle a large number of users and library branches.
  2. High Availability: The system should be available 24/7 with a minimum of 99.99% uptime.
  3. Security: The system should implement robust authentication and authorization mechanisms.
  4. Performance: The system should respond to user requests within 2 seconds.
  5. Data Consistency: The system should ensure data consistency across all library branches.

High-Level Architecture:

  1. Client-Side: Users interact with the system through a web or mobile application.
  2. API Gateway: Handles incoming requests from clients and routes them to the appropriate service.
  3. Authentication Service: Handles user authentication and authorization.
  4. Library Service: Manages library branches, books, and book availability.
  5. Database: Stores library data, including books, branches, and user information.

Learning Link: API Gateway Design Pattern - https://microservices.io/patterns/apigateway.html

Database Design:

  1. Library Branch Table: Stores information about each library branch, including branch ID, name, and address.
  2. Book Table: Stores information about each book, including book ID, title, author, and ISBN.
  3. Book Availability Table: Stores the current availability of each book across all library branches.
  4. User Table: Stores user information, including user ID, username, and password.

Learning Link: Database Design Principles - https://www.tutorialspoint.com/database_design/database_design.htm

Scaling Strategy:

  1. Horizontal Scaling: Add more instances of the API Gateway, Authentication Service, and Library Service to handle increased traffic.
  2. Load Balancing: Distribute incoming requests across multiple instances of the API Gateway to prevent overload.
  3. Caching: Implement caching mechanisms to reduce the load on the Library Service and improve response times.

Learning Link: Scaling a Microservices Architecture - https://microservices.io/patterns/scaling.html

Bottlenecks:

  1. Database Performance: As the number of users and library branches increases, the database may become a bottleneck.
  2. API Gateway Performance: The API Gateway may become a bottleneck if it cannot handle the increased traffic.

Trade-offs:

  1. Scalability vs. Complexity: Adding more instances of the API Gateway and Library Service increases complexity and may introduce new bottlenecks.
  2. Security vs. Performance: Implementing robust security mechanisms may impact system performance.

First Principle of System Design: “The first principle of system design is to separate concerns. This means separating the system into distinct components, each responsible for a specific function or set of functions. This approach allows for greater flexibility, scalability, and maintainability.”

In this system design, we have separated concerns into distinct components, including the API Gateway, Authentication Service, and Library Service. This approach allows for greater flexibility, scalability, and maintainability, and enables us to address the functional and non-functional requirements of the system.

Additional Learning Resources:

  1. Microservices Architecture - https://microservices.io/
  2. API Design Principles - https://www.apiary.io/blog/
  3. Database Design Principles - https://www.tutorialspoint.com/database_design/database_design.htm