Skip to main content

Overview

Directus CMS serves as the primary data layer for Genie Helper, providing:
  • Headless CMS: RESTful API for all application data
  • Authentication: User management, JWT tokens, role-based access control
  • Collections: 11 core collections for creators, media, jobs, and platform data
  • Flows: Low-code automation workflows (scraping, media processing, notifications)
  • Admin Panel: Visual interface for data management and debugging
Service Details:
  • Port: 8055 (proxied to /api/directus/ in production)
  • Process: pm2 agentx-cms
  • Admin URL: https://geniehelper.com/admin (iframe in dashboard)

Architecture Integration

Data Flow

MCP Integration

The Directus MCP Server exposes 17 tools to the AnythingLLM agent: Location: /home/daytona/workspace/source/scripts/directus-mcp-server.mjs:1 Tools: Agent Use Case:

Key Collections

Genie Helper uses 11 core Directus collections:

1. creator_profiles

Purpose: Platform account credentials and scrape configuration Encryption: The credentials field uses server-side AES-256-GCM encryption via credentialsCrypto.js.

2. scraped_media

Purpose: Content library with engagement metrics Taxonomy Integration: See taxonomy_dimensions collection for concept definitions.

3. scheduled_posts

Purpose: Cross-platform post queue Worker Integration: The post_scheduler worker polls this collection every 60s for pending posts where scheduled_for <= NOW().

4. media_jobs

Purpose: BullMQ job tracking for media operations Dashboard Polling: Dashboard uses this collection to show real-time job progress.

5. hitl_sessions

Purpose: Human-in-the-loop login requests Trigger: Created when scraping fails due to missing cookies. See Browser Extension for HITL flow.

6. platform_sessions

Purpose: Encrypted browser cookies for automated login Security: Cookies encrypted with same credentialsCrypto.js module as creator_profiles.credentials.

7. taxonomy_dimensions

Purpose: 6 super-concept content classification system Current Dimensions (from README):
  1. Intimacy Level
  2. Production Quality
  3. Content Type
  4. Audience Appeal
  5. Platform Fit
  6. Engagement Potential

8. taxonomy_mapping

Purpose: 3,208 classified tags across 6 concepts AI Classification: The taxonomy-tag Action Runner flow uses this mapping to auto-classify new content.

9. fan_profiles

Purpose: Fan engagement data

10. action_flows

Purpose: Action Runner flow definitions Action Runner: When agent outputs [ACTION:slug:{"params"}], the action-runner plugin executes the matching flow. Seeded Flows (from README):
  • scout-analyze: Scrape URL + AI analysis
  • taxonomy-tag: Auto-classify content
  • post-create: Draft platform-specific post
  • message-generate: Fan engagement message
  • memory-recall: Search stored data + summarize
  • media-process: Queue media job (watermark, teaser, compress)

11. agent_audits

Purpose: Action execution logs Debugging: Use this collection to debug why actions failed or missed.

Directus Flows

Directus Flows are low-code automation workflows triggered by:
  • Webhooks: External HTTP POST triggers
  • Schedule: Cron-based triggers
  • Events: Collection CRUD events (insert, update, delete)
  • Manual: Triggered via trigger-flow MCP tool or API

Example Flow: Platform Scraping

Flow Name: platform_scrape_flow Trigger: Manual (via trigger-flow MCP tool or dashboard button) Steps:
  1. stagehand_cookie_login: Inject cookies from platform_sessions + navigate to creator profile
  2. stagehand_extract: Extract profile stats (followers, earnings, recent posts)
  3. create-item (Directus): Insert/update scraped_media records
  4. stagehand_close: End browser session
Seeding Script: /home/daytona/workspace/source/scripts/hitl/seed_platform_scrape_flow.mjs:1

Creating Custom Flows

Directus admin panel provides a visual flow builder:
  1. Navigate to https://geniehelper.com/admin → Flows
  2. Click “Create Flow”
  3. Select trigger type
  4. Add operations:
    • Webhook / HTTP Request: Call external APIs
    • Run Script: Execute Node.js code
    • Condition: Branching logic
    • Create/Update/Delete Data: Directus CRUD
    • Send Notification: Email, push, webhook
    • Trigger Another Flow: Flow chaining

Authentication & RBAC

User Roles

Genie Helper uses Directus roles:

RBAC Sync

User creation in dashboard automatically syncs to Directus: Sync Endpoint: /api/rbacSync (webhook triggered by Directus user creation) Flow:
  1. User registers in dashboard /register
  2. Dashboard calls /api/register (proxy to Directus /users with admin token)
  3. Directus creates user + triggers RBAC sync webhook
  4. Sync webhook creates user_personas collection record
  5. User can now log in and access dashboard
Related Files:
  • /home/daytona/workspace/source/server/endpoints/api/register.js:1
  • /home/daytona/workspace/source/server/endpoints/api/rbacSync.js:1

JWT Tokens

Directus uses JWT for authentication:
  • Access Token: Short-lived (15 min), used for API requests
  • Refresh Token: Long-lived (7 days), used to renew access token
Dashboard Storage:
  • Access token: localStorage.getItem('directus_token')
  • Refresh token: Auto-refreshed via Directus SDK
Admin Token: Server-side operations use DIRECTUS_ADMIN_TOKEN env var for elevated permissions.

API Proxy

Production traffic routes through nginx proxy: Nginx Config (Plesk):
Dashboard API Client:

Environment Variables

Directus requires these env vars:

Debugging

Check Directus Logs

Restart Directus

Query Collections via CLI

Access Admin Panel

URL: https://geniehelper.com/admin Credentials:
  • Email: admin@geniehelper.com
  • Password: (see README admin credentials section)
Features:
  • Browse collections
  • Edit records
  • View flows
  • Monitor activity logs
  • Manage users and roles

Performance Tips

Enable Caching

Directus supports Redis caching for improved performance: Env Vars:

Optimize Queries

Use fields parameter to reduce payload size:

Indexed Fields

Ensure frequently queried fields have database indexes:
  • creator_profiles.user_id
  • scraped_media.creator_profile_id
  • scheduled_posts.scheduled_for
  • media_jobs.status
  • platform_sessions.platform