Architecture

How a post moves from a config to a published tweet, and the processes that make it happen.

Pegacraft is a NestJS backend (Postgres + Redis/BullMQ) and a Next.js frontend, run as three backend entry points from one codebase: the HTTP API, a BullMQ worker, and an elizaOS-based "engine" worker that owns metrics ingestion. There is no official-API integration for X: posting happens by replaying a saved browser session through headless Playwright, a deliberate cost trade-off covered in the publishing model.

The pipeline, end to end

The three processes

  • src/main.ts: the HTTP API. Every request runs behind JwtAuthGuard, which also seeds tenant context for the request.
  • src/worker.ts: a headless BullMQ worker (concurrency: 1) consuming the generation, publish, competitor-scrape, and mention-scrape queues.
  • src/engine-worker.ts: a separate headless process embedding elizaOS as the metrics and topic-performance substrate. It owns the metrics queue and is the only process that reads or writes elizaOS's own database.

Where to go next

On this page