Architecture
Answer Overflow is built as a TypeScript monorepo using Bun and Turbo for orchestration. The project follows a clean separation between applications and shared packages.Monorepo structure
Applications
Discord bot
The Discord bot (apps/discord-bot) is the core service that:
- Monitors Discord servers for new threads and messages
- Processes thread data for indexing
- Responds to slash commands
- Manages channel settings and permissions
- discord.js for Discord API integration
- Effect for functional programming patterns
- Bun runtime for fast execution
apps/discord-bot/index.ts
Main site
The web application (apps/main-site) provides:
- Public-facing thread pages for SEO
- Server and channel management dashboard
- User authentication and settings
- MCP (Model Context Protocol) server for AI agents
- Next.js 16 with App Router
- Better Auth for authentication
- Convex for real-time data
- Tailwind CSS for styling
Core packages
Database package
The@packages/database package contains:
- Convex schema definitions
- Database queries and mutations
- Authentication configuration
- Storage layer (S3) integration
packages/database/convex/schema.ts
bun dev- Start Convex in development modebun deploy- Deploy to productionbun codegen- Generate type definitions
Agent package
The@packages/agent package provides:
- AI agent framework built on Convex
- Tool definitions for AI interactions
- React hooks for agent state management
- HTTP endpoints for agent communication
AI package
The@packages/ai package includes:
- AI SDK integrations (OpenAI, Anthropic)
- Prompt templates and utilities
- Content generation helpers
Data flow
Build orchestration
The project uses Turbo for monorepo task orchestration:turbo.json
Environment variables
Key environment variables used across the monorepo:DISCORD_TOKEN- Discord bot tokenDISCORD_CLIENT_ID/DISCORD_CLIENT_SECRET- OAuth credentialsCONVEX_DEPLOYMENT- Convex deployment URLNEXT_PUBLIC_CONVEX_URL- Public Convex endpointBETTER_AUTH_SECRET- Authentication secretSTRIPE_SECRET_KEY- Payment processing
Deployment
- Discord bot: Deployed as a long-running service
- Main site: Deployed on Vercel with edge functions
- Database: Convex handles serverless deployment automatically
The monorepo structure allows packages to be shared between apps while maintaining clear boundaries.