Low Level Design of Food delivery app - Zomato, Swiggy, UberEats
5983

Requirements

  1. Restaurant can register themselves.
  2. User can create, update, delete, get their profiles.
  3. User can search for the restaurant using restaurant name, city name.
  4. Restaurant can add, update foodmenu.
  5. User can see the foodmenu. User can get the food items based on Meal type or Cuisine type.
  6. User can add/remove items to/from the cart. User can get all the items of the cart.
  7. User can place or cancel the order. User can get all the orders ordered by him/her.
  8. User can apply the coupons. User can get the detailed bill containing tax details.
  9. User can made a payment using different modes of payment - credit card, wallet, etc.
  10. Delivery boy can get all the deliveries made by him using his Id.
  11. User can get the order status anytime. Success, Out for Delivery, Delivered, etc.

Solution:

class FoodDeliveryApp {
vector restaurants;
vector users;
vector deliveryPersons;
}

class Restaurant {
string restaurantId;
string restaurantName;
Address location;
Rating rating;
FoodMenu menu;

public:
	bool register(FoodDeliveryApp& app);
	FoodMenu getMenu();

}

class Address {
int zipCode;
string street;
string city;
string state;
string country;
}

class Rating {
double rating;
public:
bool updateRating(double newRating);
// consider newRating to calculate new Average Rating
double getRating();
}

class FoodMenu {
set items;
public:
set getFoodMenu();
bool addItem(Item item);
bool updateItem(Item oldItem, Item newItem);
bool deleteItem(Item item);
set getMenuByCuisine(Cuisine cuisine);
set getMenuByMealType(MealType mealType);
}

class Item {
int itemId;
string itemName;
string itemDescription;
Cuisine cuisine;
MealType mealType;
double price;
}

enum class Cuisine {
NORTH_INDIAN, SOUTH_INDIAN;
}

enum class MealType {
BREAK_FAST, LUNCH, SNACKS, DINNER;
}

class Account {
string firstName;
string lastName;
string email;
string userName;
string passWord;
}
class User {
searchObj search;
bool createAccount(Account account);
}

class Member : Public User {
Account account;
Cart cart;
vector order;

bool update(Account account);
bool delete(Account account);
Account get();
vector<Order> getAllOrders();

}

class searchObj {
vector searchRestaurants(string city);
vector searchRestaurants(string city, string restaurantName);
}

class Cart {
vector items;
double cartValue;
Payment payment;

bool addItem(Item item);
bool removeItem(Item item);
vector<Item> getAllItems();
void applyCoupon(Coupon coupon);
double calculateCartValue();

}

class Coupon {
string code;
string description;
}

class Order {
int orderId;
OrderStatus orderStatus;

bool placeOrder(Member member, Cart cart);
bool cancelOrder();

}

enum class OrderStatus {
SUCCESS, PENDING, CANCELLED, OUT_FOR_DELIVERY, DELIVERED;
}

class Payment {
bool makePayment();
}

class creditCardPayment : Public Payment {
bool makePayment();
}

class debitCardPayment : Public Payment {
bool makePayment();
}

class UPIPayment : Public Payment {
bool makePayment();
}

class Invoice {
int invoiceId;
double amount;
Order order;
PaymentMode mode;
TaxCalculation taxCal;
}

enum class PaymentMode {
CREDIT_CARD, DEBIT_CARD, UPI;
}

class TaxCalculation {
double cgstCharge;
double sgstCharge;
double serviceCharge;

double getTaxCalculated(double amount);

}

class DeliveryBoy : Public User {
Account account;
vector deliveries;

vector<Delivery> getAllDeliveries();

}

class Delivery {
int deliveryId;
Restaurant restautant;
Member member;
Rating deliveryRating;
Address dropLocation;
DateAndTime pickUpTime;
DateAndTime deliverydate;
OrderStatus orderStatus;
}

Comments (11)