Skip to content

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’° Expense Tracker App

A modern, responsive expense tracking application built with Next.js 14 frontend and Express.js backend. Track your expenses efficiently with a beautiful green-themed UI and comprehensive features.


🌟 Features

πŸ” Authentication System

  • User Registration – Create new accounts with email and password (passwords securely hashed with bcrypt)
  • User Login – Secure login with JWT token storage
  • Forgot Password – Password reset with email and new password
  • Session Management – Automatic logout and token handling

πŸ’Έ Expense & Income Management

  • Add Expenses/Incomes – Create new entries with title, amount, date, category, and notes
  • Edit & Delete – Update or remove entries with confirmation
  • User-Specific Categories – Each user has their own set of income and expense categories
  • Category Management – Create, view, and manage categories filtered by logged-in user

πŸ“Š Dashboard & Analytics

  • Summary Cards – View spending and income totals for week, month, and last 3 months
  • Filtering – Filter by time periods and custom date ranges
  • Category Organization – Color-coded categories per user

🎨 User Interface

  • Modern Design – Clean, intuitive interface with green primary theme
  • Dark Mode Support – Toggle between light and dark themes
  • Responsive Layout – Works perfectly on desktop, tablet, and mobile
  • Toast Notifications – User-friendly success and error messages

πŸ› οΈ Tech Stack

Frontend

  • Next.js 14 - React framework with App Router
  • TypeScript - Type-safe development
  • Tailwind CSS - Utility-first CSS framework
  • shadcn/ui - Modern UI component library
  • Lucide React - Beautiful icons

Backend

  • Express.js – Node.js web framework
  • Sequelize ORM – Database ORM
  • JWT Authentication – Secure token-based auth
  • bcryptjs – Password hashing
  • MySQL – Database

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone https://github.com/kronos-optimize/Expense_Tracker.git
    cd expense-tracker
  2. Configure environment variables

    • Backend:
      Create a .env file inside the backend folder with your database credentials:

      DB_HOST=localhost
      DB_USER=root
      DB_PASS=your_mysql_password
      DB_NAME=expense_tracker
      PORT=4000
      JWT_SECRET=your_jwt_secret
      
    • Frontend:
      Create a .env.local file in the root of your frontend (Next.js) project:

      NEXT_PUBLIC_API_URL=http://localhost:4000/api
      
  3. Run the backend server

    cd backend
    npm install
    npm run dev
  4. Run the frontend server

    cd ../
    npm install
    npm run dev
    # or
    yarn dev
  5. Open your browser Navigate to http://localhost:3000


πŸ“ Project Structure

Expense_Tracker/
β”œβ”€β”€ backend/                       # Express.js backend
β”‚   β”œβ”€β”€ controllers/               # Route controllers (user, expense, income, etc.)
β”‚   β”œβ”€β”€ db/                        # Database config and seeders
β”‚   β”œβ”€β”€ models/                    # Sequelize models
β”‚   β”œβ”€β”€ routes/                    # API route definitions
β”‚   β”œβ”€β”€ server.js                  # Express app entry point
β”‚   └── ...                        # Other backend files
β”œβ”€β”€ frontend/                      # Next.js 14 frontend
β”‚   β”œβ”€β”€ app/                       # App Router pages
β”‚   β”œβ”€β”€ components/                # Reusable React components
β”‚   β”œβ”€β”€ lib/                       # Utility functions
β”‚   β”œβ”€β”€ public/                    # Static assets
β”‚   β”œβ”€β”€ styles/                    # Global styles (if any)
β”‚   └── ...                        # Other frontend files
β”œβ”€β”€ README.md                      # Project documentation

πŸ”Œ API Endpoints

User Endpoints

POST   /api/users/register           # Register new user
POST   /api/users/login              # Login, returns { token, user }
POST   /api/users/forgot-password    # Request password reset

Expense Endpoints

GET    /api/expenses                 # Get all expenses for logged-in user
POST   /api/expenses                 # Add new expense
GET    /api/expenses/:id             # Get expense by ID
PUT    /api/expenses/:id             # Update expense by ID
DELETE /api/expenses/:id             # Delete expense by ID
GET    /api/expense/summary/stats   # get summary data for display at dashboard

Income Endpoints

GET    /api/incomes                  # Get all incomes for logged-in user
POST   /api/incomes                  # Add new income
GET    /api/incomes/:id              # Get income by ID
PUT    /api/incomes/:id              # Update income by ID
DELETE /api/incomes/:id              # Delete income by ID

Income Category Endpoints

GET    /api/income-categories                # Get income categories for logged-in user
POST   /api/income-categories                # Create income category for logged-in user
GET    /api/income-categories/:id            # Get income category by ID
PUT    /api/income-categories/:id            # Update income category by ID
DELETE /api/income-categories/:id            # Delete income category by ID

Expense Category Endpoints

GET    /api/categories               # Get expense categories for logged-in user
POST   /api/categories               # Create expense category for logged-in user
GET    /api/categories/:id           # Get expense category by ID
PUT    /api/categories/:id           # Update expense category by ID
DELETE /api/categories/:id           # Delete expense category by ID

Database Schema (Simplified)

Users Table

CREATE TABLE users (
  id INT PRIMARY KEY AUTO_INCREMENT,
  email VARCHAR(255) UNIQUE NOT NULL,
  password VARCHAR(255) NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

IncomeCategory & ExpenseCategory Tables (user-specific)

CREATE TABLE income_categories (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(50) NOT NULL,
  description VARCHAR(255),
  userId INT NOT NULL,
  FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
);

CREATE TABLE expense_categories (
  id INT PRIMARY KEY AUTO_INCREMENT,
  name VARCHAR(50) NOT NULL,
  description VARCHAR(255),
  userId INT NOT NULL,
  FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE
);

Expenses & Incomes Table

CREATE TABLE expenses (
  id INT PRIMARY KEY AUTO_INCREMENT,
  title VARCHAR(255) NOT NULL,
  amount DECIMAL(10,2) NOT NULL,
  date DATE NOT NULL,
  notes TEXT,
  userId INT NOT NULL,
  categoryId INT NOT NULL,
  FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE,
  FOREIGN KEY (categoryId) REFERENCES expense_categories(id) ON DELETE CASCADE
);

CREATE TABLE incomes (
  id INT PRIMARY KEY AUTO_INCREMENT,
  title VARCHAR(255) NOT NULL,
  amount DECIMAL(10,2) NOT NULL,
  date DATE NOT NULL,
  notes TEXT,
  userId INT NOT NULL,
  categoryId INT NOT NULL,
  FOREIGN KEY (userId) REFERENCES users(id) ON DELETE CASCADE,
  FOREIGN KEY (categoryId) REFERENCES income_categories(id) ON DELETE CASCADE
);

πŸ“ Seeding Logic

  • Seed runs only once: On first run, if no users exist, initial users and categories are created.
  • User-specific categories: Each user gets their own set of income and expense categories.
  • Passwords are hashed before saving users.

🎯 Current Status

  • βœ… Backend and frontend are fully integrated
  • βœ… All features are functional with real API and persistent data
  • βœ… User-specific categories and data filtering
  • βœ… Authentication and session management implemented
  • βœ… Responsive, modern UI

Happy expense tracking! πŸ’š

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages