The Wayback Machine - https://web.archive.org/web/20261113214021/https://www.geeksforgeeks.org/system-design/what-is-low-level-design-or-lld-learn-system-design/

Low Level Design or LLD

Last Updated : 6 Nov, 2026

Low-Level Design (LLD) is the process of defining the internal structure and implementation details of individual components in a software system. It focuses on designing classes, interfaces, methods, data structures, and their interactions based on the overall system architecture defined during High-Level Design (HLD).

  • Defines the responsibilities, attributes, methods, and relationships of individual classes and modules.
  • Helps developers translate architectural requirements into clear and maintainable implementation details.

Example: In an e-commerce application, LLD defines how Order, OrderItem, PaymentService, and PaymentGateway interact to process an order.

Importance of Low-Level Design

Low-Level Design provides a clear implementation plan for software components. It helps developers understand how different classes interact and how business requirements are implemented.

  • Defines the purpose and behavior of individual classes and interfaces clearly.
  • Breaks component functionality into smaller and more manageable operations.
  • Makes code easier to understand, modify, maintain, and extend over time.
  • Encourages modular components that can be tested independently.
  • Helps developers follow consistent design decisions, interfaces, and coding contracts.

Key Components of Low-Level Design

LLD focuses on the internal elements required to implement application functionality.

low_level_design

The key components are as follows:

  • Classes and Objects represent application entities, their state, and behavior.
  • Interfaces define contracts between components without exposing implementation details.
  • Attributes and Methods specify the data and operations associated with individual classes.
  • Class Relationships define association, aggregation, composition, and inheritance between classes.
  • Data Structures determine how application data is organized and manipulated.
  • Design Patterns provide reusable approaches to recurring design problems.
  • Error Handling defines how components validate inputs, report errors, and recover where appropriate.

How Low-Level Design Works

Low-Level Design translates system requirements and high-level architectural decisions into detailed component specifications.

low_level_design2

LLD Process:

  • Understand the functional requirements, business rules, constraints, and relevant HLD decisions.
  • Identify the classes and interfaces required to implement the functionality.
  • Define the attributes, methods, access modifiers, and responsibilities of each class.
  • Establish relationships between classes, including dependencies, inheritance, and composition.
  • Choose suitable data structures and design patterns based on the requirements.
  • Review the design for edge cases, extensibility, testability, and maintainability.

Important OOP Concepts Used in LLD

Object-Oriented Programming provides a foundation for many low-level designs.

  • Encapsulation groups related data and behavior within a class while controlling access to its internal state.
  • Abstraction exposes required functionality while hiding implementation details.
  • Inheritance allows a class to derive accessible functionality from another class when a genuine is-a relationship exists.
  • Polymorphism allows multiple classes to provide different implementations of the same operation.

SOLID Principles in Low-Level Design

SOLID principles help create classes and interfaces that are easier to maintain, test, and extend.

  • Single Responsibility Principle (SRP): A class should have one primary responsibility or reason to change.
  • Open/Closed Principle (OCP): Components should support extension without requiring unnecessary modifications.
  • Liskov Substitution Principle (LSP): Subtypes should preserve the expected behavior of their base types.
  • Interface Segregation Principle (ISP): Prefer focused interfaces instead of large interfaces with unrelated operations.
  • Dependency Inversion Principle (DIP): High-level components should depend on abstractions rather than concrete implementations.

UML Diagrams Used in Low-Level Design

Unified Modeling Language (UML) provides visual representations of software structure and behavior.

Design Patterns Used in Low-Level Design

Design patterns provide reusable approaches to commonly occurring software design problems. They help organize object creation, component relationships, and interactions.

  • Creational provides flexible and reusable ways to create objects while hiding the complexity of object creation.
  • Structural defines how classes and objects can be combined to form larger, flexible, and maintainable structures.
  • Behavioral defines how objects communicate, share responsibilities, and interact to perform specific tasks.

Real-World Example of Low-Level Design

Consider an e-commerce application where customers place orders and make payments using UPI or Card.

The LLD focuses on the classes responsible for creating orders, maintaining their state, and processing payments.

1. Identify Classes and Responsibilities

Class/InterfaceResponsibility
CustomerRepresents the customer placing an order.
OrderMaintains order details, items, and status.
OrderItemStores product and quantity information.
OrderServiceCoordinates order creation and payment processing.
PaymentGatewayDefines a common contract for processing payments.
UpiPaymentImplements UPI payment processing.
CardPaymentImplements card payment processing.

2. Class Diagram

low_level_design3

The key classes and their relationships in the Order Management System are explained below:

  • Customer -> Order: A Customer places an Order. The customer stores basic details such as customerId and name, while the order maintains its orderId, status, and payment state.
  • Order -> OrderItem: The filled diamond represents composition, meaning an Order contains one or more OrderItem objects. Each item stores information such as productId and quantity.
  • OrderService -> PaymentGateway: OrderService coordinates order processing and depends on the PaymentGateway interface for making payments.
  • PaymentGateway: Defines a common pay(amount) operation without depending on a particular payment method.
  • UpiPayment and CardPayment: These classes implement PaymentGateway and provide their own payment-processing behavior.

3. Implementation

The following simplified example demonstrates interface-based payment processing and order state management.

C++
#include <iostream>
#include <string>
using namespace std;

// Contract for payment processing
class PaymentGateway {
public:
    virtual bool pay(double amount) = 0;
    virtual ~PaymentGateway() = default;
};

// UPI payment implementation
class UpiPayment : public PaymentGateway {
public:
    bool pay(double amount) override {
        cout << "UPI payment: " << amount << endl;
        return true; // Simulated successful payment
    }
};

// Order maintains its own state
class Order {
private:
    string status = "CREATED";

public:
    void markPaid() {
        if (status != "CREATED") {
            throw logic_error("Invalid order state");
        }
        status = "PAID";
    }

    string getStatus() const {
        return status;
    }
};

// Coordinates order payment
class OrderService {
private:
    PaymentGateway& gateway;

public:
    OrderService(PaymentGateway& gateway)
        : gateway(gateway) {}

    void placeOrder(Order& order, double amount) {
        bool success = gateway.pay(amount);

        if (success) {
            order.markPaid();
        }
    }
};

int main() {
    Order order;

    // Inject payment implementation
    UpiPayment payment;
    OrderService service(payment);

    service.placeOrder(order, 1500.00);

    cout << "Order Status: "
         << order.getStatus() << endl;

    return 0;
}
Java
import java.math.BigDecimal;

// Contract for payment processing
interface PaymentGateway {
    boolean pay(BigDecimal amount);
}

// UPI payment implementation
class UpiPayment implements PaymentGateway {
    @Override
    public boolean pay(BigDecimal amount) {
        System.out.println("UPI payment: " + amount);
        return true; // Simulated successful payment
    }
}

// Order maintains its own state
class Order {
    private String status = "CREATED";

    public void markPaid() {
        if (!status.equals("CREATED")) {
            throw new IllegalStateException("Invalid order state");
        }
        status = "PAID";
    }

    public String getStatus() {
        return status;
    }
}

// Coordinates order payment
class OrderService {
    private final PaymentGateway gateway;

    public OrderService(PaymentGateway gateway) {
        this.gateway = gateway;
    }

    public void placeOrder(Order order, BigDecimal amount) {
        boolean success = gateway.pay(amount);

        if (success) {
            order.markPaid();
        }
    }
}

public class Main {
    public static void main(String[] args) {
        Order order = new Order();

        // Inject payment implementation
        PaymentGateway payment = new UpiPayment();
        OrderService service = new OrderService(payment);

        service.placeOrder(order, new BigDecimal("1500.00"));

        System.out.println("Order Status: " + order.getStatus());
    }
}
Python
from abc import ABC, abstractmethod
from decimal import Decimal

# Contract for payment processing
class PaymentGateway(ABC):

    @abstractmethod
    def pay(self, amount):
        pass


# UPI payment implementation
class UpiPayment(PaymentGateway):

    def pay(self, amount):
        print(f"UPI payment: {amount}")
        return True  # Simulated successful payment


# Order maintains its own state
class Order:

    def __init__(self):
        self._status = "CREATED"

    def mark_paid(self):
        if self._status != "CREATED":
            raise ValueError("Invalid order state")

        self._status = "PAID"

    def get_status(self):
        return self._status


# Coordinates order payment
class OrderService:

    def __init__(self, gateway: PaymentGateway):
        self.gateway = gateway

    def place_order(self, order, amount):
        success = self.gateway.pay(amount)

        if success:
            order.mark_paid()


# Main program
order = Order()

# Inject payment implementation
payment = UpiPayment()
service = OrderService(payment)

service.place_order(order, Decimal("1500.00"))

print("Order Status:", order.get_status())
JavaScript
// Contract for payment processing
class PaymentGateway {
    pay(amount) {
        throw new Error("pay() must be implemented");
    }
}

// UPI payment implementation
class UpiPayment extends PaymentGateway {
    pay(amount) {
        console.log(`UPI payment: ${amount}`);
        return true; // Simulated successful payment
    }
}

// Order maintains its own state
class Order {
    #status = "CREATED";

    markPaid() {
        if (this.#status !== "CREATED") {
            throw new Error("Invalid order state");
        }

        this.#status = "PAID";
    }

    getStatus() {
        return this.#status;
    }
}

// Coordinates order payment
class OrderService {
    constructor(gateway) {
        this.gateway = gateway;
    }

    placeOrder(order, amount) {
        const success = this.gateway.pay(amount);

        if (success) {
            order.markPaid();
        }
    }
}

// Main program
const order = new Order();

// Inject payment implementation
const payment = new UpiPayment();
const service = new OrderService(payment);

service.placeOrder(order, 1500.00);

console.log("Order Status:", order.getStatus());

Output

UPI payment: 1500
Order Status: PAID

Explanation:OrderService processes payments through the PaymentGateway interface, while Order controls its internal status. Different payment implementations can be provided without modifying the service logic.

4. Sequence of Operations

The successful path demonstrates how objects interact during order processing. In a complete design, the sequence would also show unsuccessful payments, exceptions, and recovery behavior.

low_level_design4

The order processing flow involves the following steps:

  1. The customer sends an order request to the OrderService.
  2. The OrderService calls pay(amount) through the PaymentGateway interface.
  3. The PaymentGateway returns the payment result to the OrderService.
  4. If the payment succeeds, the OrderService calls markPaid() to update the order status.
  5. The OrderService returns the updated order status to the customer.

Challenges of Low-Level Design

  • Identifying appropriate classes, responsibilities, and relationships can become difficult in large applications.
  • Changing business requirements may require updates to interfaces, dependencies, and object interactions.
  • Using too many classes or design patterns can make simple functionality unnecessarily complex.
  • Poorly designed dependencies can create tight coupling and make components harder to modify or test.
  • Detailed diagrams and design specifications may become outdated as the implementation evolves.
Comment

Explore