Backend Services¶
The FastAPI backend lives in backend/app/ and exposes REST endpoints consumed by the Next.js frontend, Langfuse, and external tools.
API Surface¶
api/chat.py– orchestrates chat sessions, translates user messages into Cypher or analytics jobs viaservices/graphrag.py.api/graph_info.py– returns schema/metadata generated byai/schema/utilities.api/knowledge_base.py– interfaces with MongoDB to fetch KB entries.api/health.py– readiness/liveness checks for deployment probes.
Service Layer¶
services/chat_sessions.py– manages session state, caching, and fallback logic.services/mongodb.py– connection helpers and CRUD for the knowledge base.services/neo4j_sync.py&update_category_in_neo4j.py– utilities for keeping graph schema/categories synchronized.services/migrate_to_mongodb.py– migration workflow for KB documents.
Integration Points¶
- Langfuse: instrumentation via
ai/llmops/langfuse_client.py. - MCP / GDS Agent: invoked when analytics routing is enabled.
- Environment Flags:
ENABLE_ANALYTICS_AGENT,PROMPT_LABEL, and other settings in.envgovern backend behavior.
Future Enhancements¶
- Auto-generated API reference using
mkdocstringsonce added to the build. - Scenario-based guides for each endpoint (e.g., streaming responses vs. batched).