A complete MERN stack application for managing shared expenses among groups. Perfect for roommates, travel groups, or any shared spending scenarios.
CostSplit is a simple yet powerful expense sharing manager that allows groups to:
- Track shared expenses
- Automatically calculate who owes whom
- Generate settlement instructions
- Manage group members dynamically
- View detailed balance summaries
- Single Shared Authentication - One login for the entire group
- Member Management - Add/remove members dynamically
- Expense Tracking - Record expenses with who paid
- Multi-Payer Support - Split expenses among multiple payers with different amounts (e.g., A pays 60৳, B pays 40৳ for 100৳ expense)
- Auto-Split - Automatically divide expenses equally among selected payers
- Automatic Balance Calculation - Smart algorithm calculates balances including multi-payer scenarios
- Settlement Generation - Optimized "who owes whom" instructions
- Clean Modern UI - Built with shadcn/ui and TailwindCSS
- Responsive Design - Works on all devices
- Comprehensive Tests - Full Jest test coverage
- Enhanced Dashboard - Quick actions, recent expenses, members preview, and average expense stats
- Expense Search - Real-time search by title or member name
- Date Filtering - View expenses by Today, This Week, This Month, or All Time
- CSV Export - Download filtered expenses for external analysis
- Copy Settlements - One-click copy settlement instructions to clipboard
- Smart Filtering - Shows filtered count and easy filter clearing
- Loading States - Smooth loading indicators throughout
- Empty States - Helpful messages and call-to-actions
- Add Members - Start by adding group members
- Track Expenses - Record expenses with amount and who paid
- View Balances - System calculates balances automatically
- Settle Up - Follow settlement instructions to clear debts
- Node.js - Runtime environment
- Express - Web framework
- MongoDB - Database
- Mongoose - ODM
- JWT - Authentication
- Jest - Testing framework
- React 18 - UI library
- Vite - Build tool
- React Router - Routing
- TailwindCSS - Styling
- shadcn/ui - UI components
- Radix UI - Headless UI primitives
- Lucide React - Icon library
- Axios - HTTP client
- Jest - Testing framework
CostSplit/
├── backend/
│ ├── src/
│ │ ├── config/ # Database configuration
│ │ ├── controllers/ # Request handlers
│ │ ├── middleware/ # Authentication middleware
│ │ ├── models/ # Mongoose models
│ │ ├── routes/ # API routes
│ │ ├── tests/ # Jest tests
│ │ └── utils/ # Balance calculation logic
│ ├── server.js # Entry point
│ ├── package.json
│ └── .env
│
├── frontend/
│ ├── src/
│ │ ├── components/ # UI components
│ │ │ └── ui/ # shadcn/ui components
│ │ ├── pages/ # Page components
│ │ ├── lib/ # API client & utilities
│ │ ├── hooks/ # Custom React hooks
│ │ └── tests/ # Jest tests
│ ├── index.html
│ ├── vite.config.js
│ ├── tailwind.config.js
│ └── package.json
│
└── README.md
You can run CostSplit either using Docker (recommended for quick setup) or manually (traditional setup).
Prerequisites:
- Docker and Docker Compose installed
- External MongoDB database (local, Atlas, or remote)
Quick Start:
# 1. Clone repository
git clone https://github.com/eCodeVoyager/CostSplit.git
cd CostSplit
# 2. Create .env file
cp .env.example .env
# Edit .env and configure your MongoDB connection
# 3. Start with Docker
docker-compose up -d
# 4. Access the application
# Frontend: http://localhost:3000
# Backend: http://localhost:5000📚 Full Docker documentation: See DOCKER.md for complete Docker setup guide, troubleshooting, and advanced configurations.
Prerequisites:
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- npm or yarn
cd backend
npm installCreate .env file:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/costsplit
JWT_SECRET=your_jwt_secret_key_here
SHARED_USERNAME=admin
SHARED_PASSWORD=1234
NODE_ENV=development
Start MongoDB:
# If using local MongoDB
mongodRun backend:
# Development mode
npm run dev
# Production mode
npm start
# Run tests
npm testcd frontend
npm installCreate .env file:
VITE_API_URL=http://localhost:5000/api
Run frontend:
# Development mode
npm run dev
# Build for production
npm run build
# Run tests
npm test- Start the backend server (on port 5000)
- Start the frontend (on port 3000)
- Open browser at
http://localhost:3000 - Login with default credentials:
admin/1234 - Add members to your group
- Add expenses as they occur
- View balances to see who owes what
- Follow settlement instructions to settle up
POST /api/auth/login- Login with shared credentialsGET /api/auth/verify- Verify JWT token
GET /api/members- Get all active membersGET /api/members/count- Get member countPOST /api/members- Create new memberDELETE /api/members/:id- Delete member
GET /api/expenses- Get all expenses (with optional filters)GET /api/expenses/stats- Get expense statisticsPOST /api/expenses- Create new expenseDELETE /api/expenses/:id- Delete expense
GET /api/balances- Get balances and settlement instructions
When an expense is added:
- The payer is credited the full amount
- All members (including payer) are debited their equal share
- Net balance is calculated for each member
Example:
- 4 members: Ehsan, Sakib, Rafi, Nabil
- Expense: 1000৳ paid by Ehsan
- Share per person: 1000 ÷ 4 = 250৳
Balances:
- Ehsan: +1000 (paid) - 250 (share) = +750 (should receive)
- Sakib: 0 (paid) - 250 (share) = -250 (owes)
- Rafi: 0 (paid) - 250 (share) = -250 (owes)
- Nabil: 0 (paid) - 250 (share) = -250 (owes)
Uses a greedy algorithm to minimize transactions:
- Separate creditors (positive balance) and debtors (negative balance)
- Sort both by amount
- Match largest debtor with largest creditor
- Continue until all balances are settled
cd backend
npm testTests cover:
- Balance calculation logic
- Settlement generation
- Authentication
- API endpoints
cd frontend
npm testTests cover:
- Utility functions
- Component rendering
- User interactions
- Simplicity - Single shared login, no complex permissions
- Accuracy - Precise balance calculations
- Transparency - Clear settlement instructions
- Flexibility - Dynamic member management
- Modern UI - Clean, professional design
- Reset/archive expenses
- Export to CSV/PDF
- Date range filters
- Multiple groups/trips
- Currency selection
- Expense categories
- Receipt photo upload
- Email notifications
- Mobile app
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
ISC
Built with ❤️ for simplifying shared expenses
Note: This is a complete, production-ready MERN application with modern best practices, clean code, comprehensive tests, and professional UI design.