Skip to content

thepratikguptaa/spendsense

Repository files navigation

SpendSense - Brutal AI Finance Coach

A minimal, no-nonsense expense tracker that gives brutally honest AI insights based on your spending habits. Built with Next.js, Tailwind CSS, shadcn/ui, and MongoDB.

Features

  • Add Expenses - Quick 1-click expense logging with auto-categorization
  • Auto Categorization - Keyword-based detection for food, transport, shopping, entertainment, bills
  • Full CRUD - Add, view, edit, and delete expenses
  • 7-Day Summary - Total spending, top category, and transaction count at a glance
  • AI Insights - Brutally honest spending analysis powered by Azure OpenAI (GPT-4.1)
  • User Accounts - Simple username + password auth with JWT cookies
  • Per-User Data - Each user sees only their own expenses
  • Dark / Light Mode - Toggle between themes, persisted in localStorage
  • Mobile-First - Responsive design, works great on all screen sizes

Tech Stack

  • Frontend - Next.js (App Router), React, Tailwind CSS, shadcn/ui
  • Backend - Next.js API Routes, Mongoose
  • Database - MongoDB
  • AI - Azure OpenAI (GPT-4.1)
  • Auth - bcryptjs + jose (JWT)
  • Font - Roboto (Google Fonts)

Getting Started

Prerequisites

  • Node.js 18+
  • MongoDB (local or Atlas)
  • Azure OpenAI API key

Installation

git clone https://github.com/your-username/spendsense.git
cd spendsense
npm install

Environment Variables

Create a .env.local file in the root directory:

MONGODB_URI=mongodb://localhost:27017/spendsense
AZURE_OPENAI_ENDPOINT=your-azure-openai-endpoint
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_API_VERSION=2025-01-01-preview
JWT_SECRET=your-secret-key-here

Run

npm run dev

Open http://localhost:3000 in your browser.

Project Structure

src/
├── app/
│   ├── api/
│   │   ├── auth/
│   │   │   ├── login/route.ts
│   │   │   ├── register/route.ts
│   │   │   ├── logout/route.ts
│   │   │   └── me/route.ts
│   │   ├── expense/
│   │   │   ├── route.ts          # POST (create) + GET (list)
│   │   │   └── [id]/route.ts     # PUT (update) + DELETE
│   │   └── analyze/route.ts      # POST (AI insights)
│   ├── login/page.tsx
│   ├── page.tsx
│   ├── layout.tsx
│   └── globals.css
├── components/
│   ├── ui/                       # shadcn/ui components
│   ├── theme-provider.tsx
│   └── theme-toggle.tsx
├── lib/
│   ├── models/
│   │   ├── expense.ts
│   │   └── user.ts
│   ├── auth.ts
│   ├── categorize.ts
│   └── mongodb.ts
└── middleware.ts

API Routes

Method Route Description
POST /api/auth/register Create a new account
POST /api/auth/login Login
POST /api/auth/logout Logout
GET /api/auth/me Get current user
POST /api/expense Add expense
GET /api/expense Get last 20 expenses
PUT /api/expense/:id Update expense
DELETE /api/expense/:id Delete expense
POST /api/analyze Get AI spending insights

Created by

Pratik Gupta

About

A minimal, no-nonsense expense tracker that gives brutally honest AI insights based on your spending habits. Built with Next.js, Tailwind CSS, shadcn/ui, and MongoDB.

Topics

Resources

Stars

Watchers

Forks

Contributors