MATIH Platform is in active MVP development. Documentation reflects current implementation status.
12. AI Service
Integrations
Integration Overview

Integration Overview

The AI Service integrates with a broad set of internal platform services and external systems through event-driven, real-time, and request-response patterns. These integrations enable feedback loops, data lineage tracking, real-time streaming, personalization, and copilot capabilities that extend the core conversational analytics engine.


Integration Map

IntegrationProtocolDirectionPurpose
KafkaaiokafkaBidirectionalEvent streaming for feedback, agent thinking, learning signals
WebSocketFastAPI WebSocketServer to ClientReal-time streaming of agent responses and status updates
Feedback/RLHFREST + KafkaInboundUser feedback collection and reinforcement learning signals
Data LineageREST + KafkaOutboundQuery lineage tracking and column-level provenance
dbtRESTInboundSemantic model import and metric definitions
PersonalizationInternalBidirectionalUser preference learning and response customization
AI CopilotREST + WebSocketBidirectionalContextual assistance and proactive suggestions

Event-Driven Architecture

The AI Service uses Apache Kafka as the backbone for asynchronous event processing. Events flow through the following topics:

TopicProducerConsumerSchema
ai-feedback-eventsAI ServiceFeedback PipelineFeedbackEvent
ai-learning-signalsFeedback PipelineModel TuningLearningSignal
ai-insightsAnalysis AgentNotification ServiceInsightEvent
agent-thinking-eventsOrchestratorContext GraphThinkingEvent
agent-decision-eventsRouter AgentAnalytics StoreDecisionEvent
agent-trace-eventsAll AgentsTrace StoreTraceEvent
agent-metrics-eventsQuality MetricsMonitoringMetricsEvent
query-lineage-eventsSQL AgentLineage ServiceLineageEvent
audit-eventsAll (read-only)ComplianceAuditEvent

Configuration

All integration endpoints are configured through environment variables bound to Pydantic Settings:

# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
KAFKA_SECURITY_PROTOCOL=PLAINTEXT
KAFKA_CONSUMER_GROUP=ai-service
 
# WebSocket
WS_MAX_CONNECTIONS=100
WS_HEARTBEAT_INTERVAL=30
 
# External services
QUERY_ENGINE_URL=http://query-engine:8080
CATALOG_SERVICE_URL=http://catalog-service:8086
SEMANTIC_LAYER_URL=http://semantic-layer:8086

Graceful Degradation

All integrations follow a graceful degradation pattern. If an external dependency is unavailable, the AI Service continues operating with reduced functionality rather than failing entirely:

IntegrationDegraded Behavior
Kafka unavailableFeedback events are buffered in memory with a bounded queue
WebSocket failureFalls back to HTTP polling
Lineage service downLineage events are dropped silently
dbt unavailableUses cached semantic models
Personalization failureReturns default non-personalized responses

Detailed Sections

Each integration is covered in depth in its own section:

SectionWhat You Will Learn
Kafka Event StreamingTopic configuration, producer/consumer patterns, schema management
WebSocket CommunicationConnection lifecycle, message protocol, heartbeats
Feedback and RLHFFeedback collection, learning signals, model improvement
Data LineageQuery provenance, column-level tracking, lineage graph
dbt IntegrationSemantic model import, metric definitions, materialization
Personalization EngineUser profiles, preference learning, adaptive responses
AI CopilotContextual suggestions, proactive assistance, copilot modes