Files
Aseret_Bank/SETUP.md
2026-02-09 21:51:31 -08:00

3.8 KiB

Setup Instructions

Prerequisites

  1. Node.js 18+ - Download
  2. pnpm 8+ - Install with: npm install -g pnpm
  3. PostgreSQL 14+ - Either:
  4. Redis - Either:

Quick Start

If you have Docker and Docker Compose installed:

# 1. Start all services (PostgreSQL + Redis)
docker-compose up -d

# 2. Install dependencies
pnpm install

# 3. Generate Prisma client
pnpm db:generate

# 4. Run database migrations
pnpm db:migrate

# 5. (Optional) Seed the database
pnpm db:seed

# 6. Start development servers
pnpm dev

Option 2: Local Services

If you prefer to run PostgreSQL and Redis locally:

  1. Install and start PostgreSQL:

    # Ubuntu/Debian
    sudo apt-get install postgresql postgresql-contrib
    sudo systemctl start postgresql
    
    # Create database
    sudo -u postgres psql
    CREATE DATABASE aseret_bank;
    CREATE USER aseret_user WITH PASSWORD 'aseret_password';
    GRANT ALL PRIVILEGES ON DATABASE aseret_bank TO aseret_user;
    \q
    
  2. Install and start Redis:

    # Ubuntu/Debian
    sudo apt-get install redis-server
    sudo systemctl start redis-server
    
  3. Configure environment:

    cp .env.example .env
    # Edit .env with your database credentials
    
  4. Install dependencies and setup:

    pnpm install
    pnpm db:generate
    pnpm db:migrate
    pnpm db:seed
    pnpm dev
    

Environment Variables

Copy .env.example to .env and configure:

cp .env.example .env

Key variables to set:

  • DATABASE_URL - PostgreSQL connection string
  • REDIS_URL - Redis connection string
  • JWT_SECRET - Secret for JWT tokens (generate a strong random string)
  • JWT_REFRESH_SECRET - Secret for refresh tokens
  • FRONTEND_URL - Frontend URL (default: http://localhost:3000)
  • PORT - Backend port (default: 3001)

Database Setup

Initial Migration

pnpm db:migrate

This will:

  • Create all database tables
  • Set up relationships
  • Create indexes

Seed Data

pnpm db:seed

This creates:

  • Admin user: admin@aseret.com / admin123
  • Loan Officer: officer@aseret.com / officer123
  • Sample Customer: customer@example.com / customer123

Prisma Studio

View and edit database data:

pnpm db:studio

Opens at: http://localhost:5555

Development

Start Both Servers

pnpm dev

Start Separately

# Backend only
pnpm dev:backend

# Frontend only
pnpm dev:frontend

Troubleshooting

Database Connection Issues

  1. Verify PostgreSQL is running:

    sudo systemctl status postgresql
    # or
    docker-compose ps
    
  2. Test connection:

    psql -h localhost -U aseret_user -d aseret_bank
    
  3. Check DATABASE_URL in .env matches your setup

Redis Connection Issues

  1. Verify Redis is running:

    redis-cli ping
    # Should return: PONG
    
  2. Check REDIS_URL in .env

Port Already in Use

If ports 3000 or 3001 are already in use:

  1. Find the process:

    lsof -i :3001
    
  2. Kill the process or change PORT in .env

Prisma Client Not Generated

cd backend
pnpm prisma:generate

Production Build

# Build
pnpm build

# Start
pnpm start

Additional Resources