Skip to content

Expense-sharing app to split and manage group costs with ease.

Notifications You must be signed in to change notification settings

Achal13jain/Splitwise_web_app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SplitWise - Expense Sharing Application

Java Spring Boot PostgreSQL

A modern expense sharing application that helps groups split bills and track shared expenses effortlessly

Overview

A full-stack expense sharing and management application built with Spring Boot and React. SplitWise helps users split bills and expenses with friends, track balances, and settle up easily.

πŸš€ Features

Core Functionality

  • User Authentication: Secure registration and login with BCrypt password encryption
  • Group Management: Create groups and add members for expense sharing
  • Expense Tracking: Add and track expenses with detailed descriptions
  • Automatic Split Calculation: Expenses are automatically split equally among group members
  • Balance Tracking: Real-time balance calculations showing who owes whom
  • Settlement System: Easy settlement of debts between group members
  • Transaction History: Complete history of all expenses and settlements
  • Receipt Generation: Download and print receipts for any expense

Additional Features

  • Expense Calculator: Built-in calculator with tip percentage calculation
  • Category Support: Categorize expenses (Food, Transport, Housing, etc.)
  • Real-time Notifications: Toast notifications for user actions
  • Responsive Design: Mobile-friendly interface using Tailwind CSS
  • Form Validation: Comprehensive client-side validation with helpful error messages

πŸ› οΈ Tech Stack

Backend

  • Java 24 (compiled with Java 16 compatibility)
  • Spring Boot 3.2.2
    • Spring Boot Starter Web
    • Spring Boot Starter Data JPA
    • Spring Boot Starter Security
    • Spring Boot DevTools
  • PostgreSQL - Database
  • Maven - Build tool

Frontend

  • React 18
  • React Router DOM - Navigation
  • Tailwind CSS - Styling
  • Lucide React - Icons
  • Fetch API - HTTP requests

πŸ“‹ Prerequisites

Before running this application, ensure you have the following installed:

  • Java JDK 16+
  • Node.js 14+ and npm
  • PostgreSQL 12+
  • Maven 3.6+

πŸ”§ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd splitwise-project

2. Database Setup

Create a PostgreSQL database:

CREATE DATABASE splitwise;

Update database credentials in splitwise-backend/src/main/resources/application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/splitwise
spring.datasource.username=YOUR_USERNAME
spring.datasource.password=YOUR_PASSWORD
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true

3. Backend Setup

Navigate to the backend directory and build the project:

cd splitwise-backend
mvn clean install
mvn spring-boot:run

The backend server will start on http://localhost:8080

4. Frontend Setup

Navigate to the frontend directory and install dependencies:

cd splitwise-react-frontend
npm install
npm start

The frontend will start on http://localhost:3000

πŸ“ Project Structure

Backend Structure

splitwise-backend/
β”œβ”€β”€ src/main/java/com/splitwise/
β”‚   β”œβ”€β”€ config/                  # Security & CORS configuration
β”‚   β”‚   β”œβ”€β”€ SecurityConfig.java
β”‚   β”‚   └── WebConfig.java
β”‚   β”œβ”€β”€ controller/              # REST API endpoints
β”‚   β”‚   β”œβ”€β”€ ExpenseController.java
β”‚   β”‚   β”œβ”€β”€ GroupController.java
β”‚   β”‚   β”œβ”€β”€ SettlementController.java
β”‚   β”‚   └── UserController.java
β”‚   β”œβ”€β”€ dto/                     # Data Transfer Objects
β”‚   β”‚   β”œβ”€β”€ ExpenseDTO.java
β”‚   β”‚   β”œβ”€β”€ GroupDetailsDTO.java
β”‚   β”‚   β”œβ”€β”€ LoginRequest.java
β”‚   β”‚   β”œβ”€β”€ SettlementDTO.java
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ model/                   # JPA Entities
β”‚   β”‚   β”œβ”€β”€ User.java
β”‚   β”‚   β”œβ”€β”€ Group.java
β”‚   β”‚   β”œβ”€β”€ GroupMember.java
β”‚   β”‚   β”œβ”€β”€ Expense.java
β”‚   β”‚   └── Settlement.java
β”‚   β”œβ”€β”€ repository/              # JPA Repositories
β”‚   β”‚   β”œβ”€β”€ UserRepository.java
β”‚   β”‚   β”œβ”€β”€ GroupRepository.java
β”‚   β”‚   β”œβ”€β”€ ExpenseRepository.java
β”‚   β”‚   └── SettlementRepository.java
β”‚   β”œβ”€β”€ service/                 # Business Logic
β”‚   β”‚   β”œβ”€β”€ UserService.java
β”‚   β”‚   β”œβ”€β”€ GroupService.java
β”‚   β”‚   β”œβ”€β”€ ExpenseService.java
β”‚   β”‚   └── SettlementService.java
β”‚   └── SplitwiseApplication.java
└── src/main/resources/
    └── application.properties

Frontend Structure

splitwise-react-frontend/
β”œβ”€β”€ public/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ auth/               # Authentication components
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthProvider.js
β”‚   β”‚   β”‚   β”œβ”€β”€ LoginPage.js
β”‚   β”‚   β”‚   └── ProtectedRoute.js
β”‚   β”‚   β”œβ”€β”€ layout/             # Layout components
β”‚   β”‚   β”‚   └── Navbar.js
β”‚   β”‚   β”œβ”€β”€ pages/              # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.js
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.js
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateGroup.js
β”‚   β”‚   β”‚   β”œβ”€β”€ AddExpense.js
β”‚   β”‚   β”‚   β”œβ”€β”€ GroupDetails.js
β”‚   β”‚   β”‚   └── MyTransactions.js
β”‚   β”‚   └── ui/                 # UI components
β”‚   β”‚       β”œβ”€β”€ NotificationSystem.js
β”‚   β”‚       β”œβ”€β”€ LoadingSpinner.js
β”‚   β”‚       β”œβ”€β”€ ExpenseCalculator.js
β”‚   β”‚       └── ReceiptGenerator.js
β”‚   β”œβ”€β”€ utils/                  # Utility functions
β”‚   β”‚   β”œβ”€β”€ api.js
β”‚   β”‚   β”œβ”€β”€ constants.js
β”‚   β”‚   └── expenseCategories.js
β”‚   β”œβ”€β”€ App.js
β”‚   β”œβ”€β”€ App.css
β”‚   β”œβ”€β”€ index.js
β”‚   └── index.css
└── package.json

πŸ”Œ API Endpoints

User Endpoints

  • POST /api/users/register - Register new user
  • POST /api/users/login - Login user
  • GET /api/users/email/{email} - Get user by email

Group Endpoints

  • POST /api/groups/create-with-members - Create group with members
  • GET /api/groups/user/email/{email} - Get user's groups
  • GET /api/groups/{id}/details?userId={userId} - Get group details

Expense Endpoints

  • POST /api/expenses/add - Add new expense
  • GET /api/users/{userId}/transactions - Get user transactions

Settlement Endpoints

  • POST /api/settle - Settle up between users
  • GET /api/settlements/user/{userId} - Get user settlements

πŸ’‘ Usage

1. Register/Login

  • Navigate to the homepage
  • Click "Sign Up" to create a new account
  • Or login with existing credentials

2. Create a Group

  • Go to "Create Group" from the navbar
  • Enter a group name
  • Add members from the available users list
  • Click "Create Group"

3. Add an Expense

  • Navigate to "Add Expense"
  • Select a group
  • Enter description and amount
  • Optionally select a category
  • Click "Add Expense"

4. View Group Details

  • From the Dashboard, click on any group
  • View members, balances, and expenses
  • See who owes whom
  • Generate receipts for expenses

5. Settle Up

  • In the group details page
  • Click "Settle Up" button
  • Choose who to settle with
  • Confirm the settlement

6. Use Calculator

  • Click the calculator icon in the navbar
  • Enter total amount
  • Adjust number of people
  • Add tip percentage if needed
  • See automatic split calculation

🎨 Key Features Explained

Balance Calculation Algorithm

The application uses a sophisticated balance calculation system:

  1. Tracks all expenses paid by each member
  2. Calculates equal split among all group members
  3. Applies settlement transactions to adjust balances
  4. Displays personalized "you owe" or "owes you" messages

Security Features

  • Passwords encrypted with BCrypt
  • CSRF protection disabled for API endpoints
  • CORS configured for cross-origin requests
  • Spring Security integrated

Validation

  • Frontend: Real-time form validation with helpful error messages
  • Backend: Entity validation and business logic checks
  • Prevents negative amounts, invalid dates, duplicate users

πŸ› Troubleshooting

Backend Issues

Database Connection Error

  • Ensure PostgreSQL is running
  • Check database credentials in application.properties
  • Verify database exists: psql -U postgres -l

Port Already in Use

  • Change port in application.properties: server.port=8081

Frontend Issues

API Connection Error

  • Verify backend is running on port 8080
  • Check API_BASE constant in src/utils/constants.js

Module Not Found

  • Delete node_modules and package-lock.json
  • Run npm install again

πŸ”„ Future Enhancements

  • Unequal expense splitting
  • Group admin controls
  • Email notifications
  • Export data to CSV/PDF
  • Multi-currency support
  • Expense attachments (receipts/images)
  • Dark mode theme
  • Mobile app version

πŸ‘₯ Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

About

Expense-sharing app to split and manage group costs with ease.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages