0
0
LLDsystem_design~12 mins

Single Responsibility Principle in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Single Responsibility Principle

The Single Responsibility Principle (SRP) is a design guideline that states each component or module in a system should have only one reason to change. This means every part of the system should focus on a single task or responsibility, making the system easier to understand, maintain, and scale.

Architecture Diagram
User
  |
  v
+----------------+
|  Load Balancer |
+----------------+
        |
        v
+----------------+      +----------------+      +----------------+
| Auth Service   | ---> | Order Service  | ---> | Payment Service |
+----------------+      +----------------+      +----------------+
        |                      |                       |
        v                      v                       v
+----------------+      +----------------+      +----------------+
| Auth Database  |      | Order Database |      | Payment Gateway|
+----------------+      +----------------+      +----------------+
Components
Load Balancer
load_balancer
Distributes incoming user requests evenly to backend services
Auth Service
service
Handles user authentication and authorization
Order Service
service
Manages order creation, updates, and retrieval
Payment Service
service
Processes payments and handles payment gateway communication
Auth Database
database
Stores user credentials and authentication data
Order Database
database
Stores order details and status
Payment Gateway
external_service
External system to process payment transactions
Request Flow - 13 Hops
UserLoad Balancer
Load BalancerAuth Service
Auth ServiceAuth Database
Auth DatabaseAuth Service
Auth ServiceLoad Balancer
Load BalancerOrder Service
Order ServiceOrder Database
Order DatabaseOrder Service
Order ServicePayment Service
Payment ServicePayment Gateway
Payment GatewayPayment Service
Payment ServiceLoad Balancer
Load BalancerUser
Failure Scenario
Component Fails:Order Service
Impact:Order creation fails, users cannot place new orders but authentication and payment services remain functional
Mitigation:Use service replication and health checks to detect failure and route traffic to healthy instances; implement circuit breaker to prevent cascading failures
Architecture Quiz - 3 Questions
Test your understanding
Which component is responsible only for user authentication?
AAuth Service
BOrder Service
CPayment Service
DLoad Balancer
Design Principle
This architecture demonstrates the Single Responsibility Principle by separating concerns into distinct services: authentication, order management, and payment processing. Each service has one clear responsibility, making the system easier to maintain and scale.