Skip to content

skp3214/ZeptoLite-InventoryManagement-LLD-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ZeptoLite - Inventory Management - LLD Project

Overview

ZeptoLite - Inventory Management is a low-level design (LLD) for a simplified inventory and order fulfillment system, inspired by hyperlocal delivery platforms like Zepto. It manages products, inventory, dark stores (warehouses), user carts, orders, and delivery partners. The system uses design patterns like Factory, Strategy, and Singleton to ensure modularity and scalability.

Features

  • Product Management: Products with SKU, name, and price, created via a factory.
  • Inventory Management: Tracks stock levels across dark stores using an InventoryStore abstraction.
  • Dark Store Management: Supports multiple dark stores with location-based proximity search.
  • Replenishment Strategies: Implements threshold-based and weekly replenishment strategies.
  • Order Processing: Handles user carts, order splitting across dark stores, and delivery partner assignment.
  • Singleton Managers: Uses DarkStoreManager and OrderManager for centralized control.

Class Structure

The system is divided into several key components, as illustrated in the class diagram:

Models

  • Product: Represents a product with sku, name, and price.
  • User: A user with a name and coordinates (x, y), owning a Cart.
  • Cart: Manages items as pairs of Product and quantity, with methods to add items and calculate totals.
  • Order: Represents an order with an ID, user, items, delivery partners, and total amount.
  • DeliveryPartner: A simple entity with a name, assigned to fulfill orders.

Factory

  • ProductFactory: Creates Product instances based on SKU with predefined names and prices.

Inventory and Store

  • InventoryStore (Interface): Defines methods for adding/removing products, checking stock, and listing available products.
  • DbInventoryStore: Implements InventoryStore using HashMap for stock and product storage.
  • InventoryManager: Manages inventory operations, delegating to an InventoryStore.
  • DarkStore: Represents a warehouse with a name, coordinates, and an InventoryManager. Supports replenishment via a strategy.
  • DarkStoreManager (Singleton): Manages a list of dark stores and finds nearby stores based on user location.

Replenishment Strategy

  • ReplenishStrategy (Interface): Defines the replenish method for inventory replenishment.
  • ThresholdReplenishStrategy: Replenishes stock if it falls below a threshold.
  • WeeklyReplenishStrategy: Placeholder for weekly replenishment logic.

Order Management

  • OrderManager (Singleton): Manages orders, placing them by finding nearby dark stores and assigning delivery partners.
  • ZeptoHelper: Utility class to initialize dark stores and display available products to users.

Usage

  1. Initialize the System:
    • The ZeptoHelper class sets up dark stores with initial stock and replenishment strategies.
  2. User Interaction:
    • A User is created with coordinates.
    • The user adds items to their Cart.
    • ZeptoHelper.showAllItems displays available products within 5 km.
  3. Order Placement:
    • OrderManager.placeOrder processes the cart, finding nearby dark stores and assigning delivery partners.
    • Orders may be split across multiple dark stores if items are unavailable in a single store.
  4. Replenishment:
    • Dark stores use a ReplenishStrategy to restock items when needed.

Design Patterns Used

  • Factory Pattern: ProductFactory creates products.
  • Strategy Pattern: ReplenishStrategy allows flexible replenishment logic.
  • Singleton Pattern: DarkStoreManager and OrderManager ensure single instances for global management.

How to Run

The entry point is ZeptoLite.java. Compile and run it to see a demo:

  • Initializes dark stores with sample stock.
  • Creates a user, displays available products, adds items to the cart, and places an order.
  • Outputs the order summary, including items, total, and assigned delivery partners.

Class Diagram

Refer to the provided class diagram for a visual representation of the system architecture, showing relationships between classes, methods, and attributes.

alt text

About

A low-level design for a hyperlocal inventory system inspired by Zepto.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages