How discord/airhornbot works
• Bot Service:
• Discord Integration: Include subcomponents such as command handlers (e.g., SoundboardCommand, InviteCommand, StatsCommand), listeners (e.g., ReadyListener, ShardListener, InteractionCreateListener), and Discord-specific utilities.
• Routes/API: Show the API routes (e.g., ApiAdminRouter, ApiEventsRoute, and the admin API controllers under bot/src/routes/api/admin) used for administrative interactions and possibly data updates.
• Sound Management: Represent the sound resources (organized under bot/sounds) and utilities related to audio playback (e.g., AirhornAudio in utils) that the bot uses to play sound effects.
• Database Layer: Represent the Prisma integration (under bot/prisma with migrations and schema) that uses Postgres as the backend datastore.
• Website Frontend:
• UI Components: Include components such as AirhornCounter, StatsPanel, various islands (IslandDoubleTree, IslandForest, etc.) and others that build the user interface.
• State Management & Actions: Show the stores (AirhornStatsStore, OAuthStore, ResponsiveStore, ShareStore) which manage the app state and the actions (OAuthActions, StatsActions, ResponsiveActions, ShareActions) that handle events and data flow.
• Assets: Illustrate static assets like images, audio files, and videos that are part of the interface.
• Shared or Supporting Services:
• CI/CD Pipelines: Although not part of the runtime system, include a note or a separate section for the automated deployment workflows (in .github/workflows) that ensure continuous integration and deployment for both parts.
• Deployment & Configuration: Briefly note the environment configuration files (.env.example) and build tools/configurations (Webpack in the website, tsconfig.json for both parts).
Relationships and Interactions
• The Bot Service communicates with Discord (external service) and listens for events/interactions.
• The Bot processes commands, which might trigger routes/API endpoints that interact with the database.
• The Website Frontend communicates with the Bot’s API endpoints (if applicable) to fetch or display stats.
• Both Bot and Website depend on environment configurations and build processes for deployment.
• Interactions from the Discord API into the Bot’s command and listener layers. Then connect the command processing modules to utility modules (for audio, etc.), and further down to the database layer (via Prisma).
Architectural Patterns and Technical Stack
• Modular separation between the Discord bot functionalities (commands, events, routes) and the frontend website.
• Use of frameworks and tools: TypeScript throughout the project; Prisma as the ORM for database interactions; and modern web development tooling (Webpack, Babel, and a component-based UI library likely using React).
• The file structure (folders for routes, commands, listeners, and components) suggests an organizational pattern that promotes separation of concerns and modularity.