techlinks.in
Low Level Design (LLD) Coding

Follow

Low Level Design (LLD) Coding

Follow
Design (LLD) Splitwise application  - Machine Coding

Design (LLD) Splitwise application - Machine Coding

techlinks.in's photo
techlinks.in
·Oct 23, 2022·

2 min read

Play this article

Low-level design (LLD) for a Splitwise application:

  1. Database design: We will need to store information about users, their expenses, and any debts or credits between them. This will likely include tables for users, expenses, and debts/credits, with foreign keys to link them together.

  2. User authentication and authorization: Users will need to be able to sign up for the application, log in, and log out. We will also need to implement measures to ensure the security of user accounts, such as password hashing and potentially two-factor authentication.

  3. Expense tracking: The core functionality of the Splitwise application is the ability to track expenses and split them among users. This will likely involve creating forms for users to input their expenses, with fields for the amount, description, and any split information. We will also need to implement logic to calculate debts and credits between users based on the expenses they have entered.

  4. Payment tracking: In addition to tracking expenses, we will also need to allow users to mark debts as paid, so that the application can accurately reflect the current state of debts between users.

  5. User interface: Finally, we will need to design the user interface for the application, including the layout, navigation, and any necessary graphics or styling. This will involve creating wireframes and mockups, as well as implementing the front-end code to bring the design to life.

Here is an example of how the Splitwise application could be implemented in Java using object-oriented design principles:

public class Splitwise {
    private List<User> users;

    public Splitwise() {
        users = new ArrayList<>();
    }

    public void addUser(User user) {
        users.add(user);
    }

    public void addExpense(Expense expense) {
        User payer = expense.getPayer();
        payer.pay(expense.getAmount());
        for (User user : expense.getSplitters()) {
            user.receive(expense.getAmount() / expense.getSplitters().size());
        }
    }

    public List<User> getUsers() {
        return users;
    }
}

public class User {
    private String name;
    private double balance;

    public User(String name) {
        this.name = name;
        balance = 0;
    }

    public String getName() {
        return name;
    }

    public double getBalance() {
        return balance;
    }

    public void pay(double amount) {
        balance -= amount;
    }

    public void receive(double amount) {
        balance += amount;
    }
}

public class Expense {
    private User payer;
    private List<User> splitters;
    private double amount;
    private String description;

    public Expense(User payer, List<User> splitters, double amount, String description) {
        this.payer = payer;
        this.splitters = splitters;
        this.amount = amount;
        this.description = description;
    }

    public User getPayer() {
        return payer;
    }

    public List<User> getSplitters() {
        return splitters;
    }

    public double getAmount() {
        return amount;
    }

    public String getDescription() {
        return description;
    }
}

Did you find this article valuable?

Support techlinks.in by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors
 
Share this