CHORTLE

Your Friendly SQL Agent

I want to play around with a SQL agent that can be installed in any platform.

Chortle is a multi-tenant Natural Language to SQL (NL2SQL) platform that allows non-technical users to query databases using plain English. It’s designed as a B2B SaaS product where organizations can connect their own databases and enable their teams to get data insights without writing SQL.

Project Highlights:

  • I have 8 services powering this:
  • API Gatway - Single entry point for auth/rate-limiting. Keeps security concerns separate. MY FAVORITE LAYER!
  • Agent Orchestrator - Uses LangGraph to orchestrate the workflow: - Fetch schema → Fetch examples → Generate SQL → Execute → Handle errors (retry up to 3x)
  • Schema Registry - The LLM needs to know table/column names to write SQL. This service formats schema metadata into prompts.
  • Query Executor - Security isolation. Only allows SELECT, enforces timeouts and row limits. Never runs DELETE/UPDATE.
  • LLM Provider - Swap LLM providers without changing other services.
  • InHouse LLM Model Service
  • Vector Store - RAG pattern. Stores example questions + their SQL so similar questions get better results
  • Tenant MAnager - Store tenant databases, API keys, and query history and collects all interactions between services and stores them.

Technologies:

  • Python
  • Docker
  • Node
  • ChromaDB
  • FastAPI
  • Fastify
  • LangGraph
  • LangChain