Fix web/ -> api/, add missing panel/modules/graphics sections, expand module and utility listings to match actual codebase. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
7.6 KiB
Aurora - Discord RPG Bot
A comprehensive, feature-rich Discord RPG bot built with modern technologies using a monorepo architecture.
Architecture Overview
Aurora uses a Single Process Monolith architecture that runs both the Discord bot and REST API in the same Bun process. This design maximizes performance by eliminating inter-process communication overhead and simplifies deployment to a single Docker container.
Monorepo Structure
aurora-bot-discord/
├── bot/ # Discord bot implementation
│ ├── commands/ # Slash command implementations
│ ├── events/ # Discord event handlers
│ ├── lib/ # Bot core logic (BotClient, utilities)
│ ├── modules/ # Feature modules (views, interactions per domain)
│ ├── graphics/ # Canvas-based image generation
│ └── index.ts # Bot entry point
├── api/ # REST API server
│ └── src/routes/ # API route handlers
├── shared/ # Shared code between bot and API
│ ├── db/ # Database schema and Drizzle ORM
│ ├── lib/ # Utilities, config, errors, logger, events
│ └── modules/ # Domain services (economy, admin, inventory, quest, etc.)
├── panel/ # React admin dashboard (Vite + Tailwind)
├── scripts/ # Helper scripts
├── docker-compose.yml # Docker services (app, db)
└── package.json # Root package manifest
Main Application Parts
1. Discord Bot (bot/)
The bot is built with Discord.js v14 and handles all Discord-related functionality.
Core Components:
- BotClient (
bot/lib/BotClient.ts): Central client that manages commands, events, and Discord interactions - Commands (
bot/commands/): Slash command implementations organized by category:admin/: Server management commands (config, prune, warnings, notes)economy/: Economy commands (balance, daily, pay, trade, trivia)feedback/: Feedback commandsinventory/: Item management commandsleveling/: XP and level trackingquest/: Quest commandsuser/: User profile commands
- Modules (
bot/modules/): Feature modules with views and interaction handlers per domain (admin, economy, inventory, moderation, trade, trivia, etc.) - Graphics (
bot/graphics/): Canvas-based image generation (lootdrops, student IDs) - Events (
bot/events/): Discord event handlers:interactionCreate.ts: Command interactionsmessageCreate.ts: Message processingready.ts: Bot ready eventsguildMemberAdd.ts: New member handling
2. REST API (api/)
A headless REST API built with Bun's native HTTP server for bot administration and data access.
Key Endpoints:
- Stats (
/api/stats): Real-time bot metrics and statistics - Settings (
/api/settings): Configuration management endpoints - Guild Settings (
/api/guild-settings): Per-guild configuration - Users (
/api/users): User data and profiles - Items (
/api/items): Item catalog and management - Quests (
/api/quests): Quest data and progress - Economy (
/api/transactions): Economy and transaction data - Moderation (
/api/moderation): Moderation case data - Classes (
/api/classes): RPG class data - Lootdrops (
/api/lootdrops): Lootdrop data - Health (
/api/health): Health check endpoint
API Features:
- Built with Bun's native HTTP server
- WebSocket support for real-time updates (
/ws) - REST API endpoints for all bot data
- Real-time event streaming via WebSocket
- Zod validation for all requests
3. Admin Panel (panel/)
A React-based admin dashboard built with Vite and Tailwind CSS for managing the bot through a web interface.
4. Shared Core (shared/)
Shared code accessible by both the bot and API.
Database Layer (shared/db/):
- schema.ts: Drizzle ORM schema definitions for:
users: User profiles with economy dataitems: Item catalog with rarities and typesinventory: User item holdingstransactions: Economy transaction historyclasses: RPG class systemmoderationCases: Moderation logsquests: Quest definitions
Modules (shared/modules/):
- economy/: Economy service, lootdrops, daily rewards
- admin/: Administrative actions (maintenance mode, cache clearing)
- inventory/: Inventory management
- items/: Item catalog and management
- trade/: Trading system
- trivia/: Trivia game logic
- quest/: Quest creation and tracking
- class/: RPG class system
- leveling/: XP and leveling logic
- moderation/: Moderation case management
- user/: User profile management
- dashboard/: Dashboard statistics and real-time event bus
- guild-settings/: Per-guild configuration
- game-settings/: Game-wide settings
- feature-flags/: Feature flag management
- system/: System-level utilities
Utilities (shared/lib/):
config.ts: Application configuration managementlogger.ts: Structured logging systemenv.ts: Environment variable handlingerrors.ts: Error classes (UserError, SystemError)events.ts: Event bus for inter-module communicationeventWiring.ts: Event bus wiringconstants.ts: Application-wide constantstypes.ts: Shared TypeScript typesutils.ts: General utility functionsrarity.ts: Item rarity definitionsassets.ts: Asset path utilities
Main Use-Cases
For Discord Users
- Class System: Users can join different RPG classes with unique roles
- Economy:
- View balance and net worth
- Earn currency through daily rewards, trivia, and lootdrops
- Send payments to other users
- Trading: Secure trading system between users
- Inventory Management: Collect, use, and trade items with rarities
- Leveling: XP-based progression system tied to activity
- Quests: Complete quests for rewards
- Lootdrops: Random currency drops in text channels
For Server Administrators
- Bot Configuration: Adjust economy rates, enable/disable features via API
- Moderation Tools:
- Warn, note, and track moderation cases
- Mass prune inactive members
- Role management
- Quest Management: Create and manage server-specific quests
- Monitoring:
- Real-time statistics via REST API
- Activity data and event logs
- Economy leaderboards
For Developers
- Single Process Architecture: Easy debugging with unified runtime
- Type Safety: Full TypeScript across all modules
- Testing: Bun test framework with unit tests for core services
- Docker Support: Production-ready containerization
- Remote Access: SSH tunneling scripts for production debugging
Technology Stack
| Layer | Technology |
|---|---|
| Runtime | Bun 1.0+ |
| Bot Framework | Discord.js 14.x |
| Web Framework | Bun HTTP Server (REST API) |
| Database | PostgreSQL 17 |
| ORM | Drizzle ORM |
| Admin Panel | React + Vite + Tailwind CSS |
| UI | Discord embeds and components |
| Validation | Zod |
| Containerization | Docker |
Running the Application
# Database migrations
bun run migrate
# Production (Docker)
docker compose up
The bot and API server run on port 3000 and are accessible at http://localhost:3000.