Skip to content

acharyaanusha/NudgePay

Repository files navigation

NudgePay

A full-stack web application to track and settle expenses between friends. Split bills easily with multiple split options (equal, exact amounts, percentages, or shares) and keep track of who owes whom.

Features

  • User Management: Switch between different users to see personalized views
  • Transaction Tracking: Add, edit, and delete expense transactions
  • Flexible Split Options:
    • Equal split
    • Exact amounts
    • Percentage-based
    • Share-based
  • Balance Tracking: See your overall balance and detailed breakdown of who owes you and whom you owe
  • Settlement Management: Record payments to settle debts
  • Activity Feed: View recent transaction history

Tech Stack

Frontend

  • React 18
  • Tailwind CSS for styling
  • Lucide React for icons
  • Fetch API for HTTP requests

Backend

  • Node.js with Express
  • PostgreSQL database
  • RESTful API architecture

Project Structure

NudgePay/
├── backend/
│   ├── src/
│   │   ├── config/
│   │   │   ├── database.sql    # Database schema
│   │   │   └── db.js           # Database connection
│   │   ├── controllers/        # Request handlers
│   │   │   ├── userController.js
│   │   │   ├── transactionController.js
│   │   │   └── settlementController.js
│   │   ├── models/            # Database models
│   │   │   ├── User.js
│   │   │   ├── Transaction.js
│   │   │   └── Settlement.js
│   │   ├── routes/            # API routes
│   │   │   ├── userRoutes.js
│   │   │   ├── transactionRoutes.js
│   │   │   └── settlementRoutes.js
│   │   ├── middleware/        # Express middleware
│   │   │   └── errorHandler.js
│   │   └── server.js          # Express app entry point
│   ├── package.json
│   ├── .env.example
│   └── .gitignore
├── frontend/
│   ├── public/
│   │   └── index.html
│   ├── src/
│   │   ├── components/        # React components
│   │   │   ├── Header.jsx
│   │   │   ├── BalanceCard.jsx
│   │   │   ├── Navigation.jsx
│   │   │   ├── Dashboard.jsx
│   │   │   ├── OwesSection.jsx
│   │   │   ├── ActivitySection.jsx
│   │   │   ├── AddTransaction.jsx
│   │   │   └── SettleUp.jsx
│   │   ├── services/          # API service layer
│   │   │   └── api.js
│   │   ├── App.jsx            # Main app component
│   │   ├── index.jsx          # React entry point
│   │   └── index.css          # Global styles
│   ├── package.json
│   ├── tailwind.config.js
│   ├── postcss.config.js
│   ├── .env.example
│   └── .gitignore
└── README.md

Prerequisites

  • Node.js (v16 or higher)
  • PostgreSQL (v12 or higher)
  • npm or yarn

Installation & Setup

1. Clone the Repository

cd NudgePay

2. Database Setup

First, create a PostgreSQL database:

# Login to PostgreSQL
psql -U postgres

# Create database
CREATE DATABASE nudgepay;

# Exit psql
\q

Then, run the database schema:

cd backend
psql -U postgres -d nudgepay -f src/config/database.sql

3. Backend Setup

cd backend

# Install dependencies
npm install

# Create .env file from example
cp .env.example .env

# Edit .env file with your database credentials
# nano .env or use your preferred editor

# Start the backend server
npm run dev

The backend server will run on http://localhost:5000

4. Frontend Setup

Open a new terminal window:

cd frontend

# Install dependencies
npm install

# Create .env file from example
cp .env.example .env

# Start the frontend development server
npm start

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

Environment Variables

Backend (.env)

PORT=5000
NODE_ENV=development
DB_HOST=localhost
DB_PORT=5432
DB_NAME=nudgepay
DB_USER=postgres
DB_PASSWORD=your_password

Frontend (.env)

REACT_APP_API_URL=http://localhost:5000/api

API Endpoints

Users

  • GET /api/users - Get all users
  • GET /api/users/:id - Get user by ID
  • GET /api/users/balances - Get balance for all users
  • GET /api/users/:id/owes - Get detailed breakdown of what a user owes/is owed
  • POST /api/users - Create new user
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user

Transactions

  • GET /api/transactions - Get all transactions
  • GET /api/transactions/:id - Get transaction by ID
  • GET /api/transactions/user/:userId - Get transactions for a specific user
  • POST /api/transactions - Create new transaction
  • PUT /api/transactions/:id - Update transaction
  • DELETE /api/transactions/:id - Delete transaction

Settlements

  • GET /api/settlements - Get all settlements
  • GET /api/settlements/:id - Get settlement by ID
  • GET /api/settlements/user/:userId - Get settlements for a specific user
  • POST /api/settlements - Create new settlement
  • DELETE /api/settlements/:id - Delete settlement

Usage

  1. Select User: Use the dropdown in the header to switch between users
  2. View Dashboard: See your balance, who owes you, and whom you owe
  3. Add Transaction:
    • Click "Add Bill"
    • Enter description and total amount
    • Select who paid
    • Choose split type (equal, exact, percentage, or shares)
    • Select participants
    • Configure split amounts/percentages/shares as needed
    • Click "Add Transaction"
  4. Edit/Delete Transaction: Click the edit or delete icon on any transaction in your activity feed
  5. Settle Up:
    • Click "Settle Up"
    • Select who you're paying
    • Enter the amount
    • Click "Record Payment"
    • Or use "Quick Settle" to pay the exact amount you owe

Database Schema

Tables

  • users: User information (id, name, email)
  • transactions: Expense records (id, paid_by_user_id, total_amount, description, split_type)
  • transaction_splits: Split details for each transaction (transaction_id, user_id, amount)
  • settlements: Payment records between users (from_user_id, to_user_id, amount)

Development

Backend Development

cd backend
npm run dev  # Uses nodemon for auto-reload

Frontend Development

cd frontend
npm start  # Hot reload enabled by default

Production Build

Backend

cd backend
npm start

Frontend

cd frontend
npm run build
# Serve the build folder with a static server

Future Enhancements

  • User authentication and authorization
  • Group management for shared expenses
  • Email notifications for new transactions
  • Currency conversion support
  • Mobile app (React Native)
  • Export transaction history (CSV, PDF)
  • Recurring transactions
  • Transaction categories and tags
  • Charts and analytics

Contributing

Feel free to submit issues and enhancement requests!

License

MIT License

About

A full-stack web application to track and settle expenses between friends

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages