๐Ÿข

Enterprise Knowledge Agent

Tiered enterprise knowledge & analytics platform ยท FastAPI + React ยท PostgreSQL + pgvector ยท AWS EC2

Live โ€” internal platform, public demo endpoint
Open the Agent

About the Project

A tiered enterprise knowledge and analytics agent platform, co-architected at Clenergy. Rather than sending every question through one retrieval pipeline, it routes each one to the path that can actually answer it: curated exact Q&A, cited document RAG, or constrained Text2SQL.

The routing layer is a self-built orchestrator rather than LangChain, and knowledge only becomes retrievable after human review โ€” the corpus is curated, not whatever was last uploaded.

The analytics path is deliberately narrow: the model never emits SQL, it only adjusts filters and columns inside human-reviewed templates. That constraint is what makes 100% (20/20) end-to-end accuracy reachable, and it is packaged as a reusable cross-department pattern.

FastAPI
React
TypeScript
PostgreSQL + pgvector
MinerU
Cross-Encoder Rerank
Text2SQL
Docker
AWS EC2
100%
Text2SQL Accuracy
20 / 20 end-to-end on the analytics evaluation set
+14pp
Rerank Gain
Cross-encoder reranking over RRF fusion alone, context capped at top-5
3 Tiers
Answering Paths
Curated exact Q&A ยท cited document RAG ยท governed Text2SQL

Answer Path

router
route

Classify the question and pick an answering path

qa
exact_qa

Serve a curated, human-approved question/answer pair when one matches

rag
document_rag

MinerU parse โ†’ heading-aware chunking โ†’ hybrid vector + full-text retrieval

rag
rrf_fusion

Reciprocal rank fusion merges the two retrieval result sets

rag
cross_encoder_rerank

Rerank and cap context at top-5 โ€” +14pp over fusion alone

sql
text2sql

Fill filters and columns into a human-reviewed SQL template โ€” the model never writes raw SQL

router
answer

Synthesise the response with citations back to the reviewed source

Key Features

Tiered Answer Routing

Every question is routed to one of three answering paths โ€” curated exact Q&A first, cited document RAG second, constrained Text2SQL for anything numeric โ€” so each query is served by the cheapest path that can answer it correctly.

Self-Built Orchestrator

The routing and execution layer is written in-house rather than on LangChain, keeping control flow, state, and failure handling explicit and debuggable instead of hidden behind framework abstractions.

MinerU Document Pipeline

Source documents are parsed with MinerU and split by heading-aware chunking, preserving section structure so retrieved passages carry the context a reader needs to trust the citation.

Hybrid Retrieval + RRF + Rerank

Vector and full-text retrieval run side by side, fuse through reciprocal rank fusion, then pass a cross-encoder reranker with the context capped at top-5 โ€” worth +14pp over fusion alone.

Governed Text2SQL

The model never emits SQL. It may only adjust filters and columns inside SQL templates that a human has already reviewed โ€” which is what gets the analytics path to 100% (20/20) end-to-end accuracy.

Human-Reviewed Knowledge

Knowledge becomes retrievable only after human review, so the answer surface is a curated corpus rather than whatever happens to have been uploaded.

Reusable Cross-Department Pattern

Precise QA and Text2SQL as primary paths with RAG as backup, plus function-calling workflow agents closing an "ask โ†’ query โ†’ execute" loop โ€” packaged as a "digital employee" pattern other departments can adopt.

Postgres + pgvector Storage

PostgreSQL with pgvector holds embeddings alongside relational data, with MySQL as an additional analytics source for the Text2SQL path.

Full Tech Stack

Python
Backend and orchestration
FastAPI
REST API layer
Pydantic
Structured output & validation
SQLAlchemy
Database access layer
React
Chat and admin frontend
TypeScript
Typed frontend codebase
PostgreSQL + pgvector
Relational store & embeddings
MySQL
Analytics source for Text2SQL
OpenAI GPT-5
Primary LLM
Cross-Encoder Rerank
Final passage ranking
MinerU
Document parsing
Docker
Containerised services
AWS EC2
Deployment target

Try it Live

Ask a policy question and read the citation, or ask for a number and watch it come back through a reviewed SQL template

Open the Agent

ยฉ 2026 Tony Ye. All rights reserved.