Skip to main content
This page covers the main annie-mei service in the repository root.

What the bot service does

The bot service:
  • connects to Discord and registers slash commands
  • handles /ping, /help, /anime, /manga, /search, /recommend, /character, /songs, /register, /unregister, /whoami, and /settings
  • connects to PostgreSQL with an async connection pool
  • runs bot-owned SQLx migrations for Annie Mei settings tables
  • connects to Redis for API response caching
  • builds the AniList OAuth start link that sends members to the auth service
The bot no longer exposes an HTTP listener; stack liveness and readiness are served by the auth service.

Required dependencies

Before you run the bot service, make sure you have:
  • a Discord bot token
  • PostgreSQL
  • Redis
  • Spotify API credentials
  • MyAnimeList API client ID
  • auth service configuration values, including AUTH_SERVICE_BASE_URL
  • (optional) a Gemini or OpenAI-compatible API key for /search
The bot currently loads OAuth configuration during startup. That means AUTH_SERVICE_BASE_URL and OAUTH_CONTEXT_SIGNING_SECRET are part of the normal bot setup, not optional extras.

Configure the bot environment

Create .env in the repository root and set the bot service variables:
# Discord
DISCORD_TOKEN=your_discord_bot_token

# Database
DATABASE_URL=postgres://user:password@localhost/annie_mei

# Cache
REDIS_URL=redis://localhost:6379

# External APIs
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
MAL_CLIENT_ID=your_mal_client_id

# Monitoring
SENTRY_DSN=your_sentry_dsn
ENV=development
SENTRY_TRACES_SAMPLE_RATE=0.0

# Shared privacy and OAuth values
USERID_HASH_SALT=generate_a_random_secret_value
AUTH_SERVICE_BASE_URL=http://127.0.0.1:8000
OAUTH_CONTEXT_SIGNING_SECRET=generate_a_random_secret_value

# Optional
OAUTH_CONTEXT_TTL_SECONDS=300
RUST_LOG=info,serenity=warn
Use Environment Variables for the full bot and auth reference.
Set DATABASE_URL to the same PostgreSQL database used by the auth service. The bot reads OAuth credential rows that the auth service writes.

Run the bot service locally

1

Create the database

createdb annie_mei
2

Start Redis

Make sure your local Redis instance is reachable at the value in REDIS_URL.
3

Start the bot

cargo run
On startup, the bot will connect to PostgreSQL, run its settings migrations, load OAuth configuration, and register slash commands.

Verify in Discord

Try these slash commands after the bot is online:
/ping
/anime search:Attack on Titan
/settings
/register
If /register returns a link button but the browser flow fails, finish the Auth service setup and make sure both services share the same OAUTH_CONTEXT_SIGNING_SECRET.