An open API service indexing awesome lists of open source software.

https://github.com/mohankumar01012005/expense-splitter-challenge-medable

Expense Splitter is a clean, responsive, and production-ready group expense management app built with React and TypeScript. It helps users track shared expenses, calculate real-time balances, and simplify debts with accurate, integer-based calculations for financial reliability. Designed with a modern UI, centralized state management
https://github.com/mohankumar01012005/expense-splitter-challenge-medable

css jest react reactcontext reacttestinglibrary state-management tailwindcss toast typescript vite

Last synced: 4 months ago
JSON representation

Expense Splitter is a clean, responsive, and production-ready group expense management app built with React and TypeScript. It helps users track shared expenses, calculate real-time balances, and simplify debts with accurate, integer-based calculations for financial reliability. Designed with a modern UI, centralized state management

Awesome Lists containing this project

README

          

# πŸ’° Expense Splitter β€” React + TypeScript (Production-Ready)

A clean, responsive, and fully functional group expense management application built using React + TypeScript, featuring shared state management, real-time balance calculations, debt simplification, toast notifications, and a production-quality UI/UX.

This application helps groups (friends, roommates, travel groups, teams) record expenses and instantly see who owes whom.

### Live : https://expense-splitter-challenge.vercel.app

### ✨ Features
### πŸ‘₯ People Management

- **Add people to the group**

- **Remove people with data-integrity checks**

- **Toast notifications for feedback**

- **Validations to prevent accidental actions**

### πŸ’Έ Expense Management

### Add expenses with:

- **Description**

- **Amount**

- **Date**

- **Paid by**

- **Split between**

- **Equal or custom splits**

- **Delete expenses**

- **Real-time UI updates after every mutation**

- **Production-style toast messages using react-hot-toast**

### πŸ“Š Live Balance Calculation

### Total group spending

### Per-person:

- **Total paid**

- **Total owed**

- **Net balance**

β€˜- **Owes’ vs β€˜Is owed’ UI states**

- **Zero balance detection (Settled Up)**

### πŸ”„ Debt Simplification

- **Minimizes number of transactions**

- **Shows suggested settlements (who pays whom)**

- **Integer-based calculations to avoid floating-point errors**

### 🎨 Modern UI & UX

- **Fully responsive**

- **Modern card-based layout**

- **Smooth hover / elevation states**

- **Clean forms with validations**

- **Expandable expense items**

- **Subtle micro-interactions**

### πŸ’Ύ Centralized State Management

- **Custom reducer + context API**

- **Predictable, testable state updates**

- **Actions, selectors & utilities for clean architecture**

### πŸ§ͺ Unit Tests

- **Vitest test environment**

- **Component-level and function-level tests**

- **Utility logic thoroughly validated**

### πŸ› οΈ Tech Stack

### Frontend

- **React**

- **TypeScript**

- **Vite**

- **CSS + Tailwind-like utility classes**

- **State Management**

- **Custom reducer + React Context**

- **Clean action definitions & selectors**

- **Utilities**

- **Custom calculation engine:**

- **calculateTotals.ts**

- **simplifyDebts.ts**

- **format.ts**

- **Notifications**

- **react-hot-toast β€” production-grade toast notifications**

- **Testing**

- **Vitest**

- **React Testing Library**

### πŸ“ Project Structure

src/
β”œβ”€β”€ components/
β”‚ β”œβ”€β”€ PeopleManager.tsx
β”‚ β”œβ”€β”€ ExpenseForm.tsx
β”‚ β”œβ”€β”€ ExpenseList.tsx
β”‚ └── BalanceView.tsx
β”‚
β”œβ”€β”€ state/
β”‚ β”œβ”€β”€ actions.ts
β”‚ β”œβ”€β”€ reducer.ts
β”‚ β”œβ”€β”€ selectors.ts
β”‚ └── index.tsx
β”‚
β”œβ”€β”€ utils/
β”‚ β”œβ”€β”€ calcBalances.ts
β”‚ β”œβ”€β”€ simplifyDebts.ts
β”‚ └── format.ts
β”‚
β”œβ”€β”€ App.tsx
β”œβ”€β”€ main.tsx
└── initialData.ts

### πŸš€ Getting Started
- **1️⃣ Install dependencies**
- **npm install**

### 2️⃣ Start development server
- **npm run dev**

### 3️⃣ Run unit tests
- **npm test**

### 🧩 Core Logic Overview
- **βœ” calculateTotals.ts**

- **Uses integer-based cents to avoid floating-point issues**

### Handles:

- **Equal split**

- **Custom split**

- **Missing or partial custom amounts**

- **Remaining differences assigned deterministically**

### Produces:

- **Per-person paid, owed, net**

- **Group totals**

- **βœ” simplifyDebts.ts**

- **Converts net balances into minimal transactions**

- **Greedy algorithm matching debtors β†’ creditors**

- **Ensures no unmatched amounts remain**

### πŸ›‘οΈ Data Integrity Rules

- **People cannot be removed if referenced in an expense**

- **Expenses require at least one participant**

- **Custom split amounts must match total (or require confirmation)**

- **Every action validated with toast messages**

### πŸ“¦ Production Build
- **npm run build**