Agentic AI for Interactive Business Analytics & Reasoning
Agent Service Edition (API-first)
Built with:
Conversational Business Analytics (CBA) is an experimental, open-source system for building agentic, LLM-driven analytical workflows that can reason, compute, observe results, and expose those capabilities via a service-oriented API.
This branch focuses on serving the agent as a FastAPI-based backend, intended to be consumed by one or more external user interfaces (e.g. Streamlit, web apps, notebooks).
The system enables:
- natural-language business queries,
- explicit analytical planning and execution,
- structured reasoning over relational data,
- observation-driven correction loops.
This project is a research and learning platform for agentic analytics — not a production BI tool.
This branch provides a cleanly separated architecture, with emphasis on:
- isolating the agent core from presentation concerns,
- serving agent capabilities via a stable HTTP API,
- improving observability and debuggability of agent workflows,
- and enabling multiple UI clients without coupling.
The system is built around a Binary-Responsibility Agent Graph, guided by the following principles:
Each node has at most two outgoing paths, ensuring:
- localized decisions,
- predictable control flow,
- traceable failure modes.
Each node performs one clearly defined task, such as:
- intent interpretation,
- context distillation,
- request classification,
- planning,
- execution,
- observation.
This limits prompt complexity and error propagation.
Analytical reasoning follows a consistent loop:
- Plan — generate a constrained, structured plan
- Execute — run code or actions in a controlled environment
- Observe — validate semantic and functional correctness
Failures trigger targeted correction loops rather than global retries.
.
├── agent/ # LangGraph-based agent and node definitions (core logic)
├── api/ # FastAPI service layer exposing the agent
├── context/ # Runtime context shared across agent nodes
├── docker_script/ # Database initialization & synthetic data seeding
├── language_model/ # LLM abstraction layer
├── memory/ # Conversational and short-term memory persistence
└── notebook/ # Agent graph export from get_mermaid_graph.ipynb-
🧠 Agentic Reasoning Pipeline
Intent → classification → planning → execution → observation.
-
📊 Business Analytics Focus
Supports descriptive, diagnostic, predictive, and inferential analysis.
-
🧾 Structured LLM Outputs
Enforced via Pydantic schemas.
-
🧩 LangGraph-based Orchestration
Explicit state transitions and execution control.
-
🐳 Containerized Agent Service
FastAPI-based backend, UI-agnostic
-
🔒 Sandboxed Code Execution
Analytical Python code runs in isolated E2B sandbox environments, separated from the OLTP data source.
-
🗃️ External PostgreSQL Integration
-
🧪 Synthetic Data Seeding for Development
You will need:
- Docker
- Docker Compose
- Git
No local Python installation is required if using Docker.
This project uses environment variables for configuration.
-
Copy the example file:
cp .env.example .env
-
Fill in required values:
- API keys (Groq, E2B, optional LangSmith)
- PostgreSQL credentials (defaults work for Docker)
AGENT_API_PORT(default: 8000)
docker compose up --buildOnce running, the agent API will be available to test with Swagger docs:
http://localhost:8000/docs#/You can try using cURL to test the agent stream endpoint.
curl -X 'POST' \
'http://localhost:8000/agent/stream' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"input": "What is the best-selling product in March 2024?"
}'Health check endpoint:
GET /healthThis project depends on an external PostgreSQL database to simulate business data.
- Local CSV datasets live in
docker_script/datasets/(seedocker_script/datasets/DATASETS.md) - The script
external_database_factory.py:- selects a dataset via
EXTERNAL_DATASET, - infers the PostgreSQL schema from CSV columns,
- loads rows into a fixed table name (
EXTERNAL_DB_TABLE_NAME, defaultbusiness_data), - runs automatically on container startup if enabled.
- selects a dataset via
Controlled via environment variables:
ENABLE_EXTERNAL_DB_SEEDING=true
EXTERNAL_DATASET=3
EXTERNAL_DB_TABLE_NAME=business_dataEXTERNAL_DATASET accepts 1–5 or dataset_1 … dataset_5. Change it and restart the container to switch the active business domain.
This allows:
- zero-setup onboarding for new users,
- reproducible analytical scenarios across multiple business domains,
- safe experimentation without real business data.
- This project prioritizes clarity over cleverness
- Explicit state > implicit magic
- If something is ambiguous, it should probably be a schema
- If something is implicit, it should probably be a graph edge
- UI concerns do not belong in the agent core or service layer
