Skip to content

Repository files navigation

πŸͺ™ Budgetcap β€” Zero-Based Envelope Budgeting App

Budgetcap is a modern, full-stack personal finance and budgeting application built on the principles of Zero-Based Envelope Budgeting. It helps households plan their spending, allocate funds to specific categories (envelopes), track real-time balances, and manage accounts and transactions in a shared household environment.

Designed for multi-user collaboration within a household, this application features a sleek responsive UI with light/dark theme support, smooth drag-and-drop budget organizing, and decimal-free currency calculations to ensure high precision and reliability.


πŸš€ Features

πŸ” 1. Authentication & Household Sharing

  • Secure Authentication: Secure user registration and login powered by NextAuth.js v5 (using bcrypt for password hashing).
  • Household Concept: Users belong to a "Household". Multiple family members can log in and share the same budget, envelopes, and transaction lists in real time.

🏦 2. Account Management

  • Multi-Account Tracking: Support for three types of real-world financial accounts:
    • CHECKING (Daily transaction account)
    • SAVINGS (Savings and goal funds)
    • CASH (Cash-on-hand or physical wallets)
  • Default Accounts: Easily designate a primary account for quick transaction entry.
  • Interactive Drag & Drop: Reorder accounts to customize your sidebar or dashboard overview.

βœ‰οΈ 3. Zero-Based Envelope Budgeting

  • Envelope Sets: Group envelopes into logical sections (e.g., Monthly Expenses, Annual Funds, Special Projects).
  • Budget Period Settings: Customize when a budget month starts for each Envelope Set (e.g., the 1st of the month, or aligned with a custom payday).
  • Allocations: Allocate a specific portion of your income to envelopes on a monthly basis.
  • Rollovers: Available balances automatically roll over from previous months, calculating the cumulative budget status.
  • Drag-and-Drop Sorting: Seamlessly reorder both Envelope Sets and individual Envelopes using @dnd-kit.

🎯 4. Goal Tracking

  • Goal Envelopes: Toggle any envelope to function as a savings goal.
  • Goal Amount & Deadlines: Set target amounts and target dates for specific milestones.
  • Visual Progress: Track how close you are to completing the goal relative to the total envelope balance.

πŸ’Έ 5. Transactions & Transfers

  • Three Transaction Types:
    • INCOME: Credit money to accounts and assign it to "Unallocated" or specific envelopes.
    • EXPENSE: Log spending from a chosen account and envelope.
    • TRANSFER: Move money between two accounts (Account Transfer) or two envelopes (Envelope Transfer).
  • Recurring Transactions: Create recurring transaction templates that automatically copy and generate on a specified day of the month.
  • Transaction Logs: Filter and view historical transactions by envelope, date range, or account.

πŸ“ˆ 6. Analytical Reports

  • Visual Insights: View charts and breakdowns of spending habits, income vs. expenses, and budget allocation distributions to optimize your financial plans.

πŸŒ“ 7. Premium Dark & Light UI

  • Dynamic Theme Toggle: Clean light and dark modes powered by next-themes and styled with TailwindCSS and Radix UI primitives.
  • Responsive Layout: Fits beautifully on desktop, tablet, and mobile screens.

πŸ› οΈ Tech Stack


πŸ“ Database Architecture

The database model is configured in PostgreSQL using Prisma.

erDiagram
    User ||--o{ HouseholdMember : "belongs to"
    User ||--o{ Household : "owns"
    Household ||--o{ HouseholdMember : "has"
    Household ||--o{ Account : "owns"
    Household ||--o{ EnvelopeSet : "owns"
    Household ||--o{ Transaction : "records"
    
    Account ||--o{ EnvelopeSet : "linked to"
    Account ||--o{ Transaction : "primary source"
    Account ||--o{ Transaction : "transfer destination"
    
    EnvelopeSet ||--o{ Envelope : "contains"
    
    Envelope ||--o{ Allocation : "has monthly"
    Envelope ||--o{ Transaction : "debited from"
    Envelope ||--o{ Transaction : "credited to (transfers)"
Loading

Key Technical Decisions:

  1. Paise-Based Currency: All monetary values (amountInPaise, openingBalanceInPaise, goalAmountInPaise) are stored as integers representing Paise (1 Rupee = 100 Paise). Storing currency as integers completely avoids the floating-point inaccuracies (0.1 + 0.2 !== 0.3) typical of float/double database columns.
  2. Cascading Deletes: When a household is deleted, all associated accounts, envelopes, allocations, and transactions cascade and delete automatically.
  3. Unique Constraints: Envelopes can only have one allocation per month/year, enforced by a composite unique index: @@unique([envelopeId, month, year]).

πŸ“ Project Directory Structure

β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/                   # Login, register pages
β”‚   β”œβ”€β”€ (dashboard)/              # Core pages (budget, accounts, envelopes, transactions, etc.)
β”‚   β”œβ”€β”€ actions/                  # Next.js Server Actions (auth, accounts, budget, transactions)
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ auth/[...nextauth]    # NextAuth.js API handlers
β”‚   β”‚   └── cron/recurring        # Trigger endpoint for monthly recurring transactions
β”‚   β”œβ”€β”€ globals.css               # Global styling, Tailwind imports
β”‚   β”œβ”€β”€ layout.tsx                # App layout wrapper (Auth & Theme providers)
β”‚   └── page.tsx                  # Home redirect to dashboard
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ accounts/                 # Account forms, dialogs, drag-and-drop lists
β”‚   β”œβ”€β”€ budget/                   # Allocation tables, rollover trackers, forms
β”‚   β”œβ”€β”€ ui/                       # Shadcn/Radix UI base design components
β”‚   β”œβ”€β”€ sidebar.tsx               # Sidebar navigation (IndianRupee & links)
β”‚   └── header.tsx                # Navigation header & user status
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ auth-helpers.ts           # Authentication session guards
β”‚   β”œβ”€β”€ prisma.ts                 # Database client singleton
β”‚   └── utils.ts                  # HSL-Tailwind classes, formatINR, rupeesToPaise
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma             # DB schemas (User, Household, Account, Transaction, etc.)
β”‚   └── migrations/               # Database migrations folder
β”œβ”€β”€ public/                       # Static assets
└── vercel.json                   # Vercel deployment cron configuration

βš™οΈ Getting Started

1. Prerequisites

Ensure you have the following installed on your machine:

  • Node.js (v20+ recommended)
  • pnpm or npm
  • A running PostgreSQL database instance (Supabase, local Postgres, or Docker image)

2. Installation

Clone the repository and install the dependencies:

git clone <repository-url>
cd budgetcap
pnpm install # or npm install

3. Setup Environment Variables

Create a .env file in the root directory:

# PostgreSQL connection string
DATABASE_URL="postgresql://postgres:12345678@localhost:5432/budgetcap"

# Cryptographically strong secret key for NextAuth.js
AUTH_SECRET="your-generated-super-secret-key"

# Base URL of the app
NEXTAUTH_URL="http://localhost:3000"

# Optional cron secret for recurring transactions (in production)
CRON_SECRET="your-custom-cron-secret-key"

4. Database Setup & Migrations

Create your database tables and run the initial migration:

npx prisma db push # Or run full migrations: npx prisma migrate dev

5. Running the Application

Start the development server:

pnpm dev # or npm run dev

Open http://localhost:3000 in your browser. Register a new account, which will automatically create a default Household, a primary Checking account, and get your budget started!

6. Triggering Recurring Transactions

To test the monthly recurring transactions generator in development, you can invoke the GET request:

curl http://localhost:3000/api/cron/recurring

In production, this route requires the authorization header Authorization: Bearer <CRON_SECRET>. It is triggered automatically at 6:00 AM on the 1st of every month via the schedule defined in vercel.json.


πŸ“œ License

This project is licensed under the MIT License.

About

This is a basic budget app.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages