Skip to content

MongoDB & Redis

Sosyabot has two storage dependencies: MongoDB for the system of record and Redis for the BullMQ job queue.

MongoDB

  • Version: 6.0 or newer (Mongoose 8 supports 6.0+; tested against 7.0).
  • Connection: MONGODB_URL=mongodb://user:pass@host:27017/sosyabot.
  • Auth: passwords containing URL-reserved characters must be URL-encoded.
  • Replica set: optional but recommended for production. Append ?replicaSet=...&readPreference=primary to the URL.

Collections

The largest collections by row count:

  • accounts — connected social channels.
  • posts — every post ever drafted, scheduled, sent, or failed.
  • post_stats — engagement snapshots (find-slot reads from this — see Best Posting Time).
  • agent_runs — autonomous-agent execution history.
  • usage_counters — AI credit accounting.
  • audit_log — admin and security events.

Redis

  • Version: 7.0+. BullMQ requires Redis Streams support.
  • Connection: REDIS_URL=redis://:pass@host:6379/0.
  • Persistence: not required — Sosyabot treats Redis as ephemeral state. BullMQ jobs replay on worker restart from MongoDB-backed scheduled-post records.

Queues

  • ai-video — async video-generation jobs (video).
  • ai-agents — autonomous agent runs (agents).
  • ai-generation — synchronous prompt / inline generation jobs.
  • token-refresh — sweeps OAuth tokens (Threads, Pinterest, YouTube, Reddit) every interval; see Connections.
  • post-publishing — scheduled-post fan-out worker.

WORKER_CONCURRENCY (default 4) controls how many jobs the worker handles concurrently per queue.

Sizing

Rough guidance for a single-tenant deployment:

Tenants × posts/monthMongo storageMongo RAMRedis RAM
10 × 1 0001 GB1 GB256 MB
100 × 5 00020 GB4 GB1 GB
1 000 × 10 000200 GB16 GB4 GB

Most growth is in post_stats — ~100 bytes per snapshot per post per platform. A 90-day window keeps the working set bounded.

Backups

See Backups. Mongo is the source of truth — back it up daily; Redis can be rebuilt from Mongo.