Skip to content

Store & Auth Configuration

EchoFox has two pluggable persistence layers:

  • Auth — Baileys session credentials (signal keys, sender keys, encryption state)
  • Store — message bodies, group metadata, edits/reactions/receipts, subscribers

Both support multiple backends. They can run on different backends — e.g. auth on local SQLite while store is on PostgreSQL.

Auth backends

js
auth: {
  method: 'MULTIFILE',  // 'MULTIFILE' | 'SQLITE' | 'REDIS' | 'POSTGRES'

  // For SQLITE
  sqlitePath: './src/store/auth.db',

  // For REDIS
  redisUrl: 'redis://localhost:6379',

  // For POSTGRES
  postgresUrl: 'postgresql://postgres:postgres@localhost:5432/echofox',
},
MethodWhen to use
MULTIFILEDefault. Files in src/<sessionName>/. Fastest, simplest.
SQLITEWhen you want one file containing both auth + store data
REDISMulti-instance failover (auth shared across multiple worker processes)
POSTGRESSame, when you already run Postgres for other workloads

Store backends

js
storeDB: {
  type: 'SQLITE',  // 'SQLITE' | 'POSTGRES' | 'MONGODB' | 'REDIS'

  sqlitePath:  './src/store/runtime/wa.db',
  postgresUrl: 'postgresql://postgres:postgres@localhost:5432/echofox',
  mongoUri:    'mongodb://localhost:27017/echofox',
  redisUrl:    'redis://localhost:6379',

  runMigrationsOnBoot: true,
},

Backend trade-offs

BackendProsCons
SQLiteZero ops, fastest single-node, WAL durabilityOne process at a time
PostgresMulti-instance, mature, JSONB for metaAdds operational dependency
MongoDBSchemaless flexibility, easy to inspect via CompassLess compact than pg
RedisLowest-latency, ideal for ephemeral subscriber dataVolatile by default

Backend feature parity

All 4 backends implement the same interface (src/store/db.js docs the contract):

  • Messages, chats, contacts, groups, edits, reactions, receipts, deletions
  • Per-service subscriptions with arbitrary meta (Phase 3+)
  • Item-dedup tracker (service_sent_items)
  • Statistics + gauges

A backend swap (e.g. SQLite → Postgres) is config-only; no code change.

Migrations

When runMigrationsOnBoot: true (default), the lifecycle's selectStore() runs all pending migrations after construction and before exposing the store. Failures abort boot loudly.

Manual control:

bash
npm run migrate              # apply all pending
npm run migrate -- --status  # show status only

Migration files live in src/store/migrations/<backend>/NNN_slug.js and are versioned monotonically per backend.

  • Solo personal bot: auth: MULTIFILE + storeDB: SQLITE (zero infra)
  • Small org (one host): same as above with regular backups
  • Multi-instance failover: auth: POSTGRES + storeDB: POSTGRES
  • High-volume (many groups, message storage important): storeDB: POSTGRES with the batched writes (v0.4.6)

Released under the AGPL-3.0 License.