Background worker service for KnowledgePlane that handles automated tasks like card consolidation and category organization.
This service runs background workers that:
- Card Consolidator: Automatically consolidates related facts into knowledge cards using AI
- Category Organizer: Organizes cards into hierarchical categories using AI
ARANGO_URL- ArangoDB connection URL (default:http://localhost:8529)ARANGO_DB_NAME- Database name (default:knowledgeplane)ARANGO_USER- Database username (default:root)ARANGO_PASSWORD- Database password (default: empty string)OPENAI_API_KEY- OpenAI API key for AI model operations
AI_PROVIDER- AI provider to use (default:openai)OPENAI_MODEL- OpenAI model to use (default:gpt-5.2)NODE_ENV- Environment mode (developmentorproduction)
- Install dependencies:
npm install- Configure environment variables:
Create a
.env.devfile in the app directory:
ARANGO_URL=http://localhost:8529
ARANGO_DB_NAME=knowledgeplane
ARANGO_USER=root
ARANGO_PASSWORD=root
OPENAI_API_KEY=your-openai-api-key
AI_PROVIDER=openai
OPENAI_MODEL=gpt-5.2- Ensure database is running: The worker requires an ArangoDB instance to be running and accessible.
npm run devThis runs the worker in watch mode with hot reload.
- Build the application:
npm run build- Start the worker:
npm startThe worker can be run using Docker Compose. See the root infra/docker-compose.yml for configuration.
- Interval: Runs every 5 minutes
- Purpose: Finds unconsolidated facts and groups them into knowledge cards
- Process:
- Finds facts not yet in any card
- Groups facts by knowledge context
- Uses graph traversal to find related facts
- Uses AI to consolidate related facts into a card
- Creates or updates cards with consolidated content
- Interval: Runs every 30 minutes
- Purpose: Organizes uncategorized cards into hierarchical categories
- Process:
- Finds cards without categories
- Groups cards by knowledge context
- Uses AI to suggest a category structure
- Creates categories and assigns cards to them
The worker handles SIGTERM and SIGINT signals for graceful shutdown, stopping all workers before exiting.
The worker logs to stdout with information about:
- Worker startup and shutdown
- Processing status
- Errors and warnings
@knowledgeplane/db- Database models and connection@knowledgeplane/aimodel- AI model client for OpenAI integration