Overview
The Knowledge Graph (KG) service is a foundational microservice in FlowX.AI’s AI Agent ecosystem that provides a distributed graph database solution for managing AI Agent state, enabling Retrieval-Augmented Generation (RAG), and facilitating multi-agent collaboration.The Knowledge Graph service uses DGraph as the underlying graph database technology and is essential for AI Agent operations, conversation state management, and cross-agent data sharing.
Key Capabilities
AI Agent State Management
Persistent storage and retrieval of AI Agent states across horizontal scaling scenarios
RAG Support
Enhanced LLM prompts with domain-specific data through efficient graph-based retrieval
Multi-Agent Collaboration
Transparent agent integration with shared context and state management
Connected Data
Property graph implementation for scalable, queryable data relationships
Infrastructure Prerequisites
Before setting up the Knowledge Graph service, ensure the following components are installed and configured:Core Requirements
Core Requirements
Component | Version | Purpose |
---|---|---|
Docker Engine | 17.06+ | Container runtime |
DGraph | Latest | Graph database backend |
Kafka | 2.8+ | Event-driven communication |
Redis | 6.0+ | Caching layer |
PostgreSQL | 13+ | Metadata storage (Designer phase) |
DGraph Cluster Requirements
DGraph Cluster Requirements
For production deployments:
- Minimum 3 Alpha nodes - Store graph data and handle queries
- Minimum 3 Zero nodes - Manage cluster state and coordination
- Persistent storage - For data durability
- Network connectivity - Between all nodes in the cluster
FlowX Dependencies
FlowX Dependencies
- Process Engine - Must be deployed and running
- Advancing Controller - Required for workflow integration
- Existing Kafka instance - Used by other FlowX services
- Redis instance - Shared with other FlowX microservices
Configuration Parameters
Core Service Configuration
Core Service Settings
DGraph Cluster Configuration
DGraph Settings
Integration Configuration
FlowX Integration
Security Configuration
- Basic Authentication
- Enterprise Security
Basic Auth (DGraph OSS)
Deployment
Docker Compose Deployment
Kubernetes Deployment
Performance Benchmarks
Based on synthetic testing with realistic AI Agent workloads:Read Performance
20-45ms average response time
- Query complexity: Multi-hop graph traversals
- Concurrent threads: 10-15
- Data scale: 4M+ nodes, 8M+ relationships
Write Performance
10-20ms per node average
- Includes relationship creation
- Batch operations supported
- ACID transaction guarantees
Test Data Scale
Synthetic Data Stats
Health Checks and Monitoring
Service Health Endpoints
Health Check URLs
Key Metrics to Monitor
DGraph Cluster Metrics
DGraph Cluster Metrics
- Alpha node health - All nodes responding
- Zero node health - Cluster coordination status
- Memory usage - RAM consumption per node
- Disk usage - Storage utilization
- Query latency - Response time percentiles
Knowledge Graph Service Metrics
Knowledge Graph Service Metrics
- API response times - HTTP request latency
- Kafka consumer lag - Message processing delay
- Redis cache hit rate - Caching effectiveness
- Error rates - Failed requests percentage
Schema Management
The Knowledge Graph service automatically manages schemas for AI Agent operations:Core Schema Types
- Conversation Schema
- AI Agent Schema
- RAG Schema
Conversation Types
Troubleshooting
Cluster Startup Issues
Cluster Startup Issues
Problem: DGraph nodes fail to join clusterSolutions:
- Check network connectivity between nodes
- Verify Zero nodes start before Alpha nodes
- Ensure persistent volumes are properly mounted
- Check for port conflicts (5080, 8080, 9080)
Debug Commands
Performance Issues
Performance Issues
Problem: Slow query response timesSolutions:
- Increase memory allocation for Alpha nodes
- Add appropriate indexes for frequent queries
- Optimize query patterns to reduce traversal depth
- Consider adding more Alpha nodes for read scaling
Performance Tuning
Data Consistency Issues
Data Consistency Issues
Problem: Inconsistent data across cluster nodesSolutions:
- Verify all Zero nodes are healthy
- Check for network partitions
- Monitor Raft consensus logs
- Perform cluster backup and restore if needed
Consistency Checks
Security Best Practices
For production deployments, implement these security measures:
-
Network Security
- Use private networks for inter-node communication
- Implement firewall rules for DGraph ports
- Enable TLS for all communications
-
Authentication & Authorization
- Use DGraph Enterprise ACLs for fine-grained access control
- Implement JWT-based authentication for API access
- Rotate authentication tokens regularly
-
Data Protection
- Enable encryption at rest (DGraph Enterprise)
- Implement backup encryption
- Use secure communication protocols
-
Monitoring & Auditing
- Enable audit logging (DGraph Enterprise)
- Monitor for suspicious query patterns
- Set up alerts for security events
Backup and Recovery
Automated Backup (DGraph Enterprise)
Backup Configuration
Export/Import (DGraph OSS)
Manual Export/Import
Developer Guidelines
Schema Contribution Standards
The Knowledge Graph service acts as “Database as a Service” for all FlowX microservices. Follow these guidelines when contributing schemas:Naming Conventions
Naming Conventions
Type Naming Rules:
- Use PascalCase for all type definitions
- Prefix types with the microservice name to avoid conflicts
- Follow the pattern:
{MicroserviceName}{ActualDataType}
Examples
Schema Organization
Schema Organization
File Structure:Organization Rules:
- Place schemas in the most specific microservice folder
- Use descriptive file names that reflect the domain
- Keep common types in
/common.graphql
only if truly general-purpose
Indexing Best Practices
Indexing Best Practices
Add indexes only for properties that are frequently queried:Index Types:
Indexing Examples
@index(exact)
- For exact matches (IDs, enum values)@search(by: [fulltext])
- For text search@embedding @search(by: ["hnsw"])
- For vector similarity@index(day)
- For date-based queries
Breaking Changes Prevention
Breaking Changes Prevention
❌ Avoid These Breaking Changes:
- Removing existing fields from types
- Changing field types (String to Int)
- Removing types that are in use
- Changing required fields to optional or vice versa
- Adding new optional fields
- Adding new types
- Adding new indexes
- Extending enums with new values
A schema registry will be implemented to automatically detect breaking changes in the future.
Schema Deployment Process
- Local Development
- Production Deployment
Local Schema Management
Data Contribution Patterns
The Knowledge Graph supports two data pipeline patterns:Synchronous Pipeline
Use for: Critical data requiring immediate consistency
- Real-time AI Agent state updates
- User interaction data
- Process execution state
- Strong consistency guarantees
- Immediate availability
- Higher latency tolerance required
Asynchronous Pipeline
Use for: Bulk data processing and analytics
- Historical conversation data
- Training data ingestion
- Background embeddings generation
- Eventual consistency
- Higher throughput
- Lower resource impact
Currently only synchronous pipeline is supported
KAG RPC Interface
The Knowledge Graph provides a gRPC interface for cross-language compatibility:KAG Service Definition
Client Integration Patterns
Interface-Based Query Resolvers:- Database Agnostic: Easy to switch between graph databases
- Testable: Mock implementations for unit testing
- Maintainable: Changes confined to specific implementations
- Consistent: Same semantics across different backends
Multi-Database Support Strategy
Direct query translation between graph databases (DGraph ↔ Neo4j ↔ JanusGraph) is not practical due to fundamental differences in query languages and capabilities.
- Abstract Business Logic: Use repository interfaces for domain operations
- Database-Specific Implementations: Separate implementation for each graph DB
- Consistent Data Models: Maintain same semantic meaning across databases
- Configuration-Based Selection: Choose database implementation at runtime
Database Selection Config
Next Steps
After successfully deploying the Knowledge Graph service:Schema Development
Learn how to contribute schemas and follow development guidelines
AI Agent Integration
Configure AI Agents to use the Knowledge Graph for state management
RAG Configuration
Set up Retrieval-Augmented Generation with vector search
Multi-Agent Setup
Enable collaboration between multiple AI Agents
Data Migration
Migrate existing data to the Knowledge Graph
Monitoring Setup
Configure comprehensive monitoring and alerting
Need Help? Check the troubleshooting section above or contact the FlowX.AI support team for assistance with your Knowledge Graph deployment.