A self-hosted Secret Santa gift exchange organizer built with FastAPI, SQLModel, and Telegram Bot integration.
uv is a fast Python package installer and resolver.
-
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh # Or on macOS: brew install uv
-
Install dependencies:
uv sync
-
Run the application:
uv run uvicorn app.main:app --reload
pip install -r requirements.txtCopy the example environment file and fill in your values:
cp .env.example .envEdit .env with your configuration:
# Database
DATABASE_URL=sqlite+aiosqlite:///./data/santa.db
# Google OAuth (required)
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# Session Secret Key (generate a random string)
SECRET_KEY=your_random_secret_key_here
# Telegram Bot (optional, for notifications)
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_BOT_USERNAME=your_bot_username # Optional: bot username will be auto-detected from bot API if not setmkdir -p dataThe .env file is automatically loaded by pydantic-settings.
With uv:
uv run uvicorn app.main:app --reloadWith pip:
uvicorn app.main:app --reloadThe application will be available at http://localhost:8000
The application uses pydantic-settings which automatically loads variables from:
.envfile (in the project root)- System environment variables (takes precedence)
GOOGLE_CLIENT_ID: Google OAuth client IDGOOGLE_CLIENT_SECRET: Google OAuth client secretSECRET_KEY: Secret key for session encryption (generate a random string)
DATABASE_URL: Database connection string (defaults to SQLite)TELEGRAM_BOT_TOKEN: Telegram bot token for notificationsTELEGRAM_BOT_USERNAME: Telegram bot usernameLOG_LEVEL: Logging level for uvicorn (default: "info"). Set to "error" to disable access logs in production. Options: "critical", "error", "warning", "info", "debug", "trace"
Production:
docker-compose up -dDevelopment (with hot-reload):
docker-compose -f docker-compose.dev.yml upUsing uv (recommended, faster):
docker build -f Dockerfile.uv -t secret-santa:latest .Using traditional pip:
docker build -f Dockerfile -t secret-santa:latest .- Make sure your
.envfile exists in the project root - The database is stored in a Docker volume (
santa_data) for persistence - See DOCKER.md for detailed Docker deployment guide
The project includes comprehensive tests for all functionality.
Unit Tests (Fast, No Server Required):
# Run all unit tests
uv run pytest tests/ -v -m "not browser"
# Run specific test file
uv run pytest tests/test_auth.py -v
# Run with coverage
uv run pytest tests/ --cov=app --cov-report=htmlBrowser Tests (Requires Running Server):
# Option 1: Use the automated script
./tests/run_browser_tests.sh
# Option 2: Manual (start server first)
# Terminal 1:
uv run uvicorn app.main:app --port 8001
# Terminal 2:
TEST_BASE_URL=http://localhost:8001 uv run pytest tests/test_browser_e2e.py -v --browser -m browserAll Tests:
./run_tests.sh --allSee TESTING.md for detailed testing documentation.
# Install dependencies including dev tools
uv sync --dev
# Run the application
uv run uvicorn app.main:app --reload
# Add a new dependency
uv add package-name
# Add a dev dependency
uv add --dev package-name
# Update dependencies
uv sync --upgradepyproject.toml- Project metadata and dependencies (uv/pip compatible)requirements.txt- Traditional pip requirements (for compatibility).python-version- Python version specificationuv.lock- Lock file for reproducible installs (generated by uv)
The application automatically:
- Creates database tables on startup
- Starts the Telegram bot (if token is provided)
- Loads environment variables from
.env
- The
.envfile is gitignored for security - Environment variables set in the system take precedence over
.envfile values - The database is created automatically in the
data/directory uv.lockis gitignored but can be committed for reproducible builds