Database Setup
Database Setup
MongoDB
Version
flow8 requires MongoDB 5.0+. MongoDB 6+ is recommended for production. The Docker Compose files pin to mongo:latest.
Connection
Set MONGODB_URI and MONGODB_DB in your .env:
MONGODB_URI=mongodb://localhost:27017MONGODB_DB=udFor authenticated MongoDB:
MONGODB_URI=mongodb://user:password@host:27017/ud?authSource=adminFor MongoDB Atlas:
MONGODB_URI=mongodb+srv://user:password@cluster.mongodb.net/?retryWrites=true&w=majorityMONGODB_DB=udCollection Initialization
All collections are created automatically on first run. No schema migration scripts are needed — MongoDB creates collections on first write. The full collection list:
flows # Flow definitionslayers # Flowlet (step) definitionsplays # Flow execution instanceslogs # Execution log entriesgroups # Flow groupscompanies # Organizations (tenants)company_users # User-company associationsuser_groups # User group definitionsaccess # Fine-grained permissionsschedules # Cron trigger schedulesretention_policies # Data retention rulesqueue_jobs # Background job queuechannels # HTTP/WS/MCP channel definitionschannel_routes # Routes within channelschannel_requests # Incoming channel requestskvs # Key-value store entrieslinks # OAuth/API credential storagecomponent_configs # Runtime component configurationssystem_config # Installation-wide settingsinstallations # Deployment instance recordsapps # Module/app catalogaudit # Audit log entriesai_chat # AI chat sessionsai_chat_messages # AI chat messagesai_generation # AI generation recordsflow_test_suites # Test suite definitionsflow_test_cases # Individual test casestest_fixtures # Recorded component I/Oplay_component_events # Component call logs for fixturesRecommended Indexes
flow8 does not auto-create indexes. Add these for production performance:
// flowsdb.flows.createIndex({ companyId: 1, deleted: 1 })db.flows.createIndex({ companyId: 1, permanentId: 1 })
// playsdb.plays.createIndex({ flowId: 1, state: 1, createdAt: -1 })db.plays.createIndex({ companyId: 1, createdAt: -1 })
// layersdb.layers.createIndex({ flowId: 1 })
// kvsdb.kvs.createIndex({ companyId: 1, scopeType: 1, scopeKey: 1, key: 1 }, { unique: true })
// auditdb.audit.createIndex({ companyId: 1, createdAt: -1 })db.audit.createIndex({ createdAt: 1 }, { expireAfterSeconds: 7776000 }) // optional TTL index
// logsdb.logs.createIndex({ playId: 1 })db.logs.createIndex({ flowId: 1, createdAt: -1 })MongoDB Express (Admin UI)
The dev and production compose profiles include MongoDB Express at port 8081:
EXPRESS_USER=adminEXPRESS_PASS=securepasswordAccess at http://localhost:8081 after running compose. Do not expose this port publicly.
Backups
Full Backup with mongodump
mongodump \ --uri="mongodb://localhost:27017" \ --db=ud \ --out=/backups/$(date +%Y%m%d_%H%M%S)
# Compressed backupmongodump --uri="mongodb://localhost:27017" --db=ud --gzip --archive=/backups/ud_$(date +%Y%m%d).gzRestore
mongorestore \ --uri="mongodb://localhost:27017" \ --db=ud \ /backups/20240101_120000/ud/
# From compressed archivemongorestore --uri="mongodb://localhost:27017" --db=ud --gzip --archive=/backups/ud_20240101.gzDocker-based Backup
docker exec mongo mongodump --db=ud --gzip --archive > /backups/ud_$(date +%Y%m%d).gzStorage Directory Layout
The storage/ directory holds all runtime data and is gitignored. In Docker it is mounted as the app-data named volume.
storage/├── db/ # JSON snapshots of certain model data (used by F8DB)├── data/ # User-uploaded and flow-generated files│ └── .files/ # Internal file storage, keyed by company/flow├── logs/ # Application logs written by zerolog└── tmp/ # Temporary files created during flow execution (auto-cleaned)The paths are configurable in .config.yaml:
path: storage: "./storage" tmp: "./storage/tmp" db: "./storage/db" data: root: "./storage/data" files: "./storage/data/.files" logs: "./storage/logs"F8DB (Built-in Database)
flow8 includes a lightweight built-in database (F8DB) backed by MongoDB collections: DBLocalDBDatabase, DBLocalDBTable, DBLocalDBRow. It provides SQL-like operations through flow modules without requiring an external database. Data is stored in MongoDB alongside all other platform data.
PostgreSQL (Optional)
PostgreSQL is supported as an optional component for flow-level database operations (not for platform data). It is included in docker-compose.local.yml on port 5744 for testing. Configure via a DBComponentConfig entry with kind: db and impl: postgresql, providing the connection URI in the component settings.