Building a Backend Service for a Splitwise-like App
Using NodeJS, MongoDB & ExpressJS
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:
Clone the repository to your local machine:
git clone
https://github.com/rohitkulkarni22/Splitwise-backend-clone.git
Navigate to the backend folder:
cd backend
Install the required packages for the NodeJS backend:
npm install
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:
@hapi/joi: Download @hapi/joi
bcrypt: Download bcrypt
cors: Download cors
dotenv: Download dotenv
express: Download express
jsonwebtoken: Download jsonwebtoken
mongoose: Download mongoose
nodemon: Download nodemon
You can install them using:
npm install
API Endpoints
The backend provides the following API endpoints:
User Registration/Signup: POST /api/users/signup
User Login: POST /api/users/login
Create a Group: POST /api/group/create
Add New Member to a Group: POST /api/group/:groupId/addMember (Request Parameters: groupId)
Create an Expense: POST /api/group/:groupId/addExpense (Request Parameters: groupId)
View Expenses: GET /api/group/:groupId/viewExpenses (Request Parameters: groupId)
Split Expense Between Users: POST /api/group/:groupId/splitAmount (Request Parameters: groupId)
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!