SplitEase is a full-stack expense management application designed to simplify the process of splitting expenses among friends, roommates, or travel groups. This repository contains the backend codebase built with Node.js, Express, and MongoDB.
Check out the Frontend Repository
-
π± User Management
- Register, login, and profile management
- Social login with Google OAuth
- Upload profile pictures to Cloudinary
- Add and manage payment methods
-
π₯ Group Management
- Create groups for different expense categories
- Add/remove friends to groups
- Track group-specific expenses
-
πΈ Expense Tracking
- Add expenses with multiple splitting methods:
- Equal splits
- Percentage-based splits
- Custom amount splits
- Support for multiple currencies
- Categorize expenses (Food, Transportation, etc.)
- Add expenses with multiple splitting methods:
-
π Transaction Management
- View pending payments
- Settle transactions with transaction history
- Track payment statuses
-
π Dashboard Analytics
- Expense summaries
- Group statistics
- Monthly trends and category breakdowns
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Caching: Redis (Upstash)
- Authentication: JWT, Passport.js (Google OAuth)
- Security: bcryptjs, helmet, cors
- File Uploads: multer, cloudinary
- Email: nodemailer
- Scheduling: node-cron
- Testing: Jest, Supertest
- Database Hosting: MongoDB Atlas
- Cloud Storage: Cloudinary
- Redis Cache: Upstash
- Currency Exchange: ExchangeRates API
SplitEase follows a robust, service-oriented architecture:
βββ config/ # Configuration files
βββ middleware/ # Express middleware
βββ models/ # Mongoose models
βββ routes/ # Express routes
βββ services/ # Business logic
βββ tests/ # Jest test suite
βββ utils/ # Utility functions
- Models: Define the data structure
- Routes: Handle HTTP requests
- Services: Implement business logic
- Middleware: Process requests (auth, validation, file uploads)
SplitEase uses MongoDB with the following main collections:
- Users: Profile information, payment methods, friends list
- Groups: Group details and member references
- Expenses: Expense records with splitting information
- Transactions: Payment tracking between users
- ExchangeRates: Currency conversion rates (cached daily)
- Password Hashing: bcrypt with 12 rounds of salting
- JWT Authentication: 7-day expiry tokens
- CORS Protection: Configured for allowed origins
- Rate Limiting: Prevents brute-force attacks
- Secure Headers: Using Helmet.js
- Password Reset: Secure token-based process
POST /api/auth/signup- Register new userPOST /api/auth/login- Login existing userGET /api/auth/google/login- Google OAuth loginPOST /api/auth/forgot-password- Request password resetPOST /api/auth/reset-password- Reset password with token
GET /api/profile/me- Get user profilePUT /api/profile/update- Update profile detailsPOST /api/profile/upload- Upload profile picturePUT /api/profile/change-password- Change passwordPOST /api/profile/add-friend- Add a friendPOST /api/profile/search-friends- Search for users by namePOST /api/profile/add-payment- Add payment methodDELETE /api/profile/delete-friend/:friendId- Remove a friendDELETE /api/profile/delete-payment/:paymentId- Remove payment method
POST /api/groups/create- Create a new groupGET /api/groups/mygroups- Get user's groupsGET /api/groups/:groupId- Get group detailsPUT /api/groups/edit/:groupId- Edit groupDELETE /api/groups/delete/:groupId- Delete groupGET /api/groups/friends- Get user's friends
POST /api/expenses/create- Create a new expenseGET /api/expenses/group/:groupId- Get group expensesGET /api/expenses/my-expenses- Get user expensesGET /api/expenses/expense/:expenseId- Get expense detailsDELETE /api/expenses/delete/:expenseId- Delete expenseGET /api/expenses/summary- Get expense summaryGET /api/expenses/recent- Get recent expensesGET /api/expenses/breakdown/:currency- Get expense breakdown by category
GET /api/transactions/pending- Get pending transactionsGET /api/transactions/history- Get transaction historyPUT /api/transactions/:transactionId/settle- Settle a transaction
GET /api/stats- Get dashboard statisticsGET /api/transactions/recent- Get recent transactions
- Node.js (v14+)
- MongoDB (local or Atlas)
- Redis (optional but recommended)
- Google OAuth credentials (for social login)
- Cloudinary account (for image uploads)
- ExchangeRates API key
Create a .env file in the root directory with the following:
PORT=5000
FRONTEND_URL=https://your-frontend-url.com
BACKEND_GOOGLE_CALLBACK_URL=https://your-backend-url.com/api/auth/google/callback
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/splitease
REDIS_URL=rediss://default:password@your-redis-url.upstash.io:6379
JWT_SECRET=your-jwt-secret-key
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
EXCHANGE_RATE_URL=https://api.apilayer.com/exchangerates_data/latest
EXCHANGERATES_API_KEY=your-api-key
BASE_CURRENCY=INR# Clone the repository
git clone https://github.com/CodeTirtho97/SplitEase_backend.git
# Navigate to the directory
cd SplitEase_backend
# Install dependencies
npm install
# Run development server
npm run dev
# Run tests
npm testSplitEase uses Jest for testing:
# Run all tests
npm test
# Run specific test file
npx jest tests/auth.test.jsThe test suite includes:
- Authentication tests
- Profile management tests
- Group operations tests
- Expense and transaction tests
This project supports continuous integration with:
- Jest test automation
- Custom test sequencer for dependency ordering
- In-memory MongoDB for test isolation
This project is licensed under the ISC License.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or feedback, please reach out to the project maintainer:
- GitHub: CodeTirtho97
- LinkedIn: CodeTirtho97
- Twitter: CodeTirtho97
Made with β€οΈ by CodeTirtho97
