Skip to content

About

Simple self hosted solution for the secret santa.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secret Santa Application

A self-hosted Secret Santa gift exchange organizer built with FastAPI, SQLModel, and Telegram Bot integration.

Setup

Option 1: Using uv (Recommended)

uv is a fast Python package installer and resolver.

  1. Install uv (if not already installed):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    # Or on macOS: brew install uv
  2. Install dependencies:

    uv sync
  3. Run the application:

    uv run uvicorn app.main:app --reload

Option 2: Using pip (Traditional)

pip install -r requirements.txt

2. Configure Environment Variables

Copy the example environment file and fill in your values:

cp .env.example .env

Edit .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 set

3. Create Data Directory

mkdir -p data

4. Run the Application

The .env file is automatically loaded by pydantic-settings.

With uv:

uv run uvicorn app.main:app --reload

With pip:

uvicorn app.main:app --reload

The application will be available at http://localhost:8000

Environment Variables

The application uses pydantic-settings which automatically loads variables from:

  1. .env file (in the project root)
  2. System environment variables (takes precedence)

Required Variables

  • GOOGLE_CLIENT_ID: Google OAuth client ID
  • GOOGLE_CLIENT_SECRET: Google OAuth client secret
  • SECRET_KEY: Secret key for session encryption (generate a random string)

Optional Variables

  • DATABASE_URL: Database connection string (defaults to SQLite)
  • TELEGRAM_BOT_TOKEN: Telegram bot token for notifications
  • TELEGRAM_BOT_USERNAME: Telegram bot username
  • LOG_LEVEL: Logging level for uvicorn (default: "info"). Set to "error" to disable access logs in production. Options: "critical", "error", "warning", "info", "debug", "trace"

Docker

Quick Start

Production:

docker-compose up -d

Development (with hot-reload):

docker-compose -f docker-compose.dev.yml up

Build Options

Using uv (recommended, faster):

docker build -f Dockerfile.uv -t secret-santa:latest .

Using traditional pip:

docker build -f Dockerfile -t secret-santa:latest .

Important Notes

  • Make sure your .env file 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

Testing

The project includes comprehensive tests for all functionality.

Running Tests

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=html

Browser 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 browser

All Tests:

./run_tests.sh --all

See TESTING.md for detailed testing documentation.

Development

Using uv

# 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 --upgrade

Project Structure

  • pyproject.toml - Project metadata and dependencies (uv/pip compatible)
  • requirements.txt - Traditional pip requirements (for compatibility)
  • .python-version - Python version specification
  • uv.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

Notes

  • The .env file is gitignored for security
  • Environment variables set in the system take precedence over .env file values
  • The database is created automatically in the data/ directory
  • uv.lock is gitignored but can be committed for reproducible builds

About

Simple self hosted solution for the secret santa.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages