Get up and running with Zava Gift Exchange locally in minutes. This guide covers everything you need to develop, test, and debug the application on your machine.
- Prerequisites
- Quick Start (5 minutes)
- Development Workflow
- Debugging
- Database Management
- Testing
- Troubleshooting
- Advanced Topics
Before you start, ensure you have the following installed on your machine (Windows, macOS, or Linux):
-
Node.js 20+ - Download
- Verify:
node --version
- Verify:
-
Docker & Docker Compose - Download
- Verify:
docker --versionanddocker-compose --version - Windows: Docker Desktop for Windows
- macOS: Docker Desktop for Mac
- Linux: Install Docker Engine + Docker Compose separately
- Verify:
-
Git - Download
- Verify:
git --version
- Verify:
-
VS Code - Download
- Install the Azure Functions extension (ms-azuretools.vscode-azurefunctions)
- Azure Storage Explorer - For managing local Cosmos DB
- Azure Cosmos DB VS Code extension - For database browsing
- Postman/Insomnia - For API testing
git clone https://github.com/dsanchezcr/zavaexchangegift.git
cd zavaexchangegiftdocker-compose up -dVerify containers are running:
docker-compose psExpected output:
NAME STATUS PORTS
cosmosdb-emulator Up (healthy) 8081/tcp
azurite-emulator Up (healthy) 10000-10002/tcp
code .In VS Code:
- Press
F5(or Ctrl+Shift+D, then click the play button) - Select "🚀 Full Stack (Frontend + API + Emulators)"
- Press Enter or click the green play button
✅ What happens automatically:
- Frontend dev server starts on
http://localhost:5173 - API runs on
http://localhost:7071 - Cosmos DB Emulator runs on
https://localhost:8081 - Debugger attaches to both frontend and API
- Browser opens automatically
Open your browser to http://localhost:5173 and start coding!
Changes to your code automatically hot-reload. Add breakpoints in VS Code to debug any issues.
When you clone the repo and run the app, the local database configuration is set up automatically:
-
First-time setup - When you run
npm installin theapi/folder:local.settings.jsonis automatically created fromlocal.settings.json.example- Configured to use the local Cosmos DB emulator
- No manual steps needed!
-
In GitHub Codespaces - The
.devcontainerconfiguration handles this automatically -
CI/CD & Production - Azure Static Web Apps provides its own app settings with real credentials
If you need to manually create the local settings file:
npm run setupThis copies the example template and shows you what was configured.
The local.settings.json file automatically includes:
- COSMOS_ENDPOINT:
https://localhost:8081(emulator) - COSMOS_KEY: Default emulator key (safe, public key)
- COSMOS_DATABASE_NAME:
zavaexchangegift - COSMOS_CONTAINER_NAME:
games - APP_BASE_URL:
http://localhost:5173 - ENVIRONMENT:
local
.gitignore):
- The example file (
local.settings.json.example) IS committed - Your local file stays private
- Production credentials are managed by Azure, not this file
- Safe to commit the example to open-source repos
When you press F5, VS Code automatically:
- Starts Docker containers (Cosmos DB + Azurite) - if not already running
- Installs dependencies (npm modules) - if needed
- Starts the Frontend - Vite dev server with hot reload
- Starts the API - Azure Functions with hot reload
- Attaches debuggers - For both frontend and API
- Opens your browser - To http://localhost:5173
Changes to your code automatically hot-reload:
- Edit
src/files → Browser refreshes automatically - Edit
api/src/files → API restarts automatically - No need to manually restart anything!
Add breakpoints anywhere in your code:
- Click the line number to add a red dot
- Trigger the code (refresh page or call API)
- Execution pauses at the breakpoint
- Use Debug panel to step through code
- Frontend logs: Browser DevTools (F12 → Console)
- API logs: VS Code Debug Console (Ctrl+Shift+Y)
- API requests: Network tab in DevTools
Local development automatically uses api/local.settings.json:
- Cosmos DB points to emulator (
https://localhost:8081) - Email is disabled
- App base URL is
http://localhost:5173
Automatic Setup: The first time you run npm install in the api/ folder, local.settings.json is automatically created from local.settings.json.example. No manual configuration needed!
If you need to recreate it, run:
npm run setupNo configuration needed for basic development!
- Click any line number in VS Code to add a red breakpoint dot
- Trigger the code (refresh page, click button, or call API)
- Execution pauses at your breakpoint
- Step through code using the Debug toolbar:
- Step Over (F10) - Execute next line
- Step Into (F11) - Enter function calls
- Step Out (Shift+F11) - Exit current function
- Continue (F5) - Resume execution
In the Debug panel (Ctrl+Shift+D):
- Variables tab - See local variables and their values
- Watch tab - Monitor specific expressions
- Call Stack - See which functions called which
- Frontend Console: Press F12 in browser → Console tab
- API Logs: VS Code Debug Console (Ctrl+Shift+Y)
- Network Requests: Browser DevTools → Network tab
"API returns 404"
- Check Azure Functions are running in VS Code Terminal
- Verify route name in
api/src/functions/yourFunction.ts - Check CORS in
api/local.settings.json
"Cosmos DB connection error"
- Run
docker-compose psto verify containers are running - Cosmos DB should show "healthy" status
- If stuck, restart:
docker-compose restart cosmos-db
"Frontend can't find API"
- Check base URL in
src/lib/api.ts- should behttp://localhost:7071 - Check browser Network tab for failed API requests
- Verify API is actually running (check VS Code Debug Console)
"Changes aren't showing up"
- Hard refresh browser:
Ctrl+Shift+R(Windows/Linux) orCmd+Shift+R(macOS) - Check VS Code terminal for build errors
- Restart debugging: Shift+F5 then F5
The local Cosmos DB Emulator is automatically set up and data persists in Docker volume cosmos-db-data.
Option 1: Azure Storage Explorer (GUI)
- Install Azure Storage Explorer
- Connect to local Cosmos DB:
- Click "Connect" → "Cosmos DB Emulator"
- Port:
8081
- Browse databases and containers
Option 2: VS Code Extension
- Install Azure Cosmos DB extension
- Click Cosmos icon in sidebar
- "Attach Database Account" → select emulator
- Browse collections
Option 3: REST API
# Query games collection
curl -X GET "https://localhost:8081/dbs/zavaexchangegift/colls/games/docs" \
-H "Authorization: type%3Dmaster%26ver%3D1.0%26sig%3D..." \
-H "x-ms-version: 2018-12-31" \
-k # Ignore SSL for emulatorTo start fresh (delete all data):
# Stop and remove volume
docker-compose down -v
# Restart (creates fresh database)
docker-compose up -d cosmos-dbRun Jest tests for Azure Functions:
# Run all tests
cd api && npm test
# Run specific test file
npm test cosmosdb.test.ts
# Run with coverage
npm test -- --coverage
# Run in watch mode
npm test -- --watchTests automatically use local Cosmos DB via local.settings.json.
Run Playwright tests against local app:
# First, ensure app is running (local server)
npm run test:e2e
# Run with UI mode (recommended for debugging)
npm run test:e2e:ui
# Run specific test file
npx playwright test e2e/app.spec.ts
# View last test report
npm run test:e2e:reportNote: Make sure Vite dev server is running (http://localhost:5173) before running E2E tests.
- Create a game (fill form, submit)
- Join a game with participant code
- View gift assignment
- View organizer panel
- Test language toggle (all 9 languages)
- Test on mobile (DevTools)
- Dark mode toggle
- Test protected game error with token entry
- Test invalid token error with token entry
- Test manual token entry flow (enter game code, then token separately)
Error: docker-compose: command not found
Solution (All Platforms):
# Docker Desktop (Windows/macOS) should auto-install
# Verify installation:
docker-compose --version
# Linux users: may need separate install
# https://docs.docker.com/compose/install/Error: Error: listen EADDRINUSE: address already in use :::8081
Solution:
Windows:
netstat -ano | findstr :8081
taskkill /PID <PID> /FmacOS/Linux:
lsof -i :8081
kill -9 <PID>Or simply use a different port in docker-compose.yml
Error: Error: ECONNREFUSED 127.0.0.1:8081
Solution (All Platforms):
# Check container is running
docker-compose ps
# If not, start it
docker-compose up -d cosmos-db
# Wait 30-60 seconds for emulator to initialize
# Check logs
docker-compose logs cosmos-dbError: npm ERR! peer dep missing: ...
Solution (All Platforms):
# Clean install
rm -rf node_modules package-lock.json
npm install
# For API
cd api && rm -rf node_modules package-lock.json
npm installCauses & Solutions:
-
Vite not running
- Check VS Code Terminal for errors
- Restart debug session: Shift+F5 then F5
-
API not responding
- Check Azure Functions Host is running
- Look at VS Code Debug Console (Ctrl+Shift+Y)
-
CORS error
- Check browser console (F12)
- Verify CORS in
api/local.settings.json
-
Cache issue
- Hard refresh: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (macOS)
- Clear browser cache
Causes & Solutions:
-
App not running
npm run dev # In separate terminal -
Tests timing out
- Increase timeout in
playwright.config.ts - Check if API is responding
- Increase timeout in
-
Selector not found
- App structure may have changed
- Update selectors in test file
### "Cosmos DB not responding"
**Error:** `Error: ECONNREFUSED 127.0.0.1:8081`
**Solution:**
```bash
# Check container is running
docker-compose ps
# If not, start it
docker-compose up -d cosmos-db
# Wait 30-60 seconds for emulator to initialize
# Check logs
docker-compose logs cosmos-db
Error: npm ERR! peer dep missing: ...
Solution:
# Clean install
rm -rf node_modules package-lock.json
npm install
# For API
cd api && rm -rf node_modules package-lock.json
npm installCauses & Solutions:
-
Vite not running
- Check VS Code Terminal
- Restart debug session
-
API not responding
- Check Functions host is running
- Look at VS Code Debug Console
-
CORS error
- Check browser console (F12)
- Verify CORS in
api/local.settings.json
-
Cache issue
- Hard refresh: Ctrl+Shift+R (or Cmd+Shift+R)
- Clear browser cache
Causes & Solutions:
-
App not running
npm run dev # In separate terminal -
Tests timing out
- Increase timeout in
playwright.config.ts - Check if API is responding
- Increase timeout in
-
Selector not found
- App structure may have changed
- Update selectors in test file
View detailed logs from any container:
# Cosmos DB logs
docker-compose logs -f cosmos-db
# Azurite logs
docker-compose logs -f azurite
# Follow all logs
docker-compose logs -fTo enable email notifications locally:
- Get Azure Communication Services connection string from production
- Add to
api/local.settings.json:{ "ACS_CONNECTION_STRING": "endpoint=https://...", "ACS_SENDER_ADDRESS": "noreply@...", "ACS_DISABLED": "false" } - Restart debugger
Enable local telemetry:
- Create Application Insights in Azure Portal
- Get connection string
- Add to
api/local.settings.json:{ "APPLICATIONINSIGHTS_CONNECTION_STRING": "InstrumentationKey=..." } - Restart debugger
- Issue? Check GitHub Issues
- Question? Create a Discussion
- Want to contribute? See CONTRIBUTING.md
- 📖 Read development.md for navigation guide
- 🚀 Learn github-deployment.md for CI/CD setup
- 🧪 Explore quick-reference.md for command reference