Setup Guide
This guide provides detailed instructions for installing, configuring, and deploying Your Finance App. Whether you’re setting up for local development or preparing for production, this guide has you covered.Prerequisites
System Requirements
Node.js
Version 18.0.0 or higher
pnpm
Version 8.0.0 or higher
PostgreSQL
Version 14+ (via Supabase)
Required Tools
- Git - Version control system
- Code Editor - VS Code recommended
- HTTP Client - Postman, Thunder Client, or curl
- Terminal - Command line interface
Operating System Support
- Linux - Ubuntu 20.04+, Debian 11+, or similar
- macOS - 12 (Monterey) or higher
- Windows - Windows 10/11 with WSL2 recommended
Installation
Step 1: Install Node.js
- Ubuntu/Debian
- macOS
- Windows
Install Node.js using NodeSource:
Step 2: Install pnpm
Why pnpm?
- 2-3x faster than npm
- Saves disk space with content-addressable storage
- Built-in monorepo workspace support
- Strict dependency management prevents phantom dependencies
Step 3: Clone the Repository
Database Setup
Creating a Supabase Project
Sign up for Supabase
- Go to supabase.com
- Click “Start your project”
- Sign up with GitHub (recommended) or email
Create a new project
- Click “New Project” from your dashboard
- Fill in the project details:
- Name:
your-finance-app(or your preferred name) - Database Password: Generate a strong password and save it securely
- Region: Choose the closest region to your users
- Pricing Plan: Free (includes 500MB database, 1GB file storage)
- Name:
- Click “Create new project”
- Wait approximately 2 minutes for provisioning
Get connection strings
Once your project is ready:Session Mode (Port 5432) - Use for migrations:
- Navigate to Settings (⚙️ icon) → Database
- Scroll to Connection string section
- Select URI from the mode dropdown
- You’ll see two connection types:
Understanding Connection Modes
- Transaction Mode
- Session Mode
Port: 6543Used for regular application queries through PgBouncer connection pooler.Advantages:
- Connection pooling reduces database load
- Better for high-traffic applications
- Faster connection establishment
- Application runtime queries
- Production environments
- Any SELECT, INSERT, UPDATE, DELETE operations
Environment Configuration
Setting Up Environment Variables
Generate a secure JWT secret
Use Node.js to generate a cryptographically secure random string:Example output:Copy this value and paste it as your
JWT_SECRET.Environment Variables Explained
Connection string for application queries. Uses transaction mode (port 6543) with PgBouncer pooling.
Connection string for migrations. Uses session mode (port 5432) for direct PostgreSQL access.
Secret key used to sign and verify JWT tokens. Must be a long, random string. Never share this or commit it to version control.
How long JWT tokens remain valid. Accepts formats like
7d (days), 24h (hours), 60m (minutes).Installing Dependencies
Install Workspace Dependencies
- Reads
pnpm-workspace.yamlto identify workspaces - Installs dependencies for all workspace packages
- Creates symlinks between local packages
- Downloads and caches external dependencies
- NestJS framework and modules
- Prisma ORM and client
- Authentication libraries (Passport, JWT, bcrypt)
- Validation libraries (class-validator, class-transformer)
- Development tools (ESLint, Prettier, TypeScript)
First installation typically takes 2-5 minutes depending on your internet speed. Subsequent installs are much faster due to pnpm’s caching.
Verify Installation
Database Migrations
Running Migrations
Generate Prisma Client
Generate TypeScript types from your Prisma schema:This creates:
- Type-safe Prisma Client
- TypeScript interfaces for your models
- Auto-completion for queries
Understanding the Schema
The Prisma schema defines three main models:Running the Application
Development Mode
Start the server with hot-reload enabled:- NestJS compiles TypeScript to JavaScript
- Starts the server on port 3000
- Watches for file changes
- Auto-restarts on code modifications
The server is now running at
http://localhost:3000Production Mode
Build and run for production:- Code is optimized and minified
- No file watching or hot reload
- Better performance
- Source maps disabled
Testing the Installation
Test Health Endpoint
Test User Registration
Test Authentication
Test Transaction Creation
Troubleshooting
Common Issues and Solutions
Cannot find module '@nestjs/core'
Cannot find module '@nestjs/core'
Cause: Dependencies not installed or corrupted.Solution:
Environment variable not found: DATABASE_URL
Environment variable not found: DATABASE_URL
Cause:
.env file missing or not in correct location.Solution:connect ECONNREFUSED or timeout
connect ECONNREFUSED or timeout
Cause: Cannot connect to database.Solutions:
- Verify Supabase project is running (check dashboard)
- Confirm connection strings are correct
- Check password doesn’t contain special characters that need escaping
- Ensure no trailing spaces in
.envfile - Try pinging the database host
Error: P1001 - Can't reach database server
Error: P1001 - Can't reach database server
Cause: Network or firewall issue.Solutions:
- Check your internet connection
- Verify firewall isn’t blocking ports 5432/6543
- Try using a different network
- Check if your organization blocks PostgreSQL ports
Port 3000 is already in use
Port 3000 is already in use
Cause: Another process is using port 3000.Solutions:Find and kill the process:Or change the port in
apps/backend/src/main.ts:Prisma Client not generated
Prisma Client not generated
Cause: Prisma Client wasn’t generated after schema changes.Solution:
Migration failed: Table already exists
Migration failed: Table already exists
Cause: Database state doesn’t match migration history.Solution:
Getting More Help
Check Logs
Review server logs for detailed error messages
Prisma Studio
Use
npx prisma studio to inspect databaseGitHub Issues
Search or open issues on GitHub repository
Documentation
Review NestJS and Prisma official docs
Development Tools
Recommended VS Code Extensions
Useful Commands
Next Steps
Now that you have Your Finance App set up and running:Explore the Architecture
Understand the modular structure
Learn the Database Schema
Deep dive into data models
Study Authentication
Learn how JWT auth works
API Reference
Explore all endpoints
Pro Tip: Keep your
.env file secure and never commit it to version control. Use environment-specific .env files for different deployment environments.