Infrastructure¶
Detailed guide to the infrastructure services that power Genji Shimada.
Architecture Overview¶
┌─────────────────┐
│ Discord Users │
└────────┬────────┘
│
┌────▼────────────────┐
│ Discord Bot │
│ (discord.py) │
└─┬────────────────┬──┘
│ │
│ │
┌────▼─────┐ ┌────▼──────┐
│ RabbitMQ │◄───┤ REST API │
│ │ │ (Litestar)│
└──────────┘ └─────┬─────┘
│
┌─────▼──────┐
│ PostgreSQL │
└────────────┘
PostgreSQL¶
Overview¶
PostgreSQL 17 is the primary data store for all persistent data.
Schema Organization¶
The database uses multiple schemas for logical separation:
genjishimada (database)
├── core # Users, maps, permissions
├── maps # Map metadata, ratings
├── completions # User completion records
├── playtests # Map playtesting data
├── users # Profiles, XP, rank cards
├── lootbox # Lootbox system
├── rank_card # Rank card customization
└── public # Jobs, sessions, idempotency
Backups¶
Create a full backup:
RabbitMQ¶
Overview¶
RabbitMQ is used for asynchronous message passing between the API and bot.
Key Features: - Queue-based messaging for event processing - Dead letter queues (DLQ) for failed messages - Message persistence for reliability - Idempotency tracking to prevent duplicate processing
Queue Naming Convention¶
Queues follow the pattern: api.<domain>.<action>
Examples:
- api.completion.submission
- api.notification.delivery
- api.map_edit.created
Monitoring¶
Local development: Access management UI at http://localhost:15672 (genji/local_dev_password)
Remote deployments: RabbitMQ is not exposed directly. Use container logs:
# Staging
docker compose -f docker-compose.dev.yml logs -f genjishimada-rabbitmq-dev
# Production
docker compose -f docker-compose.prod.yml logs -f genjishimada-rabbitmq
Cloudflare R2¶
Overview¶
Cloudflare R2 is used for S3-compatible object storage.
Use cases: - Completion videos and screenshots - User rank card images - Map thumbnails
Configuration¶
Set environment variables:
Bucket Details¶
The API uploads screenshots to the genji-parkour-images bucket and returns public URLs via the cdn.bkan0n.com domain.
Sentry¶
Overview¶
Sentry provides error tracking and performance monitoring.
Configuration¶
Set the DSN in .env:
SENTRY_DSN=https://[email protected]/your_project
Integration¶
API (apps/api/app.py):
import sentry_sdk
sentry_sdk.init(
dsn=SENTRY_DSN,
environment=APP_ENVIRONMENT,
traces_sample_rate=0.1,
)
Bot (apps/bot/main.py):
import sentry_sdk
from sentry_sdk.integrations.asyncio import AsyncioIntegration
sentry_sdk.init(
dsn=SENTRY_DSN,
environment=APP_ENVIRONMENT,
integrations=[AsyncioIntegration()],
)
Email (Resend)¶
Overview¶
Resend is used for transactional email delivery.
Configuration¶
RESEND_API_KEY=your_resend_api_key
[email protected]
Next Steps¶
- Docker Compose Guide - Deploy these services
- Reverse Proxy - Caddy routing and TLS for Genji and monitoring
- Bot Configuration - Configure the bot
- API Documentation - Understand the API