Building a Backend Service for a Splitwise-like App

Using NodeJS, MongoDB & ExpressJS

Building a Backend Service for a Splitwise-like App

Photo by Taylor Vick on Unsplash

In the fast-paced world of digital finance and collaborative expense management, applications like Splitwise have become indispensable. In this blog post, we'll guide you through the process of building a backend service for a Splitwise-like app using NodeJS, MongoDB, and ExpressJS.

Setting up the Project

To get started with the project, follow these steps:

  1. Clone the repository to your local machine:

    git clone https://github.com/rohitkulkarni22/Splitwise-backend-clone.git

  2. Navigate to the backend folder:

    cd backend

  3. Install the required packages for the NodeJS backend:

    npm install

  4. Start the ExpressJS server:

    npm start

Now, your server is up and running at http://localhost:5005.

Project Dependencies

Before running the server, make sure you have the following dependencies installed:

  1. @hapi/joi: Download @hapi/joi

  2. bcrypt: Download bcrypt

  3. cors: Download cors

  4. dotenv: Download dotenv

  5. express: Download express

  6. jsonwebtoken: Download jsonwebtoken

  7. mongoose: Download mongoose

  8. nodemon: Download nodemon

You can install them using:

npm install

API Endpoints

The backend provides the following API endpoints:

  1. User Registration/Signup: POST /api/users/signup

  2. User Login: POST /api/users/login

  3. Create a Group: POST /api/group/create

  4. Add New Member to a Group: POST /api/group/:groupId/addMember (Request Parameters: groupId)

  5. Create an Expense: POST /api/group/:groupId/addExpense (Request Parameters: groupId)

  6. View Expenses: GET /api/group/:groupId/viewExpenses (Request Parameters: groupId)

  7. Split Expense Between Users: POST /api/group/:groupId/splitAmount (Request Parameters: groupId)

  8. Settle Expenses Between Users: DELETE /api/group/:groupId/settleup (Request Parameters: groupId)

Testing the Backend

You can test the backend using Mocha tests. Navigate to the backend folder and run:

npm test

Alternatively, you can use Postman, a popular API testing toolkit, to interact with the API endpoints.

Deployed Service

The deployed service is accessible at the following base URL:

https://splitwise-backend-clone.vercel.app

Feel free to explore the functionalities and test the service in action.

Now you have the foundation for a Splitwise-like app backend. Customize and enhance the code as needed for your specific requirements. Here you can find the source-code.

Happy coding!