A full-stack expense splitting application built with React, Node.js, Express, and MongoDB. This is a clone of Splitwise that allows users to create groups, add expenses, and track balances with friends.
- User Authentication: Register, login, and manage user profiles
- Group Management: Create groups, add/remove members
- Expense Tracking: Add expenses with custom splits between group members
- Balance Calculation: Automatic balance calculations showing who owes whom
- Real-time Updates: Socket.io integration for real-time expense updates
- User Search: Find and add friends to split expenses with
- Multiple Currencies: Support for different currencies
- Expense Categories: Categorize expenses for better organization
- React 18
- Material-UI (MUI) for UI components
- React Router for navigation
- Axios for API calls
- Socket.io-client for real-time updates
- Node.js with Express.js
- MongoDB with Mongoose ODM
- JWT for authentication
- Socket.io for real-time communication
- bcryptjs for password hashing
- Node.js (v14 or higher)
- MongoDB (running locally or MongoDB Atlas)
-
Clone the repository
git clone <repository-url> cd splitwise
-
Install dependencies
npm run install-deps
-
Set up environment variables Create a
.envfile in the root directory:NODE_ENV=development PORT=5000 MONGODB_URI=mongodb://localhost:27017/splitwise JWT_SECRET=your_jwt_secret_key_here JWT_EXPIRE=30d
-
Start MongoDB Make sure MongoDB is running on your system or update the
MONGODB_URIto use MongoDB Atlas. -
Run the application
npm run dev
This will start both the backend server (on port 5000) and the frontend development server (on port 3000).
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user info
GET /api/groups- Get all user groupsPOST /api/groups- Create a new groupGET /api/groups/:id- Get specific group detailsPOST /api/groups/:id/members- Add member to groupDELETE /api/groups/:id/members/:userId- Remove member from group
POST /api/expenses- Create new expenseGET /api/expenses/group/:groupId- Get group expensesGET /api/expenses/:id- Get specific expensePUT /api/expenses/:id- Update expenseDELETE /api/expenses/:id- Delete expenseGET /api/expenses/balances/:groupId- Get group balances
GET /api/users/search- Search users by name/emailGET /api/users/profile- Get user profilePUT /api/users/profile- Update user profilePOST /api/users/friends- Add friendDELETE /api/users/friends/:friendId- Remove friendGET /api/users/friends- Get friends list
- name: String
- email: String (unique)
- password: String (hashed)
- avatar: String
- phoneNumber: String
- friends: [ObjectId] (ref: User)
- groups: [ObjectId] (ref: Group)
- name: String
- description: String
- creator: ObjectId (ref: User)
- members: [{ user: ObjectId (ref: User), joinedAt: Date }]
- expenses: [ObjectId] (ref: Expense)
- description: String
- amount: Number
- currency: String
- paidBy: ObjectId (ref: User)
- group: ObjectId (ref: Group)
- splitBetween: [{ user: ObjectId (ref: User), amount: Number, paid: Boolean }]
- category: String
- date: Date
- notes: String
The application uses Socket.io for real-time updates:
- Expense additions/updates/deletions
- Member additions/removals from groups
- Balance updates
- Register/Login: Create an account or login with existing credentials
- Create Groups: Create groups to organize expenses with different sets of people
- Add Members: Search and add friends to your groups
- Add Expenses: Add expenses and split them between group members
- Track Balances: View who owes whom in each group
- Real-time Updates: See expense updates in real-time when other group members add expenses
npm run dev- Start both frontend and backend in development modenpm run server- Start only the backend servernpm run client- Start only the frontend development servernpm run build- Build the frontend for productionnpm run install-deps- Install dependencies for both root and client
splitwise/
├── client/ # React frontend
│ ├── public/
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── contexts/ # React contexts (Auth, Socket)
│ │ └── App.js
│ └── package.json
├── server/ # Node.js backend
│ ├── models/ # Mongoose models
│ ├── routes/ # Express routes
│ └── index.js # Server entry point
├── .env # Environment variables
├── package.json # Root package.json
└── README.md
Splitwise is an expense-splitting application designed to help friends, roommates, and groups fairly divide costs and track who owes whom money.
-
Expense Sharing Split bills among multiple people Track shared expenses like rent, utilities, dinners, trips Calculate fair splits based on who paid what
-
Balance Management Automatic calculations of who owes whom Simplify debts by combining multiple transactions Settle up easily with payment integrations
-
Group Organization Create groups for different situations (roommates, travel buddies, family) Add members and manage group expenses Track spending patterns over time
🏠 Common Use Cases
Rent and utility bills Groceries and household supplies Shared furniture or appliances
Restaurant bills and bar tabs Concert tickets and events Group gifts and celebrations
Hotel accommodations Transportation costs Group activities and meals
Family vacations Shared household expenses Parent-child expense tracking
-
Financial Clarity No more confusion about who paid what Clear records of all shared expenses Fair distribution of costs
-
Relationship Protection Avoid awkward money conversations Transparent tracking prevents misunderstandings Maintain friendships while managing finances
-
Convenience Mobile app for on-the-go tracking Automatic reminders for payments Multiple payment methods (Venmo, PayPal, etc.)
-
📊 How It Works
- Add Expense Example: Dinner for 4 people - $200 total
- Person A paid: $200
- Split between: A, B, C, D
- Each person owes: $50
- A's balance: +$150 (owed to them)
- B, C, D's balance: -$50 each (they owe)
- Track Balances Green numbers = Someone owes you money Red numbers = You owe someone money Zero balance = All settled up
- Settle Up Payment reminders sent to debtors Mark as paid when transactions complete Simplify debts by combining multiple people
- 🌟 Real-World Example Scenario: 4 roommates sharing expenses
Monthly Expenses:
Rent: $2,000 (split 4 ways = $500 each) Utilities: $200 (split 4 ways = $50 each) Groceries: $400 (Person A paid for everyone) Calculations:
Person A: Paid $400 groceries + $550 rent/utilities = $950 Person B: Paid $550 rent/utilities = $550 Person C: Paid $550 rent/utilities = $550 Person D: Paid $550 rent/utilities = $550 Result:
Person A is owed $400 by the group Persons B, C, D each owe $133.33 to Person A 💼 Business Applications Professional Use Cases Startup teams sharing office costs Project groups managing shared resources Freelance collaborations tracking expenses Non-profit organizations managing shared costs
- 🚀 Why People Use Splitwise Problem Solving Eliminates spreadsheets and manual calculations Reduces conflicts over money Simplifies complex group finances Provides documentation for shared expenses Modern Solution Digital tracking replaces paper notes Automated calculations prevent errors Mobile access for convenience Integration with payment platforms
- 📈 Impact Splitwise has helped millions of people manage billions of dollars in shared expenses, making it easier to maintain healthy relationships while handling financial responsibilities together.
In simple terms: Splitwise is like a digital accountant for shared expenses - it keeps track of who paid for what and calculates who owes whom, so friends and groups can split costs fairly without awkward conversations or complicated math! 🧮💰
- Fork the repository
- Create a feature branch
- Make your changes
- Test your changes
- Submit a pull request
This project is licensed under the MIT License.