Full Environment Setup Guide
Complete guide for setting up and running the Payroll Pipeline SaaS application locally on Windows.Prerequisites
Required Software
-
Node.js + npm
- Version: Node.js 18.x or later
- Download: https://nodejs.org/
- Verify:
node -vandnpm -v
-
Python
- Version: Python 3.8 or later
- Download: https://www.python.org/downloads/
- Verify:
python --version - Ensure Python is added to PATH during installation
-
Google Cloud SDK (gcloud)
- Optional but recommended for GCP operations
- Download: https://cloud.google.com/sdk/docs/install
Service Account Credentials
- Option 1: Place
credentials.jsonin the project root directory - Option 2: Use Application Default Credentials (ADC)
- Run:
gcloud auth application-default login - Credentials will be stored in your user profile
- Run:
One-Time Setup
1. Place Credentials File (if using service account JSON)
Place your Google Cloud service account JSON file in the project root:credentials.json file is typically gitignored for security. If you don’t have one, the backend will attempt to use Application Default Credentials.
2. Environment Variables
The scripts will automatically set required environment variables, but you can override them:- GCP_PROJECT_ID: Defaults to
payroll-bi-gauntletif not set - GOOGLE_APPLICATION_CREDENTIALS: Set automatically if
credentials.jsonexists in project root - GCP_REGION: Defaults to
us-central1(for Vertex AI) - VERTEX_MODEL: Optional (code handles defaults)
.env file in the project root or set them in your PowerShell session before running scripts.
Commands
Bootstrap Virtual Environment
First-time setup - Creates Python virtual environment and installs dependencies:- Creates
./venvdirectory if it doesn’t exist - Activates virtual environment
- Upgrades pip
- Installs dependencies from
requirements-api.txt - Validates imports (fastapi, uvicorn, google.cloud.bigquery, vertexai)
Start Backend
Option 1: Using .bat file (recommended)- Checks for virtual environment (prompts to bootstrap if missing)
- Activates virtual environment
- Sets environment variables:
BACKEND_ENV=localGCP_PROJECT_ID=payroll-bi-gauntlet(if not set)GOOGLE_APPLICATION_CREDENTIALS(ifcredentials.jsonexists)GCP_REGION=us-central1(if not set)
- Starts FastAPI/uvicorn server on
http://localhost:8000
- API: http://localhost:8000
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/api/health
Start Frontend
Option 1: Using .bat file (recommended)- Changes to
./dashboarddirectory - Runs
npm installifnode_modulesdoesn’t exist - Starts Next.js dev server on
http://localhost:3000
- Dashboard: http://localhost:3000
- Login: Use test credentials (see below)
Start Full Stack (Both Services)
Option 1: Using .bat file (recommended)- Bootstraps venv if missing
- Starts backend in a new PowerShell window
- Starts frontend in another new PowerShell window
- Polls health endpoints to verify services are running
- Prints status summary
Run Diagnostics
Generate a diagnostic report of your environment:- Checks Python and Node versions
- Verifies virtual environment
- Lists environment variables
- Validates credentials file
- Tests Python package imports
- Checks backend health endpoint
- Writes report to
./diagnostics/diagnostic-report.md
- Troubleshooting setup issues
- Verifying environment configuration
- Before reporting bugs
Test Users
After starting the backend, you can use these test credentials:| Password | Role | |
|---|---|---|
aaronbundy681@gmail.com | admin123 | CEO/Admin |
aaronbundy@test.com | admin123 | Admin |
test@example.com | admin123 | Agent |
Troubleshooting
Backend Not Starting
Error:venv not found
- Solution: Run
.\scripts\bootstrap-venv.ps1first
ModuleNotFoundError: No module named 'fastapi'
- Solution:
- Activate venv:
.\venv\Scripts\activate.ps1 - Install dependencies:
pip install -r requirements-api.txt
- Activate venv:
BigQuery client not available
- Solution:
- Verify
GCP_PROJECT_IDis set (defaults topayroll-bi-gauntlet) - Ensure
credentials.jsonexists OR rungcloud auth application-default login - Check that service account has BigQuery permissions
- Verify
- Solution:
Failed to activate virtual environment
- Solution:
- Check PowerShell execution policy:
Get-ExecutionPolicy - If Restricted, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser - Or use the
.batfiles which bypass execution policy
- Check PowerShell execution policy:
Frontend Not Starting
Error:npm: command not found
- Solution:
- Verify Node.js is installed:
node -v - Restart terminal after installing Node.js
- Verify npm is in PATH:
npm -v
- Verify Node.js is installed:
Port 3000 already in use
- Solution:
npm install fails
- Solution:
- Clear npm cache:
npm cache clean --force - Delete
node_modulesandpackage-lock.json - Run
npm installagain
- Clear npm cache:
- Solution:
- Check Node.js version (should be 18.x or later)
- Run
npm run buildto see detailed errors - Check
dashboard/tsconfig.jsonconfiguration
Vertex AI / BigQuery Permission Issues
Error:403 Forbidden or Permission denied
- Solution:
- Verify service account has required permissions:
- BigQuery Data Viewer
- BigQuery Job User
- Vertex AI User (if using AI features)
- Check that
GCP_PROJECT_IDmatches your project - Verify credentials file is valid JSON
- Verify service account has required permissions:
Vertex AI initialization failed
- Solution:
- Check
GCP_REGIONis set (defaults tous-central1) - Verify project has Vertex AI API enabled
- Check service account has Vertex AI permissions
- Check
Project not found
- Solution:
- Verify
GCP_PROJECT_ID=payroll-bi-gauntlet(or your actual project ID) - Check that project exists in GCP Console
- Verify you have access to the project
- Verify
Environment Variable Issues
Issue: Backend uses wrong project ID- Solution: Set
GCP_PROJECT_IDbefore starting:
- Solution:
- Place
credentials.jsonin project root, OR - Run
gcloud auth application-default login
- Place
Quick Reference
| Task | Command |
|---|---|
| Bootstrap venv | .\scripts\bootstrap-venv.ps1 |
| Start backend | .\start-backend.bat |
| Start frontend | .\start-frontend.bat |
| Start both | .\start-full-stack.bat |
| Run diagnostics | .\scripts\diagnose-backend.ps1 |
| Seed test users | python scripts/seed_user.py |
File Structure
Additional Resources
- API Documentation: http://localhost:8000/docs (when backend is running)
- Makefile Commands: See
Makefilefor additional development commands - Local Development Guide: See
LOCAL_DEVELOPMENT_GUIDE.md
Last Updated: 2025-12-21