0
0
LLDsystem_design~25 mins

Sequence diagrams in LLD - System Design Exercise

Choose your learning style9 modes available
Design: Sequence Diagram for User Login Flow
Focus on the login process only, excluding registration or password reset flows
Functional Requirements
FR1: Show the interaction between user, frontend, backend, and database during login
FR2: Include authentication and error handling steps
FR3: Demonstrate synchronous and asynchronous message flows
Non-Functional Requirements
NFR1: Diagram must be clear and easy to understand for beginners
NFR2: Must represent real-world request-response timing
NFR3: Should cover up to 10 steps in the sequence
Think Before You Design
Questions to Ask
❓ Question 1
❓ Question 2
❓ Question 3
❓ Question 4
Key Components
User interface (frontend)
Backend authentication service
Database for user credentials
Session or token management
Design Patterns
Request-response pattern
Error handling in sequence diagrams
Synchronous vs asynchronous messages
Activation bars to show processing time
Reference Architecture
User          Frontend          Backend          Database
  |               |                |                 |
  |---Login Req-->|                |                 |
  |               |---Auth Req---->|                 |
  |               |                |---Query User--->|
  |               |                |<--User Data-----|
  |               |<--Auth Resp----|                 |
  |<--Login Resp--|                |                 |
  |               |                |                 |
Components
User
Human interaction
Initiates login request
Frontend
Web or mobile client
Sends login request and displays response
Backend
Authentication server
Processes login, verifies credentials
Database
Relational or NoSQL DB
Stores user credentials and data
Request Flow
1. User enters credentials and sends login request to Frontend
2. Frontend forwards authentication request to Backend
3. Backend queries Database for user data
4. Database returns user data to Backend
5. Backend verifies password and authentication rules
6. Backend sends authentication result back to Frontend
7. Frontend displays login success or failure to User
Database Schema
Entities: - User(id PK, username, password_hash, salt, email) Relationships: - None needed for login flow Notes: - Password stored securely as hash with salt - User table supports authentication queries
Scaling Discussion
Bottlenecks
Backend authentication server CPU limits under high login volume
Database read latency for user credential queries
Frontend handling many simultaneous login requests
Solutions
Use load balancer and multiple backend instances for horizontal scaling
Cache user credentials or session tokens in memory (e.g., Redis) to reduce DB hits
Implement rate limiting and throttling on frontend and backend to prevent overload
Interview Tips
Time: Spend 10 minutes clarifying requirements and participants, 20 minutes drawing and explaining the sequence diagram, 15 minutes discussing scaling and error handling
Clearly identify all actors and their roles
Explain synchronous vs asynchronous messages in the flow
Highlight error handling and alternative flows
Discuss how the design supports scalability and reliability