SplitKro is a robust expense sharing application built with Spring Boot, designed to help users manage shared expenses easily and efficiently.
- Features
- Technology Stack
- Getting Started
- API Documentation
- Database Configuration
- Swagger UI
- Low-Level Design (LLD)
- High-Level Design (HLD)
Feature | Requirements |
---|---|
User Management | - User registration with email and password - User profile creation and editing - Password reset functionality - User authentication and authorization - User roles (e.g., regular user, group admin) |
Group Creation and Management | - Create new groups with a name and description - Add/remove members to/from groups - Assign group administrators - Group settings (e.g., default split method, currency) - Group invitation system |
Expense Tracking and Splitting | - Add new expenses with amount, description, and date - Assign payer for each expense - Specify split method (equal, exact amounts, percentages) - Ability to split expenses among selected group members - Categorize expenses (e.g., food, transportation, accommodation) - Attach receipts or images to expenses |
Debt Calculation | - Real-time calculation of balances within groups - Individual balance calculation for each user - Simplify debts to minimize transactions - Support for multiple currencies - Historical debt tracking |
Reporting and Analytics | - Generate expense reports by date range, category, or group - Visualize spending patterns with charts and graphs - Export reports in various formats (PDF, CSV) - Personal spending insights and trends |
Settlement | - Mark debts as settled - Record settlement transactions - Integrate with payment gateways for direct settlements - Settlement reminders and notifications |
Notifications | - Email notifications for new expenses, settlements, and reminders - In-app notifications for group activities - Customizable notification preferences |
- Java 17
- Spring Boot 3.2.10
- Spring Security
- Spring Data JPA
- PostgreSQL (Supabase)
- Liquibase (for database migrations)
- Swagger (SpringDoc OpenAPI) for API documentation
- Clone the repository:
git clone https://github.com/yourusername/splitkro.git
- Navigate to the project directory:
cd splitkro
- Build the project:
mvn clean install
- Run the application:
mvn spring-boot:run
Endpoint | Method | Description |
---|---|---|
/api/users |
GET | Retrieve all users |
/api/users/{id} |
GET | Retrieve a specific user |
/api/users |
POST | Create a new user |
/api/users/{id} |
PUT | Update a user |
/api/users/{id} |
DELETE | Delete a user |
/api/groups |
GET | Retrieve all groups |
/api/groups/{id} |
GET | Retrieve a specific group |
/api/groups |
POST | Create a new group |
/api/groups/{id} |
PUT | Update a group |
/api/groups/{id} |
DELETE | Delete a group |
/api/expenses |
GET | Retrieve all expenses |
/api/expenses/{id} |
GET | Retrieve a specific expense |
/api/expenses |
POST | Create a new expense |
/api/expenses/{id} |
PUT | Update an expense |
/api/expenses/{id} |
DELETE | Delete an expense |
For a more detailed API documentation, please refer to the Swagger UI section below.
This application uses PostgreSQL hosted on Supabase. The database connection is configured in the application.properties
file:
spring.datasource.url=jdbc:postgresql://aws-0-ap-south-1.pooler.supabase.com:6543/postgres
spring.datasource.username=postgres.xnghldgwregxdovykyhn
spring.datasource.password=[YOUR-PASSWORD]
Make sure to replace [YOUR-PASSWORD]
with your actual Supabase database password.
Swagger UI is integrated into the application for easy API exploration and testing. Once the application is running, you can access the Swagger UI at:
http://localhost:8080/swagger-ui.html
This interface provides a comprehensive view of all available endpoints, allowing you to test the API directly from your browser.
The application follows a layered architecture:
-
Controller Layer: Handles HTTP requests and responses.
UserController
: Manages user-related operationsGroupController
: Handles group managementExpenseController
: Deals with expense tracking and splitting
-
Service Layer: Implements business logic.
UserService
: User management logicGroupService
: Group operations and member managementExpenseService
: Expense creation, updating, and debt calculationDebtCalculator
: Utility for calculating debts between users
-
Repository Layer: Interfaces with the database.
UserRepository
: Data access for User entitiesGroupRepository
: Data access for Group entitiesExpenseRepository
: Data access for Expense entities
-
Model Layer: Represents database entities.
User
: Represents a user in the systemGroup
: Represents a group of usersExpense
: Represents an expense within a group
-
DTO Layer: Data Transfer Objects for API communication.
UserDTO
: User data for API requests/responsesGroupDTO
: Group data for API requests/responsesExpenseDTO
: Expense data for API requests/responses
-
Security Configuration: Handles authentication and authorization.
SecurityConfig
: Configures Spring Security settings
-
Swagger Configuration: Sets up API documentation.
SwaggerConfig
: Configures Swagger/OpenAPI settings
Here's a high-level diagram of the SplitKro application architecture:
This diagram illustrates the main components of the SplitKro application and how they interact with each other. The application follows a typical Spring Boot architecture with additional components like Swagger for API documentation and Spring Security for authentication.
The SplitKro application uses a relational database model to manage users, groups, expenses, and settlements. Below is a detailed explanation of each table and its relationships.
-
users
- Stores user account information
- Fields: id, username, email, password_hash, created_at, updated_at
- Primary Key: id
- Unique Constraints: username, email
-
groups
- Represents expense sharing groups
- Fields: id, name, description, created_by, created_at, updated_at
- Primary Key: id
- Foreign Key: created_by references users(id)
-
user_group
- Manages the many-to-many relationship between users and groups
- Fields: user_id, group_id, role, joined_at
- Primary Key: (user_id, group_id)
- Foreign Keys:
- user_id references users(id)
- group_id references groups(id)
-
expenses
- Records individual expenses
- Fields: id, group_id, payer_id, amount, description, date, category_id, created_at, updated_at
- Primary Key: id
- Foreign Keys:
- group_id references groups(id)
- payer_id references users(id)
- category_id references categories(id)
-
expense_splits
- Tracks how expenses are split among users
- Fields: id, expense_id, user_id, amount, created_at, updated_at
- Primary Key: id
- Foreign Keys:
- expense_id references expenses(id)
- user_id references users(id)
-
settlements
- Records settlements between users
- Fields: id, payer_id, payee_id, amount, group_id, settled_at, created_at, updated_at
- Primary Key: id
- Foreign Keys:
- payer_id references users(id)
- payee_id references users(id)
- group_id references groups(id)
-
categories
- Defines categories for expenses
- Fields: id, name, created_at, updated_at
- Primary Key: id
- Unique Constraint: name
- A user can belong to multiple groups, and a group can have multiple users (Many-to-Many relationship managed through user_group table)
- An expense belongs to one group and is paid by one user (payer)
- An expense can be split among multiple users (One-to-Many relationship with expense_splits)
- A settlement involves two users (payer and payee) and is associated with a group
- Each expense can belong to one category
- Use of SERIAL type for auto-incrementing primary keys
- Timestamps (created_at, updated_at) for audit trails
- Proper foreign key constraints to maintain referential integrity
- Indexes on frequently queried columns for performance optimization
- Use of DECIMAL type for financial amounts to ensure precision
- Trigger-based automatic updating of 'updated_at' columns