Skip to main content

Installation Guide

This guide covers detailed installation instructions for PC Fix, including manual setup without Docker, all dependencies, database configuration, and deployment options.
For a quick Docker-based setup, see the Quick Start Guide. This guide is for developers who need manual installation or want to understand the complete setup process.

Prerequisites

Required Software

Node.js 20+

Download from nodejs.orgVerify installation:
node --version  # Should be 20.x or higher
npm --version   # Should be 10.x or higher

PostgreSQL 15+

Download from postgresql.orgVerify installation:
psql --version  # Should be 15.x or higher

Git

Download from git-scm.comVerify installation:
git --version

Docker (Optional)

Download from docker.comOnly required for containerized deployment

System Requirements

  • OS: Linux, macOS, or Windows with WSL2
  • RAM: Minimum 4GB, recommended 8GB+
  • Disk Space: 2GB for dependencies and builds
  • Ports Available: 3001 (API), 4321 (Web), 5432 (PostgreSQL)

Installation Methods

Database Configuration

Prisma Schema Overview

PC Fix uses Prisma ORM with PostgreSQL. The schema includes:
  • User: User accounts with role-based access
  • RefreshToken: JWT refresh token management
  • Cliente: Extended customer profiles with addresses
  • Localidad & Provincia: Location data for Argentina
  • Producto: Product catalog with inventory tracking
  • Categoria: Product categories (hierarchical)
  • Marca: Brand management
  • ImagenProducto: Multiple images per product
  • Favorite: User wishlists
  • Cart & CartItem: Shopping cart management
  • Venta: Orders and sales
  • ItemVenta: Order line items
  • Pago: Payment tracking with multiple methods
  • ConsultaTecnica: Technical consultation requests
  • Servicio: Service offerings
  • ServicioPersonalizado: Custom service pricing
  • Banner: Homepage banners and promotions
  • Settings: Site configuration

Common Prisma Commands

# Generate Prisma Client (after schema changes)
npx prisma generate

# Create a new migration
npx prisma migrate dev --name your_migration_name

# Apply migrations to production
npx prisma migrate deploy

# Push schema changes without migrations (dev only)
npx prisma db push

# Open Prisma Studio (database GUI)
npx prisma studio

# Reset database (WARNING: deletes all data)
npx prisma migrate reset

# Seed database
npx prisma db seed

External Services Configuration

Cloudinary (Image CDN)

1

Create Account

Sign up at cloudinary.com
2

Get Credentials

Find your credentials in Dashboard → Account Details:
  • Cloud Name
  • API Key
  • API Secret
3

Add to .env

CLOUDINARY_CLOUD_NAME="your-cloud-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"

MercadoPago (Payment Gateway)

1

Create Account

Sign up at mercadopago.com
2

Get API Credentials

Navigate to Developers → Credentials:
  • Access Token (for backend)
  • Public Key (for frontend)
3

Add to .env

# Backend (.env)
MERCADOPAGO_ACCESS_TOKEN="your-access-token"

Google OAuth

1

Create Project

2

Enable OAuth

APIs & Services → Credentials → Create OAuth Client ID
  • Application type: Web application
  • Authorized redirect URIs: http://localhost:3001/api/auth/google/callback
3

Add Credentials

# Backend
GOOGLE_CLIENT_ID="your-client-id"
GOOGLE_CLIENT_SECRET="your-client-secret"

# Frontend
PUBLIC_GOOGLE_CLIENT_ID="your-client-id"

Resend (Email Service)

1

Create Account

Sign up at resend.com
2

Generate API Key

Dashboard → API Keys → Create API Key
3

Verify Domain (Production)

Add your domain for production email sending
4

Add to .env

RESEND_API_KEY="re_your_api_key"
FROM_EMAIL="[email protected]"

Sentry (Error Monitoring)

1

Create Project

Sign up at sentry.io and create a project
2

Get DSN

Project Settings → Client Keys (DSN)
3

Add to Both .env Files

# Backend
SENTRY_DSN="your-backend-dsn"

# Frontend
PUBLIC_SENTRY_DSN="your-frontend-dsn"

NPM Scripts Reference

Root Level Commands

# Run web development server
npm run dev

# Run tests across all packages
npm run test

API Package (packages/api)

# Development
npm run dev              # Start with nodemon (hot reload)
npm run build            # Build TypeScript to dist/
npm start                # Run production build

# Database
npm run db:push          # Push schema changes (dev)
npm run db:studio        # Open Prisma Studio
npx prisma migrate dev   # Create migration
npx prisma migrate deploy # Apply migrations

# Testing
npm test                 # Run Vitest unit tests
npm run test:watch       # Run tests in watch mode
npm run test:coverage    # Generate coverage report

Web Package (packages/web)

# Development
npm run dev              # Start Astro dev server
npm run build            # Build for production
npm run preview          # Preview production build

# Testing
npm test                 # Run Vitest unit tests
npm run e2e              # Run Playwright E2E tests
npm run test:coverage    # Generate coverage report

# Type Checking
npm run astro check      # Check Astro files

Troubleshooting

Error: Error: P1001: Can't reach database serverSolutions:
  1. Verify PostgreSQL is running:
    # macOS
    brew services list
    
    # Linux
    sudo systemctl status postgresql
    
    # Windows
    services.msc (look for PostgreSQL)
    
  2. Check DATABASE_URL format:
    postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public
    
  3. Test connection directly:
    psql -U pcfix_user -d pcfix_db -h localhost
    
Error: Cannot find module '@prisma/client'Solution:
cd packages/api
npx prisma generate
After schema changes, always regenerate the client.
Error: Port 3001 (or 4321) is already in useSolutions:
  1. Find and kill the process:
    # macOS/Linux
    lsof -ti:3001 | xargs kill -9
    
    # Windows
    netstat -ano | findstr :3001
    taskkill /PID <PID> /F
    
  2. Change port in .env:
    # API
    PORT=3002
    
    # Web (in astro.config.mjs)
    server: { port: 4322 }
    
Error: Various “Cannot find module” errorsSolution:
# Clear and reinstall dependencies
rm -rf node_modules package-lock.json
rm -rf packages/*/node_modules
npm install
Error: Access to fetch has been blocked by CORS policySolution: Ensure API .env has correct CORS_ORIGIN:
CORS_ORIGIN="http://localhost:4321"
For multiple origins:
CORS_ORIGIN="http://localhost:4321,http://localhost:3000"
Error: JsonWebTokenError: invalid signatureSolutions:
  1. Ensure JWT secrets are set in .env
  2. Clear browser cookies and local storage
  3. Restart the API server after changing JWT secrets
Solution:
cd packages/api  # or packages/web
npx tsc --noEmit  # Check for type errors
Common fixes:
  • Update @types/* packages
  • Check tsconfig.json settings
  • Regenerate Prisma client

Production Deployment

Environment Preparation

1

Update Environment Variables

  • Change all secrets (JWT, database passwords)
  • Update CORS_ORIGIN to production domain
  • Configure production database URL
  • Set NODE_ENV=production
2

Build Applications

# API
cd packages/api
npm run build

# Web
cd packages/web
npm run build
3

Run Database Migrations

cd packages/api
npx prisma migrate deploy

Deployment Options

Vercel (Frontend)

Best for: Astro frontend deployment
  1. Connect GitHub repository
  2. Set root directory: packages/web
  3. Add environment variables
  4. Deploy automatically on push

Railway (Backend + DB)

Best for: Express API and PostgreSQL
  1. Create new project
  2. Add PostgreSQL database
  3. Deploy API from GitHub
  4. Configure environment variables

Docker Production

Best for: Self-hosted deployments
docker-compose -f docker-compose.yml \
  -f docker-compose.prod.yml up -d

VPS (DigitalOcean, AWS)

Best for: Full control deployments
  1. Set up Node.js 20+
  2. Install PostgreSQL
  3. Clone repository
  4. Configure PM2 or systemd
  5. Set up Nginx reverse proxy

Testing

Run Tests

# Unit tests (API)
cd packages/api
npm test

# Unit tests (Web)
cd packages/web
npm test

# E2E tests (Web)
cd packages/web
npm run e2e

# Coverage reports
npm run test:coverage

Test Configuration

  • Vitest: Unit testing for both packages
  • Playwright: E2E testing for critical user flows
  • Supertest: API endpoint testing

Next Steps

Explore the Codebase

  • API structure: packages/api/src/modules/
  • Frontend components: packages/web/src/components/
  • Database schema: packages/api/prisma/schema.prisma

Configure Admin Account

Create admin user via Prisma Studio or seed script to access admin dashboard

Customize Branding

  • Update logo: packages/web/public/logo.png
  • Modify colors: packages/web/tailwind.config.mjs
  • Edit site metadata: packages/web/src/layouts/Layout.astro

Set Up External Services

Configure Cloudinary, MercadoPago, and email services for full functionality

Build docs developers (and LLMs) love