0
0
LLDsystem_design~12 mins

SOLID violations and fixes in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - SOLID violations and fixes

This system demonstrates common violations of the SOLID principles in software design and how to fix them. It shows a simple order processing system where each component has a clear responsibility, following best practices for maintainability and scalability.

Architecture Diagram
User
  |
  v
Load Balancer
  |
  v
API Gateway
  |
  v
+----------------+      +----------------+      +----------------+
| Order Service  | ---> | Payment Service| ---> | Notification   |
| (Single Resp.) |      | (Single Resp.) |      | Service        |
+----------------+      +----------------+      +----------------+
       |                       |                       |
       v                       v                       v
+----------------+      +----------------+      +----------------+
| Order Database |      | Payment Gateway|      | Email Service  |
+----------------+      +----------------+      +----------------+
       ^                       ^                       ^
       |                       |                       |
      Cache                  Cache                   Cache
Components
User
user
Initiates requests to the system
Load Balancer
load_balancer
Distributes incoming requests evenly to API Gateway instances
API Gateway
api_gateway
Routes requests to appropriate services and handles authentication
Order Service
service
Manages order creation and retrieval, follows Single Responsibility Principle
Payment Service
service
Handles payment processing separately from order logic
Notification Service
service
Sends notifications like emails or SMS, separated from business logic
Order Database
database
Stores order data persistently
Payment Gateway
external_service
Processes payments securely with external providers
Email Service
external_service
Sends emails for notifications
Cache
cache
Speeds up data retrieval for frequently accessed data
Request Flow - 13 Hops
UserLoad Balancer
Load BalancerAPI Gateway
API GatewayOrder Service
Order ServiceCache
CacheOrder Service
Order ServiceOrder Database
Order ServicePayment Service
Payment ServicePayment Gateway
Payment GatewayPayment Service
Payment ServiceNotification Service
Notification ServiceEmail Service
Notification ServiceAPI Gateway
API GatewayUser
Failure Scenario
Component Fails:Order Database
Impact:New orders cannot be saved, causing order creation failures. Cached data may still be served for reads but will be stale.
Mitigation:Use database replication and failover to a standby database. Implement retry logic and circuit breakers in Order Service.
Architecture Quiz - 3 Questions
Test your understanding
Which component ensures that order creation and payment processing are handled separately to follow the Single Responsibility Principle?
AAPI Gateway and Load Balancer
BOrder Service and Payment Service
CCache and Database
DNotification Service and Email Service
Design Principle
This architecture demonstrates the SOLID principles by separating concerns into distinct services, improving maintainability and scalability. It uses caching to optimize performance and externalizes payment and notification responsibilities to specialized services. The design also includes fault tolerance strategies like database replication and load balancing.