Overview
Genie Helper runs 7 services managed by PM2. This page documents each service, their ports, PM2 configuration, and how they interact.Service Architecture
Services Table
Service Details
1. AnythingLLM (anything-llm)
Port: 3001Purpose: Core AI agent, chat API, MCP server orchestration Features:
- REST API for chat, workspaces, documents
- WebSocket support for streaming responses
- Embed widget hosting (
/embed/anythingllm-chat-widget.min.js) - MCP server auto-boot (Directus, Ollama, Stagehand)
- Action Runner plugin for pre-built flows
- Custom endpoints: registration, RBAC sync, credentials, queue management
server/index.js- Express entrypointserver/utils/boot/index.js- MCP server boot logicserver/utils/actionRunner/- Action flow executorstorage/- Persistent data, documents, vector store
- Ollama (11434) for LLM inference
- Directus (8055) for data storage
- Stagehand (3002) for browser automation
2. Directus CMS (agentx-cms)
Port: 8055Purpose: Data layer, collections, authentication, REST API Key Collections:
creator_profiles- Platform accounts with encrypted credentialsscraped_media- Content with engagement metricsscheduled_posts- Post queue (polled by media worker every 60s)media_jobs- BullMQ job recordshitl_sessions- Human-in-the-loop login requestsplatform_sessions- Encrypted browser cookiestaxonomy_dimensions- 6 super-concept classification systemtaxonomy_mapping- 3208 classified tagsfan_profiles- Fan engagement dataaction_flows- Action Runner flow definitionsagent_audits- ACTION execution logs
- JWT tokens for end-users (React SPA)
- Static admin token for server-to-server API calls
- Platform credentials encrypted with AES-256-GCM
encryptJSON()/decryptJSON()inserver/utils/credentialsCrypto.js- No encryption keys in browser - server-side only
3. Stagehand (stagehand-server)
Port: 3002Purpose: Browser automation for platform scraping and posting Capabilities:
- Headless Chrome sessions with stealth mode
- Navigate, click, extract, screenshot
- Cookie management (set/get)
- Session lifecycle (start/close)
- Media worker jobs (scrape, publish)
- Stagehand MCP server (9 tools for AI agent)
- ~300MB RAM per active browser session
- ~33 concurrent sessions max (with 10GB available RAM)
4. Dashboard (genie-dashboard)
Port: 3100 (if using serve, otherwise static files served by Nginx)Purpose: React SPA - marketing, authentication, creator dashboard Routes:
- Public:
/,/pricing,/about,/register,/login - Authenticated:
/app/dashboard,/app/media,/app/calendar,/app/fans,/app/analytics,/app/platforms,/app/settings - Admin:
/admin(Directus + AnythingLLM iframes),/view-as(impersonation)
- AI chat widget (AnythingLLM embed) on all
/app/*routes - Embed ID:
cf54a9c0-224c-469d-b97b-5dc8095eac82 - Directus JWT auth (auto-refresh, sessionStorage for impersonation)
- Invite-gated registration
- Theme switcher (ImpactGenie brand palette)
dashboard/dist/ served by Nginx at document root.
5. Media Worker (media-worker)
Port: None (BullMQ consumer)Purpose: Background job processing via Redis/BullMQ Job Types:
scrape_profile- Stagehand OF login + data extractionpublish_post- Cross-platform posting via Stagehandapply_watermark- ImageMagick watermarking (~100ms)create_teaser- FFmpeg video preview (~30s CPU per clip)post_scheduler- Pollsscheduled_postscollection every 60s
- Concurrency: 3 jobs (configurable via
WORKER_CONCURRENCY) - Redis connection:
127.0.0.1:6379 - Scheduler interval: 60000ms (60s)
- FFmpeg clip generation: ~30s CPU per clip (real bottleneck)
- Watermark: ~100ms (effectively zero cost)
- Stagehand sessions: ~300MB RAM each
6. Collector (anything-collector)
Port: NonePurpose: Document ingestion for AnythingLLM vector store Processes:
- Monitors
storage/documents/for new files - Chunks and embeds documents
- Updates vector store for RAG retrieval
bge-m3:latest (via Ollama)
7. Ollama (System Service)
Port: 11434Purpose: Local LLM inference engine Installed Models:
Managed by: systemd (not PM2)
- CPU-only: ~33s first token for agent mode (qwen-2.5)
- GPU recommended for production
PM2 Configuration
Starting All Services
PM2 Ecosystem File (Recommended)
Createecosystem.config.cjs in project root:
PM2 Commands
Status and Monitoring
Restart and Reload
Stop and Delete
Flush Logs
Service Interactions
Data Flow
-
User → Dashboard (React SPA)
- User interacts with UI at
geniehelper.com/app/* - Dashboard makes API calls to
/api/directus/and/api/llm/
- User interacts with UI at
-
Dashboard → Directus (via Nginx proxy)
- CRUD operations on collections
- JWT authentication
- File uploads
-
Dashboard → AnythingLLM (via Nginx proxy)
- Chat messages via embed widget
- Streaming responses (SSE)
- Document management
-
AnythingLLM → MCP Servers
- Directus MCP: 17 tools (CRUD, flows, users, files)
- Ollama MCP: 3 tools (generate, chat, list-models)
- Stagehand MCP: 9 tools (browser sessions, navigation, extraction)
-
AnythingLLM → Ollama
- LLM inference requests
- Embeddings generation
- Model selection based on task
-
Media Worker → Directus
- Poll
scheduled_postsevery 60s - Read
media_jobsfor processing - Update job status and results
- Poll
-
Media Worker → Stagehand
- Create browser sessions
- Navigate to platforms
- Extract data or publish content
-
Media Worker → ImageMagick/FFmpeg
- Apply watermarks (ImageMagick)
- Generate video teasers (FFmpeg)
Authentication Flow
- User registers via
/register(React route) - Dashboard calls
/api/llm/api/register(server-side proxy) - AnythingLLM creates Directus user via
DIRECTUS_ADMIN_TOKEN - User logs in via Directus JWT
- JWT stored in localStorage, sent with all API requests
- RBAC sync webhook keeps AnythingLLM users in sync with Directus roles
Platform Scraping Flow
- User connects platform via
/app/platforms - Browser extension or manual cookie upload
- Encrypted cookies stored in
platform_sessions - User clicks “Scrape Profile” button
- Dashboard creates
media_jobsrecord - Media worker picks up job from BullMQ
- Worker decrypts credentials, starts Stagehand session
- Stagehand navigates, extracts data
- Worker stores results in
scraped_media - Dashboard polls job status, updates UI
