Skip to main content
PC Fix requires several environment variables and external service integrations to function properly. This guide covers all configuration needed for both the frontend and backend.

Overview

The PC Fix monorepo has two main packages that require separate environment configuration:
  • packages/api: Backend API with database, authentication, and integrations
  • packages/web: Frontend application with Astro and React
Never commit .env files to version control. Add them to .gitignore and use .env.example as a template.

Backend Environment Variables

Create packages/api/.env with the following configuration:

Database Configuration

.env
The DATABASE_URL follows this format:
  • USER: Database username (default: admin)
  • PASSWORD: Database password (default: password123)
  • HOST: Database host (localhost for local, postgres for Docker)
  • PORT: Database port (default: 5432)
  • DATABASE: Database name (default: pcfix_db)

Authentication & Security

.env
1

Generate JWT Secrets

Generate secure random strings for JWT secrets:
2

Configure Google OAuth

  1. Go to Google Cloud Console
  2. Create a new project or select existing
  3. Enable Google+ API
  4. Create OAuth 2.0 credentials
  5. Add authorized redirect URIs
  6. Copy the Client ID to your .env

External Services

.env

Server Configuration

.env

Frontend Environment Variables

Create packages/web/.env with the following configuration:

API Connection

.env
In Docker environments, use SSR_API_URL="http://api:3002/api" to leverage Docker’s internal networking.

Google OAuth (Frontend)

.env

Sentry (Frontend)

.env

External Services Setup

  1. Sign up at cloudinary.com
  2. Navigate to Dashboard
  3. Copy Cloud Name, API Key, and API Secret
  4. Add credentials to packages/api/.env
Used for:
  • Product image uploads
  • Payment receipt uploads
  • CDN delivery
  1. Create account at mercadopago.com
  2. Go to Your integrations
  3. Create a new application
  4. Copy the Access Token (use Test credentials for development)
  5. Configure webhook URL: https://your-api-url.com/api/sales/mp-webhook
Test cards for development:
  • Approved: 4509 9535 6623 3704 (any future date, any CVV)
  • Rejected: 4017 1410 1414 1234
  1. Sign up at resend.com
  2. Verify your domain or use their test domain
  3. Generate an API key
  4. Add to packages/api/.env
Emails sent:
  • Order confirmations
  • Payment receipts
  • Password reset links
  • Abandoned cart reminders
  • Stock alerts
  1. Sign up at sentry.io
  2. Create two projects:
    • PC Fix API (Node.js)
    • PC Fix Web (Astro/Browser)
  3. Copy both DSN values
  4. Add to respective .env files
Monitoring:
  • Backend: Server errors, unhandled exceptions
  • Frontend: JavaScript errors, failed requests

Environment Templates

Create .env.example files in both packages for team reference:
packages/api/.env.example

Validation

Verify your configuration is correct:
1

Test Database Connection

Should open Prisma Studio at http://localhost:5555
2

Test API Server

Visit http://localhost:3002/health - should return JSON with {"success": true}
3

Test Frontend

Visit http://localhost:4321 - should load the home page

Troubleshooting

  • Verify PostgreSQL is running: pg_isready
  • Check DATABASE_URL format and credentials
  • Ensure database pcfix_db exists
  • For Docker: use host postgres instead of localhost
  • Ensure JWT_SECRET is set and not empty
  • Regenerate secrets if you suspect compromise
  • Check token expiration times are valid
  • Verify FRONTEND_URL matches your frontend’s actual URL
  • Include protocol (http:// or https://)
  • For Docker, add both localhost and container URLs to whitelist
  • Test API keys in service dashboards first
  • Check for typos in credentials
  • Verify services are not rate-limited
  • Check service status pages for outages

Next Steps

Docker Deployment

Deploy PC Fix with Docker Compose

Database Migrations

Manage database schema changes

Testing

Run unit and E2E tests

Integrations

Configure payment providers