Some checks failed
Deploy to Production / test (push) Failing after 33s
- Rewrite AGENTS and README files to match the current app layout - Document API routes, trivia UI, and the active panel design language
4.8 KiB
4.8 KiB
AGENTS.md
This file documents the current implementation shape of the Aurora repository.
Commands
# App
bun run dev # bot + API in one Bun process with watch mode
docker compose up # app + db
docker compose up app # app only
docker compose up db # database only
# Testing
bun test # Bun's native runner
bun run test # repo test wrapper script
bun run test:ci # include CI/integration path
# Database
bun run db:push # drizzle-kit push via Docker
bun run db:push:local # drizzle-kit push locally
bun run db:generate # drizzle-kit generate via Docker
bun run db:migrate # drizzle-kit migrate via Docker
bun run db:studio # local Drizzle Studio on :4983
# Panel
bun run panel:dev # Vite dev server on :5173
bun run panel:build # build panel/dist
Architecture
Aurora is a single-process Bun application:
bot/index.tsboots shared config, registers domain listeners, starts the API server, then logs into Discord.api/src/server.tshosts REST routes, WebSocket traffic, and built panel assets.shared/modules/*contains the business logic used by both the bot and the API.shared/games/*contains reusable game plugins;api/src/games/*runs rooms and WebSocket orchestration.
Current high-level layout:
bot/ Discord commands, events, views, interactions
api/ Bun HTTP + WebSocket server
panel/ React dashboard
shared/db/ Drizzle client and schema
shared/lib/ config, env, errors, logger, events, constants
shared/modules/ domain services
shared/games/ game plugins shared by API and panel
Import conventions
Use path aliases from the repo tsconfig.json:
@/*->bot/*@commands/*->bot/commands/*@db/*->shared/db/*@lib/*->bot/lib/*@modules/*->bot/modules/*@shared/*->shared/*
Import order in the repo is generally:
- external packages
- aliases
- relative imports
File patterns
*.service.ts: domain/business logic, usually inshared/modules/**.view.ts: Discord message/view construction*.interaction.ts: component interaction handlers*.types.ts: local types and custom ID helpers*.handler.ts: bot-side orchestration around services/views*.test.ts: colocated tests
Runtime config
- Global game settings live in
game_settingsand are loaded intoshared/lib/config.ts. - Guild-specific settings live in
guild_settings;getGuildConfig()adds a 60-second cache on top of DB reads. - Most numeric DB values exposed through runtime config are converted to
bigintinshared/lib/config.ts.
Interaction routing
Global component routing is defined in bot/lib/interaction.routes.ts and consumed by ComponentInteractionHandler.
Current route table:
trade_andamount->bot/modules/trade/trade.interaction.tsshop_buy_->bot/modules/economy/shop.interaction.tslootdrop_->bot/modules/economy/lootdrop.interaction.tstrivia_->bot/modules/trivia/trivia.interaction.tscreateitem_->bot/modules/admin/item_wizard.tsenrollment->bot/modules/user/enrollment.interaction.tsfeedback_->bot/modules/feedback/feedback.interaction.ts
Some features still use local collectors instead of the global route table, notably inventory.
Commands and access control
- Slash command execution is centralized in
bot/lib/handlers/CommandHandler.ts. withCommandErrorHandling()is the normal command wrapper for defer/reply/error behavior.- Beta commands rely on
featureFlagsService.hasAccess(). ADMIN_USER_IDScontrols admin panel access, not Discord permissions inside command code.
API and panel
- API routes are prefix-matched in
api/src/routes/index.ts. /auth/*and/api/healthare public.- Players may access
/api/stats,/api/health,/api/me, and/api/me/inventory. - Remaining
/api/*routes are admin-only. - The panel dev server proxies back to the Bun server; the integrated server serves
panel/distwhen built.
Database notes
- Docker Compose uses PostgreSQL 17.
- Discord IDs and currency/xp values are stored as
bigint. withTransaction()lives inbot/lib/db.tsand is the normal way shared services compose DB work.
Testing
- Tests use
bun:test. - Mock modules before importing the unit under test.
- Most service tests stub
DrizzleClientorwithTransaction()rather than hitting the real database.
Key entrypoints
bot/index.tsbot/lib/BotClient.tsapi/src/server.tsapi/src/routes/index.tsshared/lib/config.tsshared/db/DrizzleClient.tsshared/db/schema/index.ts