3.8 KiB
3.8 KiB
Setup Instructions
Prerequisites
- Node.js 18+ - Download
- pnpm 8+ - Install with:
npm install -g pnpm - PostgreSQL 14+ - Either:
- Install locally: PostgreSQL Downloads
- Use Docker:
docker-compose up -d postgres
- Redis - Either:
- Install locally: Redis Downloads
- Use Docker:
docker-compose up -d redis
Quick Start
Option 1: Using Docker (Recommended)
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:
-
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 -
Install and start Redis:
# Ubuntu/Debian sudo apt-get install redis-server sudo systemctl start redis-server -
Configure environment:
cp .env.example .env # Edit .env with your database credentials -
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 stringREDIS_URL- Redis connection stringJWT_SECRET- Secret for JWT tokens (generate a strong random string)JWT_REFRESH_SECRET- Secret for refresh tokensFRONTEND_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
- Backend: http://localhost:3001
- Frontend: http://localhost:3000
- API Docs: http://localhost:3001/api-docs
Start Separately
# Backend only
pnpm dev:backend
# Frontend only
pnpm dev:frontend
Troubleshooting
Database Connection Issues
-
Verify PostgreSQL is running:
sudo systemctl status postgresql # or docker-compose ps -
Test connection:
psql -h localhost -U aseret_user -d aseret_bank -
Check DATABASE_URL in
.envmatches your setup
Redis Connection Issues
-
Verify Redis is running:
redis-cli ping # Should return: PONG -
Check REDIS_URL in
.env
Port Already in Use
If ports 3000 or 3001 are already in use:
-
Find the process:
lsof -i :3001 -
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