Skip to content

dsanchezcr/SecretSanta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎁 Secret Santa

Secret Santa gift exchange web application built with React + Vite, Azure Functions, and Azure Cosmos DB.

CI/CD Open in GitHub Codespaces

✨ Features

  • 🌍 Multilingual: Full support for 9 languages - English, Spanish, Portuguese, Italian, French, Japanese, Chinese, German, and Dutch
  • 🎲 Random Assignments: Fair circular shuffle algorithm
  • πŸ”’ Protected Games: Optional participant tokens for privacy
  • πŸ“§ Email Notifications: Optional Azure Communication Services integration with 13+ notification types
  • πŸ”„ Reassignment Requests: Participants can request new assignments
  • πŸ‘€ Organizer Panel: Full game management for organizers
  • πŸ—‘οΈ Game Deletion: Organizers can permanently delete games
  • πŸ“… Date Validation: Games can only be created for today or future dates
  • 🧹 Auto-Cleanup: Games automatically deleted 3 days after the event
  • πŸ” Privacy Policy: Clear data handling and retention information
  • πŸ“± Responsive Design: Works on all devices
  • πŸ“Š Application Insights: Built-in monitoring and error tracking

πŸ—οΈ Environment Strategy

Environment Resource Group Static Web App Cosmos DB Lifecycle
PR Preview secretsanta-pr-{number} Free Serverless Created on PR open, deleted on close
QA secretsanta-qa Free Free Tier Persistent (isolated from prod)
Production secretsanta Standard Serverless Persistent (unlimited scaling)

Each environment has its own Static Web App and own Cosmos DB (QA is completely isolated). All environments are automatically configured with:

  • Cosmos DB connection
  • Application Insights
  • Azure Communication Services (QA/prod)

οΏ½ Prerequisites

Before you begin, ensure you have the following installed on your system (macOS, Windows, or Linux):

Required

  • Node.js 20+ - Download

    • Verify: node --version (should be v20 or higher)
  • Docker & Docker Compose - Download

    • Verify: docker --version and docker-compose --version
    • Windows Users: Docker Desktop for Windows recommended
    • Linux Users: Install Docker Engine and Docker Compose separately
    • macOS Users: Docker Desktop for Mac recommended
  • Git - Download

    • Verify: git --version
  • VS Code - Download

    • Install extension: Azure Functions (ms-azuretools.vscode-azurefunctions)

Optional (for Azure deployment)

  • Azure CLI - Download
    • Only needed if deploying to Azure
    • Verify: az --version

Verify All Prerequisites

node --version      # Should be v20+
docker --version    # Docker version
docker-compose --version  # Docker Compose version
git --version       # Git version

All prerequisites work the same way on Windows, macOS, and Linux.


οΏ½πŸš€ Quick Start

Option 1: Cloud Development (Recommended for Beginners)

GitHub Codespaces - No installation required, develop entirely in the browser:

  1. Click: Open in GitHub Codespaces
  2. Wait ~60 seconds for container to build
  3. Press F5 in VS Code (browser-based)
  4. Click notification to open frontend in browser

βœ… Zero setup! Everything pre-configured and running.

πŸ“– Full Codespaces Guide

Option 2: Local Development (Docker Required)

Run everything on your machine:

# Clone repository
git clone https://github.com/dsanchezcr/secretsanta.git
cd secretsanta

# Start full-stack (Docker + API + Frontend)
npm install
cd api && npm install
cd ..
# Then press F5 in VS Code to debug, OR:
docker-compose up -d    # Start Docker containers
npm run dev             # Frontend dev server
cd api && npm start     # API in separate terminal

Open: http://localhost:5173

πŸ“– Full Local Development Guide

Option 3: Deploy to Azure

  1. Fork this repository

  2. Configure GitHub OIDC Authentication:

    # Create service principal
    az ad sp create-for-rbac --name "secretsanta-github" \
      --role contributor \
      --scopes /subscriptions/{subscription-id} --json-auth
  3. Add GitHub Secret (Settings β†’ Secrets):

    • AZURE_CREDENTIALS - Paste the entire JSON output from the command above
  4. Create Production Resource Group:

    az group create --name secretsanta --location centralus
  5. Open a PR - Full infrastructure is created automatically!

See docs/github-deployment.md for detailed setup instructions.

Option 2: Local Development (Windows, macOS, Linux)

The fastest way to get running is with VS Code's integrated debugger:

# 1. Clone repository
git clone https://github.com/dsanchezcr/secretsanta.git
cd secretsanta

# 2. Start Docker containers (all platforms)
docker-compose up -d

# 3. Open in VS Code
code .

In VS Code:

  • Press F5 (or Ctrl+Shift+D then click play button)
  • Select "πŸš€ Full Stack (Frontend + API + Emulators)"
  • App automatically opens at http://localhost:5173

Or use GitHub Codespaces (no local setup needed):

  1. Fork this repository
  2. Click "Code" β†’ "Codespaces" β†’ "Create codespace on main"
  3. Wait for container to start
  4. Press F5 to start debugging
  5. App opens at the Codespace URL

See docs/getting-started.md for detailed setup instructions.

πŸ“ Project Structure

β”œβ”€β”€ src/                 # React frontend
β”‚   β”œβ”€β”€ components/      # UI components (views, forms, dialogs)
β”‚   β”œβ”€β”€ lib/            # Utilities, types, translations
β”‚   └── hooks/          # Custom React hooks
β”œβ”€β”€ api/                # Azure Functions backend
β”‚   └── src/
β”‚       β”œβ”€β”€ functions/  # HTTP endpoints + timer triggers
β”‚       └── shared/     # Cosmos DB, email, telemetry
β”œβ”€β”€ e2e/                # Playwright E2E tests
β”œβ”€β”€ infra/              # Bicep infrastructure templates
└── .github/workflows/  # CI/CD pipeline

Frontend Views

  • HomeView: Landing page with game code entry
  • CreateGameView: Game creation form with date validation
  • GameCreatedView: Success page with organizer token
  • ParticipantSelectionView: Participant login for protected games
  • AssignmentView: Shows who you're buying for
  • OrganizerPanelView: Full game management (includes delete)
  • PrivacyView: Data handling and retention policy
  • GameNotFoundView: Error page for deleted/invalid games

πŸ”§ Configuration

Environment Variables (Auto-configured in Azure)

Variable Description Auto-Set
COSMOS_ENDPOINT Cosmos DB endpoint URL βœ…
COSMOS_KEY Cosmos DB primary key βœ…
COSMOS_DATABASE_NAME Database name βœ…
COSMOS_CONTAINER_NAME Container name βœ…
APPLICATIONINSIGHTS_CONNECTION_STRING App Insights connection βœ…
APPINSIGHTS_INSTRUMENTATIONKEY App Insights key βœ…
APP_BASE_URL Application URL βœ…
ACS_CONNECTION_STRING Email service connection βœ…*
ACS_SENDER_ADDRESS Email sender address βœ…*
ENVIRONMENT Environment name (pr/qa/prod) βœ…
BUILD_VERSION Build version identifier βœ…
BUILD_DATE Deployment timestamp βœ…

*Only in QA/production with email enabled

GitHub Secrets (Required)

Secret Description
AZURE_CREDENTIALS Complete JSON from az ad sp create-for-rbac command (includes appId, tenant, subscriptionId, password)

No Variables Needed

Resource group names and deployment URLs are now dynamically generated and output from the infrastructure deployment steps.

πŸ§ͺ Testing

# API unit tests
cd api && npm test

# E2E tests
npm run test:e2e

# E2E with UI
npm run test:e2e:ui

πŸ”„ CI/CD Pipeline

Stage Trigger Description
Build & Test All PRs and main Lint, build, unit tests
PR Infrastructure PR opened Create resource group + dedicated SWA
Preview PRs Deploy to PR Static Web App
Close PR PR closed Delete resource group
QA Infrastructure Main merge Deploy QA Static Web App
QA Main merge Deploy to QA
E2E (QA) After QA deploy Run E2E against QA
Production Infrastructure After QA E2E Deploy production SWA
Production After E2E Manual approval required

πŸ“Š Monitoring

Each environment includes Application Insights for:

  • Error tracking and diagnostics
  • Performance monitoring
  • Custom event logging

Health Endpoints

  • GET /api/health - Full diagnostics (version, uptime, dependencies)
  • GET /api/health/live - Liveness probe
  • GET /api/health/ready - Readiness probe (checks database)

πŸ—‘οΈ Data Retention

  • Auto-Deletion: Games are automatically deleted 3 days after their event date
  • Manual Deletion: Organizers can delete games at any time from the Organizer Panel
  • Privacy: See the in-app Privacy page for full data handling details
  • No External Sharing: Data is never shared with third parties

πŸ“œ License

MIT - See LICENSE

🀝 Contributing

See CONTRIBUTING.md for guidelines.

About

A multilingual gift exchange web application.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •