0% found this document useful (0 votes)
92 views16 pages

System Design Sample Kit

The document is a preview of a comprehensive guide on system design by Parikh Jain, detailing key topics such as low-level design (LLD), core concepts, design patterns, and interview strategies. It includes practical examples, code snippets, and a variety of design interview questions with solutions. The full version can be accessed through a provided link for those seeking to deepen their understanding of system design.

Uploaded by

tamej78768
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views16 pages

System Design Sample Kit

The document is a preview of a comprehensive guide on system design by Parikh Jain, detailing key topics such as low-level design (LLD), core concepts, design patterns, and interview strategies. It includes practical examples, code snippets, and a variety of design interview questions with solutions. The full version can be accessed through a provided link for those seeking to deepen their understanding of system design.

Uploaded by

tamej78768
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

System Design By Parikh

Jain(Sample View)

Hello and welcome! I'm Parikh Jain, and I'm excited to share with you the ultimate
guide to excel System Design. This kit is a labor of love, drawn from my extensive
journey as an SDE at Amazon, a founding member at Coding Ninjas, and the
founder of ProPeers where I worked on different system designs from scratch to
scale. I’ve distilled my real-world experience into a comprehensive resource that
covers every topic you need to excel.

In this preview file, I have shared all the topics which i have covered in detail in the
full version with relevant code snippets and solutions.
I have shared all the sections which i have covered in full version. Checkout them
below.

📘(Detailed)
Section 1: Interview Mindset & Design strategy

🔹LLD?1. What is Low-Level Design (LLD)? Difference Between HLD &


🔹 2. What to Say in the First 5 Minutes
🔹 3. Universal Structure to Approach Any LLD Problem
🔹 4. Smart Clarifying Questions to Ask Before You Start
🔹 5. Final Interview Checklist (Use Before You Say "Done")
Covered all of them in the detailed version with examples

System Design By Parikh Jain(Sample View) 1


Checkout the full version now : https://bit.ly/3YyjIHt

📘Practical
Section 2: Core LLD Concepts Refresher (with
Code)
🔹 1. SOLID Principles (with Java Examples)
Example

✅ S — Single Responsibility Principle


A class should have only one reason to change.

Bad Example:

class Invoice {
void calculateTotal() { /* logic */ }
void printInvoice() { /* logic */ }
void saveToDB() { /* logic */ }
}

Why it’s wrong: This class does 3 things — business logic, UI, and persistence.
Good Example:

class Invoice {
double calculateTotal() { /* logic */ }
}

class InvoicePrinter {
void print(Invoice invoice) { /* logic */ }
}

System Design By Parikh Jain(Sample View) 2


class InvoiceRepository {
void save(Invoice invoice) { /* DB logic */ }
}

✅ O — Open/Closed Principle
✅ L — Liskov Substitution Principle
✅ I — Interface Segregation Principle
✅ D — Dependency Inversion Principle
Covered all of them in the detailed version with examples

Checkout the full version now : https://bit.ly/3YyjIHt

🔹 2. OOP Foundations for LLD (With Practical Use-Cases)


Example

✅ A. Inheritance vs Composition
🔸 Inheritance – "is-a" relationship
Use when there's a clear hierarchy and common behavior to be inherited.

class Vehicle {
void startEngine() {
System.out.println("Engine started");
}
}

class Car extends Vehicle {


void openSunroof() {
System.out.println("Sunroof opened");

System Design By Parikh Jain(Sample View) 3


}
}

🔍 Use when:
You want code reuse across types

Behavior is shared, and customization is minimal

🔸 Composition – "has-a" relationship


Preferred in most modern designs. It allows greater flexibility.

class Engine {
void start() {
System.out.println("Engine started");
}
}

class Car {
private Engine engine = new Engine();

void drive() {
engine.start();
System.out.println("Driving");
}
}

🔍 Use when:
You want modular, loosely coupled components

You're favoring delegation over inheritance

System Design By Parikh Jain(Sample View) 4


💡 In LLD interviews, prefer composition. It’s more flexible and
testable.

✅ B. Interface vs Abstract Class


✅ C. Encapsulation & Access Modifiers
✅ D. Polymorphism
✅ E. Favor Immutability Where Possible
Covered all of them in the detailed version with examples

Checkout the full version now : https://bit.ly/3YyjIHt

🔹 3. Common Design Patterns (With Practical Use-Cases)


🔹 1. Singleton Pattern
🔹 2. Factory Pattern
🔹 3. Strategy Pattern
🔹 4. Observer Pattern
🔹 5. Decorator Pattern
Covered all of them in the detailed version with examples

Checkout the full version now : https://bit.ly/3YyjIHt

🔹 4. Layered Architecture, DTOs, and LLD Mistakes


🔹 1. Layered Architecture: Controller → Service → DAO → Model

System Design By Parikh Jain(Sample View) 5


🔹 2. DTO vs Entity vs Model vs VO
🔹Them)
3. Common Mistakes in LLD Interviews (and How to Avoid

🔹 4. Interview Tips from Real LLD Rounds


Covered all of them in the detailed version with examples

Checkout the full version now : https://bit.ly/3YyjIHt

📘examples)
Section 3 : LLD Interview Questions (20+ with

Each interview questions covers :

🟩 1. Problem Statement
🟦 2. Assumptions & Functional Requirements
🟨 3. Entity Responsibility Table
🟧 4. Diagram With Proper Image
🟨 5. Java Code Implementation
🟥 6. Follow-Up Questions + Probable Solutions
🟩 7. Deep Dives & Version 2 Ideas

System Design By Parikh Jain(Sample View) 6


Example LLD Interview Question 1: Design
Splitwise

🟩 1. Problem Statement
Design a system like Splitwise where:

Users can create shared expenses.

Expenses can be split using different strategies: Equal, Exact, and


Percentage.

The system should track who owes whom.

🟦 2. Assumptions & Functional Requirements


Feature Required? Notes

Multiple users ✅ Each user has a unique ID and name

Expense types ✅ Equal, Exact, Percentage

View balances ✅ Net balances between any two users

Groups ❌ Not required in v1; possible extension

Persistence ❌ Use in-memory structures only

Undo or delete expense ❌ Not required now; consider in follow-up

Concurrency or multi-thread ❌ Out of scope for first version

🟨 3. Entity Responsibility Table


Class / Interface Responsibility
User Represents a user with ID and name
Split Abstract class for split strategy (amount + user)
EqualSplit Implements equal splitting logic
ExactSplit Implements fixed amount per user
PercentSplit Splits based on percentage per user

System Design By Parikh Jain(Sample View) 7


Expense Contains amount, who paid, and list of splits
ExpenseService Adds expenses, performs calculations, and updates balances
BalanceSheet Maintains balances between users

🟧 4. Class Diagram (Text Format)


sql
CopyEdit
+--------------------+
| Expense |
+--------------------+
| double amount |
| User paidBy |
| List<Split> splits |
+---------^----------+
|
+------------------+-------------------+
| | |
+-----------+ +------------+ +---------------+
| EqualSplit| | ExactSplit | | PercentSplit |
+-----------+ +------------+ +---------------+
| User user | | User user | | User user |
| double amt| | double amt | | double % |
+-----------+ +------------+ +---------------+

ExpenseService → updates → BalanceSheet (Map<User1, Map<User2, Amou


nt>>)

System Design By Parikh Jain(Sample View) 8


🟨 5. Java Code Implementation
✅ User.java

class User {
String id;
String name;

public User(String id, String name) {


this.id = id;
this.name = name;

System Design By Parikh Jain(Sample View) 9


}
}

✅ Split.java (abstract)

abstract class Split {


protected User user;
protected double amount;

public Split(User user) {


this.user = user;
}

public void setAmount(double amount) { this.amount = amount; }


public double getAmount() { return amount; }
public User getUser() { return user; }
}

✅ EqualSplit , ExactSplit , PercentSplit

class EqualSplit extends Split {


public EqualSplit(User user) {
super(user);
}
}

class ExactSplit extends Split {


public ExactSplit(User user, double amount) {
super(user);
setAmount(amount);

System Design By Parikh Jain(Sample View) 10


}
}

class PercentSplit extends Split {


private double percent;
public PercentSplit(User user, double percent) {
super(user);
this.percent = percent;
}
public double getPercent() { return percent; }
}

✅ Expense.java

class Expense {
private User paidBy;
private double amount;
private List<Split> splits;

public Expense(User paidBy, double amount, List<Split> splits) {


this.paidBy = paidBy;
this.amount = amount;
this.splits = splits;
}

public List<Split> getSplits() { return splits; }


public double getAmount() { return amount; }
public User getPaidBy() { return paidBy; }
}

✅ BalanceSheet.java

System Design By Parikh Jain(Sample View) 11


class BalanceSheet {
private Map<String, Map<String, Double>> balances = new HashMap<>();

public void update(String paidBy, String owedBy, double amount) {


balances.putIfAbsent(paidBy, new HashMap<>());
balances.get(paidBy).put(owedBy, balances.get(paidBy).getOrDefault(ow
edBy, 0.0) + amount);

balances.putIfAbsent(owedBy, new HashMap<>());


balances.get(owedBy).put(paidBy, balances.get(owedBy).getOrDefault(p
aidBy, 0.0) - amount);
}

public void printBalances() {


for (String u1 : balances.keySet()) {
for (String u2 : balances.get(u1).keySet()) {
double amt = balances.get(u1).get(u2);
if (amt > 0) {
System.out.println(u2 + " owes " + u1 + ": ₹" + amt);
}
}
}
}
}

✅ ExpenseService.java

class ExpenseService {
private BalanceSheet balanceSheet = new BalanceSheet();

public void addExpense(String type, User paidBy, double amount, List<Split

System Design By Parikh Jain(Sample View) 12


> splits) {
if (type.equals("EQUAL")) {
double share = amount / splits.size();
for (Split s : splits) s.setAmount(share);
} else if (type.equals("PERCENT")) {
for (Split s : splits) {
double share = ((PercentSplit) s).getPercent() * amount / 100.0;
s.setAmount(share);
}
}

Expense expense = new Expense(paidBy, amount, splits);


for (Split s : splits) {
if (!s.getUser().id.equals(paidBy.id)) {
balanceSheet.update(paidBy.id, s.getUser().id, s.getAmount());
}
}
}

public void showBalances() {


balanceSheet.printBalances();
}
}

✅ Sample Usage (Main Class)


public class SplitwiseApp {
public static void main(String[] args) {
User u1 = new User("u1", "Parikh");
User u2 = new User("u2", "Varun");
User u3 = new User("u3", "Amit");

ExpenseService service = new ExpenseService();

System Design By Parikh Jain(Sample View) 13


List<Split> splits = List.of(new EqualSplit(u2), new EqualSplit(u3));
service.addExpense("EQUAL", u1, 300, splits);

service.showBalances();
}
}

🟥 6. Follow-Up Questions + Probable Solutions


Follow-Up Question How to Extend Design

Can we support Groups? Add Group class with users & expenses

How to undo/delete an expense? Track each expense with ID; reverse updates

What if we want to persist data? Add repository layer with DB mappings

How to scale this for 1M users? Split services, add DB, use caching

Can we add notifications? Use Observer pattern with Notifier

How to make thread-safe? Use ConcurrentHashMap , locks

🟩 7. Deep Dives & Version 2 Ideas


Upgrade Feature Required Change

Add group expenses New Group class + balance tracker by group

Add recurring expenses Add RecurrenceRule in Expense class

Multi-currency support Add CurrencyConverter & currency field

Settlement support Add Payment entity + transaction history

Expense categories Add enum Category in Expense

20+ LLD Design Interview Problems Covered in Full


Version

System Design By Parikh Jain(Sample View) 14


BookMyShow / Movie Ticket Booking

Notification System (Email/SMS/Push)

Chat Messaging App

Design a Parking Lot System

Food Ordering System

Ride Sharing / Uber-like System

Hotel Booking System

Quiz Platform (Google Forms / HackerRank)

Content Streaming Platform (Netflix / YouTube)

Versioned Document Editor (Google Docs)

Rate Limiter (API Gateway)

Social Feed System (LinkedIn / Twitter)

Job Portal (LinkedIn / Naukri)

Online Payment Gateway(Razorpay/Stripe)

Calendar & Meeting Scheduler (Google Calendar/Calendly)

File Storage & Sharing System(Google Drive/Dropbox)

Q&A Platform (Quora / StackOverflow)

Learning Path / Roadmap System (ProPeers / Coursera)

Code Execution Engine (LeetCode / Judge0 / CodePen)

Each question includes :

🟩 1. Problem Statement
🟦 2. Assumptions & Functional Requirements
🟨 3. Entity Responsibility Table
🟧
System Design By Parikh Jain(Sample View) 15
🟧 4. Diagram With Proper Image
🟨 5. Java Code Implementation
🟥 6. Follow-Up Questions + Probable Solutions
🟩 7. Deep Dives & Version 2 Ideas
Checkout the full version now : https://bit.ly/3YyjIHt

System Design By Parikh Jain(Sample View) 16

You might also like