How sleepymaidbot/sleepymaid works
Project Type and Purpose
• This is a TypeScript monorepo for a suite of Discord utility bots and a companion web dashboard, all orchestrated via Docker Compose.
• The “services” directory contains several independent Discord bot services (sleepymaid, helper, clarity, watcher, testbot) plus an API service and a Remix-based website.
• The “packages” directory holds shared libraries:
• db (Drizzle ORM configs and schemas)
• handler (command/listener/task framework for bots)
• logger (logging abstraction)
• shared (core utilities: config, localization, permissions, RabbitMQ integration)
• util (generic helpers & tests)
High-Level Architecture Components
a. Containers (Dockerized services):
• Database (PostgreSQL or similar)
• Message Broker (RabbitMQ)
• API service (serves JSON endpoints to website)
• Bot services (sleepymaid, helper, clarity, watcher, testbot)
• Website (Remix app)
b. Internal Modules (Node libraries consumed by containers):
• @sleepymaid/db
• @sleepymaid/handler
• @sleepymaid/logger
• @sleepymaid/shared
• @sleepymaid/util
c. External Systems:
• Discord API (for bots)
• Docker Registry / CI (GitHub Actions)
Component Relationships and Data Flows
• Each bot service container imports handler + shared + logger packages to register commands, listeners, and tasks against the Discord API.
• Bot services read/write application state in the Database using the db package and emit or consume events from RabbitMQ via shared/rabbitmq.
• The API service talks to the Database for CRUD operations and reads/writes to RabbitMQ for asynchronous tasks (if any).
• The Website calls the API service over HTTP, persists session data in the Database, and may dispatch jobs via the Message Broker.
• GitHub Actions CI builds, tests, and publishes container images to the Docker Registry; Docker Compose (dev/prod configs) spins up all containers together.
Architectural Patterns and Design Principles
• Monorepo + internal packages for code reuse (handler, logger, shared, util).
• Microservices: each Discord bot is its own container, allowing independent scaling and deployment.
• Event-driven communication via RabbitMQ for cross-service hooks or background tasks.
• Layered organization:
• Presentation: Website (Remix)
• API: REST service
• Domain logic: Bot services + shared libraries
• Persistence: Relational DB (Drizzle ORM)
• Infrastructure as Code: Dockerfiles, Docker Compose, GitHub Actions.
b. “RabbitMQ” to the side of the DB. Label it “Message Broker”.
d. Inside that boundary, add:
• For each Bot service:
e. Outside the Docker boundary, show:
• Discord API cloud connecting to each bot.