Skip to content

Musta-Pollo/nestjs-react-expense-tracking-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ExpenseTracker - Full Stack Application

A modern, full-stack expense tracking application built with NestJS (backend) and React (frontend). This project demonstrates professional-grade architecture, type safety, and modern development practices.

πŸ“‹ Overview

ExpenseTracker is a comprehensive personal finance management application that allows users to:

  • βœ… Track daily expenses with categorization
  • πŸ“Š Visualize spending patterns with interactive charts
  • πŸ’° Set and monitor monthly budgets
  • 🏷️ Create custom expense categories with colors and icons
  • πŸ“± Responsive design for desktop and mobile use
  • πŸ” Secure user authentication with JWT

πŸŽ₯ Demo Video

waltkthough.mov

Complete walkthrough demonstrating all key features of the ExpenseTracker application

πŸ–ΌοΈ Screenshots

Dashboard Overview & Statistics

Statistics Dashboard

Interactive charts showing spending patterns and category breakdowns

Expense Timeline

Expenses Timeline

Timeline view of all expenses with filtering and categorization

Category Management

Categories Management

Create and manage custom expense categories with colors and budget limits

Add New Expense

Add Expense Dialog

Clean, intuitive expense creation form with category selection

Add New Category

Add Category Dialog

Category creation with icon selection and budget limit setting

User Settings

User Settings

Currency selection and monthly budget configuration

Authentication

Login Page

Secure JWT-based authentication with clean UI

πŸ—οΈ Architecture

Technology Stack

Backend (NestJS)

  • NestJS framework with TypeScript
  • PostgreSQL database with TypeORM
  • JWT authentication with bcrypt
  • REST API with basic OpenAPI/Swagger documentation
  • Comprehensive testing (Unit + E2E)

Frontend (React)

  • React 18 with TypeScript and Vite
  • Tailwind CSS with shadcn/ui components
  • Zustand for state management
  • React Query for server state
  • React Hook Form with Zod validation

Shared Types

  • npm workspaces monorepo
  • Type-safe API communication
  • Consistent data models

πŸš€ Quick Start

Prerequisites

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

Installation

  1. Clone the repository

    git clone <repository-url>
    cd nestjs-vue-demo
  2. Install dependencies

    npm install
  3. Setup database

    # Start PostgreSQL with Docker
    docker-compose up -d postgres
  4. Configure environment

    # Backend environment
    cp backend/.env.example backend/.env
    # Edit backend/.env with your database credentials
    
    # Frontend environment
    cp frontend/.env.example frontend/.env.local
    # Edit frontend/.env.local with your API endpoint (usually http://localhost:3001)
  5. Start development servers

    # Start backend (in one terminal)
    npm run backend:dev
    
    # Start frontend (in another terminal)
    npm run frontend:dev

πŸ§ͺ Testing

# Backend testing
npm run test          # unit tests
npm run test:e2e      # E2E tests (requires Docker and proper .env setup)
npm run test:all      # All backend tests


# Quality checks
npm run lint          # Lint all code
npm run typecheck     # TypeScript type checking
npm run format        # Format code with Prettier

Note: E2E tests require:

  1. Docker running for PostgreSQL
  2. Proper .env file with database credentials in backend folder
  3. Database connection working

🐳 Production Deployment (Docker)

Prerequisites

  • Docker and Docker Compose
  • .env file with production configuration

πŸš€ Quick Production Start

Option 1: Using Scripts (Recommended)

# Make scripts executable (first time only)
chmod +x scripts/*.sh

# Start production environment
./scripts/production-start.sh

Option 2: Using npm scripts

# Start production environment
npm run prod:start

# Stop production environment
npm run prod:stop

# View logs
npm run prod:logs

Option 3: Manual Docker Commands

# Build and start production containers
docker compose -f docker-compose.prod.yml up --build -d

# Stop production containers
docker compose -f docker-compose.prod.yml down

πŸ“‹ Production Environment Setup

  1. Create Production Environment File

    Copy the example environment file and customize:

    cp .env.example .env

    Update .env with your production values

  2. Start Production Services

    The production setup includes:

    • PostgreSQL Database (port 5432)
    • NestJS Backend API (port 3001)
    • React Frontend (port 3002)
  3. Access Your Application

    Development URLs:

πŸ› οΈ Production Management

# Start production environment
./scripts/production-start.sh

# Stop all services
./scripts/production-stop.sh

# Restart services (without rebuild)
./scripts/production-restart.sh

# View logs from all services
./scripts/production-logs.sh

# View logs from specific service
./scripts/production-logs.sh backend
./scripts/production-logs.sh frontend
./scripts/production-logs.sh database

πŸ”§ Production Features

  • Multi-stage Docker builds for optimized image sizes
  • Security hardening with non-root users
  • nginx serving React with proper caching headers
  • Content Security Policy configured for Google Fonts
  • Environment-based configuration
  • Health checks for database readiness
  • Demo data automatically seeded on first run

πŸ“Š Production Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend      β”‚    β”‚    Backend      β”‚    β”‚   Database      β”‚
β”‚   (React)       β”‚    β”‚   (NestJS)      β”‚    β”‚ (PostgreSQL)    β”‚
β”‚   Port: 3002    │◄──►│   Port: 3001    │◄──►│   Port: 5432    β”‚
β”‚   nginx         β”‚    β”‚   Node.js       β”‚    β”‚   postgres:15   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

β”œβ”€β”€ backend/                 # NestJS backend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ auth/           # Authentication module
β”‚   β”‚   β”œβ”€β”€ users/          # User management
β”‚   β”‚   β”œβ”€β”€ categories/     # Expense categories
β”‚   β”‚   β”œβ”€β”€ expenses/       # Expense CRUD operations
β”‚   β”‚   β”œβ”€β”€ statistics/     # Analytics and reporting
β”‚   β”‚   └── database/       # Database configuration
β”‚   └── test/               # E2E tests
β”œβ”€β”€ frontend/               # React frontend application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/          # Route components
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ store/          # Zustand state management
β”‚   β”‚   └── lib/            # Utility functions
β”œβ”€β”€ lib/                    # Shared types and utilities
β”‚   └── types/              # TypeScript type definitions
└── docker-compose.yml      # Docker services configuration

πŸ”§ Development

Available Scripts

# Development
npm run backend:dev          # Start backend in development mode
npm run frontend:dev         # Start frontend in development mode

# Building
npm run backend:build        # Build backend
npm run frontend:build       # Build frontend
npm run lib:build           # Build shared types library

# Testing
npm run test                # Backend unit tests
npm run test:e2e            # Backend E2E tests (with Docker)
npm run test:all            # All backend tests

# Quality
npm run lint                # Lint all code
npm run format              # Format code with Prettier
npm run typecheck           # TypeScript type checking

# Docker
npm run docker:up           # Start development Docker services
npm run docker:down         # Stop Docker services
npm run docker:build        # Build and start Docker services

# Production
npm run prod:start          # Start production environment
npm run prod:stop           # Stop production environment
npm run prod:logs           # View production logs

Key Features

  • Type Safety: End-to-end type safety with shared types
  • Modern UI: Clean, responsive interface with Tailwind CSS
  • Real-time Updates: Optimistic updates for smooth UX
  • Data Persistence: PostgreSQL with proper relationships
  • Authentication: Secure JWT-based authentication
  • Testing: Comprehensive test coverage
  • Documentation: Auto-generated API documentation

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors