Overview
Annie Mei requires configuration through environment variables for Discord integration, database access, caching, external APIs, and monitoring. This guide covers the essential configuration steps for deploying the bot to production. If you want full self-hosted feature parity, deploy the auth service alongside the bot service. Use Self-hosting architecture and Auth service before you finalize production config.Prerequisites
Before configuring Annie Mei, ensure you have:- A Discord bot token from the Discord Developer Portal
- PostgreSQL database
- Redis cache
- Spotify API credentials
- MyAnimeList API credentials
- Sentry account for error tracking
Configuration Methods
Environment Variables
Annie Mei reads all configuration from environment variables. You can set them:- Locally: Using a
.envfile (not committed to git) - Production: Using your preferred secrets workflow or manager
- CI/CD: Using GitHub Actions secrets
Example: using Doppler
If you already use Doppler, this is one way to inject secrets:Required Configuration
See the Environment Variables page for a complete list of all required and optional environment variables.Environment-Specific Settings
Development
Production
Discord Configuration
Creating a Discord Bot
- Go to Discord Developer Portal
- Click “New Application” and name it “Annie Mei”
- Navigate to the “Bot” section
- Click “Add Bot”
- Under “Token”, click “Reset Token” and copy the value
- Set as
DISCORD_TOKENenvironment variable
Required Intents
Annie Mei requires these Gateway Intents (configured in the Discord Developer Portal):- Guild Messages
- Direct Messages
- Guild Presences
- Guilds
Inviting the Bot
Generate an invite URL with these scopes and permissions:- Scopes:
bot,applications.commands - Permissions:
Send Messages,Embed Links,Use Slash Commands
API Configuration
Spotify API
- Go to Spotify for Developers
- Create a new app
- Copy the Client ID and Client Secret
- Set
SPOTIFY_CLIENT_IDandSPOTIFY_CLIENT_SECRET
MyAnimeList API
- Go to MyAnimeList API
- Create a new API client
- Copy the Client ID
- Set
MAL_CLIENT_ID
Database Setup
See Infrastructure for detailed PostgreSQL setup instructions. Once your database is provisioned, set theDATABASE_URL:
Running Migrations
The bot automatically runs embedded Diesel migrations on startup. You only need Diesel CLI if you want to run or generate migrations manually during development.Cache Setup
See Infrastructure for detailed Redis setup instructions. Set theREDIS_URL with your Redis connection string:
Monitoring & Error Tracking
Sentry Configuration
- Create a project in Sentry
- Copy the DSN from project settings
- Set
SENTRY_DSNenvironment variable - Configure trace sampling with
SENTRY_TRACES_SAMPLE_RATE(0.0 to 1.0)
Privacy Settings
Annie Mei implements privacy-focused monitoring:- User IDs are hashed using
USERID_HASH_SALTbefore sending to Sentry - Database credentials in URLs are automatically redacted from error logs
- See
src/main.rs:146for URL credential redaction logic
Hash Lookup Utility
To look up a user’s hashed ID in Sentry logs:Server Configuration
HTTP Health Check Server
Annie Mei runs an HTTP health check server on port 8080 by default (configurable viaSERVER_PORT):
/healthz endpoint that monitors the health of Redis and PostgreSQL connections. It binds to 127.0.0.1, so expose it through your own reverse proxy or local monitoring if you need external checks.
Endpoint: GET /healthz
Response (healthy):
200 OK- All services healthy503 Service Unavailable- One or more services down
- Load balancer health checks
- Monitoring and alerting systems
- Verifying deployment success
src/server.rs:14-61
Validation
Before deploying, validate your configuration:Next Steps
- Review Environment Variables for complete reference
- Set up Infrastructure for production deployment
- Configure monitoring and alerts in Sentry
