Docker Setup (Recommended)
One command sets up MongoDB, Redis, and the app with hot-reloading:The
.env.example file comes pre-configured for local development — MongoDB and Redis connect to the Docker containers automatically. Auth features (OAuth, email) are disabled by default and work fine without configuration.Running Tests and Linting
You’ll needuv for running tests and linting outside the container:
Configuring Optional Features
The default.env.example gets you a working instance for URL shortening, redirects, and analytics. For additional features, configure these in your .env:
| Feature | Env Vars | Setup Guide |
|---|---|---|
| JWT Auth (RSA) | JWT_PRIVATE_KEY, JWT_PUBLIC_KEY | Authentication Setup |
| JWT Auth (HMAC) | JWT_SECRET | Generate with python -c "import os; print(os.urandom(32).hex())" |
| Google OAuth | GOOGLE_OAUTH_CLIENT_ID, GOOGLE_OAUTH_CLIENT_SECRET | Authentication Setup |
| GitHub OAuth | GITHUB_OAUTH_CLIENT_ID, GITHUB_OAUTH_CLIENT_SECRET | Authentication Setup |
| Discord OAuth | DISCORD_OAUTH_CLIENT_ID, DISCORD_OAUTH_CLIENT_SECRET | Authentication Setup |
| Email (Zeptomail) | ZEPTO_API_TOKEN, ZEPTO_FROM_EMAIL | See .env.example comments |
| Sentry | SENTRY_DSN | Leave empty to disable |
| Discord Webhooks | CONTACT_WEBHOOK, URL_REPORT_WEBHOOK | Creating Webhooks |
| hCaptcha | HCAPTCHA_SECRET | hcaptcha.com |
Manual Setup (Without Docker)
If you prefer not to use Docker, you’ll need to install MongoDB and Redis yourself.Prerequisites
- Python 3.10+
- uv package manager
- MongoDB 7.0+ (setup guide)
- Redis 7.0+ (setup guide)
Installation
.env to point to your local MongoDB and Redis:
Running the Server
Verifying Your Setup
After starting the app (via Docker or manually):- Health check:
curl http://localhost:8000/health— should return{"status": "healthy"} - Shorten a URL: Visit the homepage and create a test short link
- Test redirect: Click the short link to verify it redirects
- Run tests:
uv run pytest— all tests should pass
Troubleshooting
Docker: Port 8000 already in use
Docker: Port 8000 already in use
Docker: App can't connect to MongoDB
Docker: App can't connect to MongoDB
Check that all containers are running:If the
db container is unhealthy, check its logs:Manual: ModuleNotFoundError
Manual: ModuleNotFoundError
Make sure you’re using
uv run to execute commands — it activates the virtual environment automatically:Health endpoint shows 'degraded'
Health endpoint shows 'degraded'
This means MongoDB is connected but Redis isn’t. The app still works — Redis is optional for caching. Check your
REDIS_URI in .env or verify Redis is running.
