Skip to content

Honey-pg/splitBuddy

Repository files navigation

πŸ’Έ SplitBuddy β€” Intelligent Expense Sharing Made Simple

SplitBuddy is a full-stack expense-sharing web application designed to simplify group finances. Whether you're splitting bills with friends, roommates, or colleagues, SplitBuddy ensures transparency, fairness, and minimal transactions with an optimized settlement system.


✨ Features

  • πŸ“± Fully Responsive Modern UI
    Clean, intuitive, and mobile-friendly interface for seamless usage across devices.

  • πŸ” Google OAuth Authentication
    Secure and hassle-free login using Google accounts.

  • πŸ‘₯ Add Friends via Email
    Easily connect and manage expenses with your network.

  • πŸ’° Expense Splitting System
    Add expenses, split equally or unequally, and track balances in real-time.

  • ⚑ Intelligent "Settle Up" Algorithm
    Minimizes the number of transactions using an optimized approach based on priority queues.

  • πŸ”” Real-Time Notifications
    Get instant updates for new expenses, settlements, and friend activity.

  • πŸ›‘οΈ Rate Limiting for Security
    Prevents abuse and ensures API stability.


πŸ› οΈ Tech Stack

Frontend

  • React.js
  • Tailwind CSS / CSS Modules
  • Axios

Backend

  • Node.js
  • Express.js

Database

  • MongoDB (Mongoose ORM)

Authentication

  • Google OAuth 2.0
  • JWT (JSON Web Tokens)

Other Tools

  • Redis (for rate limiting / caching)
  • Nodemailer (email services)
  • WebSockets / Socket.io (for real-time notifications)

βš™οΈ How It Works

πŸ“Š Expense Tracking

  • Users can create expenses and split them among participants.
  • Each transaction updates a balance sheet representing who owes whom.
  • The system maintains a net balance for each user.

πŸ”„ "Settle Up" Optimization

SplitBuddy uses a Priority Queue (Min Heap / Max Heap) based approach to minimize the number of transactions:

  • Creditors (positive balances) are stored in a Max Heap
  • Debtors (negative balances) are stored in a Min Heap
  • The system repeatedly matches the highest creditor with the highest debtor
  • Transactions are settled greedily until all balances reach zero

πŸ€” Why This Approach?

  • A naive greedy approach may not minimize the number of transactions.
  • Using heaps ensures:
    • Efficient selection of largest debts/credits
    • Reduced total transactions
    • Time complexity optimization

This results in a cleaner and more practical settlement experience.


πŸ“ Project Structure

# πŸ“‚ SplitBuddy Project Structure

β”œβ”€β”€ πŸ“ backend/                  # Node.js + Express Backend
β”‚   β”œβ”€β”€ πŸ“ src/                 
β”‚   β”‚   β”œβ”€β”€ πŸ“ controllers/      # Request handlers/Logic (e.g., authController.js)
β”‚   β”‚   β”œβ”€β”€ πŸ“ models/           # MongoDB database schemas (User, Expense, Notification)
β”‚   β”‚   β”œβ”€β”€ πŸ“ routes/           # API Endpoints layout (e.g., authRoutes.js, settleRoutes.js)
β”‚   β”‚   └── πŸ“ services/         # Core business logic (e.g., AuthService, NotificationService)
β”‚   β”œβ”€β”€ πŸ“„ .env                  # Backend environment variables (DB Uri, JWT Secret)
β”‚   └── πŸ“„ package.json          # Backend dependencies
β”‚
β”œβ”€β”€ πŸ“ src/                      # Frontend (React + Vite + Tailwind)
β”‚   β”œβ”€β”€ πŸ“ api/                  # Axios instance and API call wrappers
β”‚   β”œβ”€β”€ πŸ“ components/           # Reusable UI & Mascot components (e.g., NotificationDropdown.jsx)
β”‚   β”œβ”€β”€ πŸ“ context/              # React Context Providers
β”‚   β”œβ”€β”€ πŸ“ hooks/                # Custom React hooks
β”‚   β”œβ”€β”€ πŸ“ integrations/         # Configuration for third-party setups (like Supabase, etc)
β”‚   β”œβ”€β”€ πŸ“ lib/                  # Utility functions
β”‚   β”œβ”€β”€ πŸ“ pages/                # Main Application Views (Dashboard.jsx, LoginPage.jsx, etc.)
β”‚   β”œβ”€β”€ πŸ“ store/                # Zustand State Management (authStore, dashboardStore, settleupStore)
β”‚   β”œβ”€β”€ πŸ“„ App.jsx               # Main React Router & Component Wrapper
β”‚   β”œβ”€β”€ πŸ“„ main.jsx              # React DOM entry point
β”‚   └── πŸ“„ index.css             # Main styling, Tailwind directives
β”‚
β”œβ”€β”€ πŸ“ public/                   # Static non-compiled assets (favicons, images)
β”œβ”€β”€ πŸ“„ package.json              # Frontend dependencies and npm scripts
β”œβ”€β”€ πŸ“„ tailwind.config.ts        # Tailwind CSS styling and theme configuration
β”œβ”€β”€ πŸ“„ vite.config.ts            # Vite bundler configuration
β”œβ”€β”€ πŸ“„ vercel.json               # Vercel configuration for client-side routing
└── πŸ“„ .env                      # Frontend environment variables (Vite Google Client ID)


πŸš€ Setup & Installation

1️⃣ Clone the Repository

git clone https://github.com/your-username/splitbuddy.git
cd splitbuddy

2️⃣ Install Dependencies

Frontend

cd frontend
npm install

Backend

cd backend
npm install

3️⃣ Setup Environment Variables

Create a .env file in the backend and frontend directories.

4️⃣ Run the Application

Start Backend

cd backend
npm run dev

Start Frontend

cd frontend
npm start

πŸ”‘ Environment Variables

Backend (/backend/.env)

PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

EMAIL_USER=your_email
EMAIL_PASS=your_email_password

REDIS_URL=your_redis_url

Frontend (/frontend/.env)

REACT_APP_API_URL=http://localhost:5000/api
REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id

πŸ”— API Highlights

πŸ” Auth Routes

  • POST /api/auth/google
  • GET /api/auth/user

πŸ’Έ Expense Routes

  • POST /api/expenses
  • GET /api/expenses
  • POST /api/expenses/settle

πŸ‘₯ Friend System

  • POST /api/friends/add
  • GET /api/friends

πŸ”” Notification Routes

  • GET /api/notifications
  • PATCH /api/notifications/read

πŸ”’ Security Features

  • 🚫 Rate Limiting
  • πŸ”‘ JWT Authentication
  • 🧱 Secure API Handling

🚧 Future Improvements

  • πŸ“Š Advanced analytics and spending insights
  • πŸ“± Native mobile app (React Native)
  • 🌍 Multi-currency support
  • 🧾 Receipt scanning with OCR
  • 🀝 Group management enhancements

⭐ Final Note

SplitBuddy is built with a focus on clean architecture, scalability, and real-world usability. It demonstrates strong full-stack development practices along with algorithmic optimization in a practical application.

If you found this project useful, consider giving it a ⭐

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors