Agentic database assistant: FastAPI backend with an MCP-style bridge to PostgreSQL, LangChain-ready reasoning loop, and a React chat UI that streams responses over WebSockets.
Windows (PowerShell):
.\start.ps1Windows (Batch):
start.batBoth scripts will open separate windows for backend and frontend services.
- Copy
.env.exampleto.envand adjust secrets. docker compose up --build- Backend: http://localhost:8000/docs, WebSocket: ws://localhost:8000/ws/chat
- Connect your frontend dev server to ws://localhost:8000/ws/chat (proxy already set in vite config).
cd backend
python -m venv .venv
. .venv/Scripts/activate # Windows
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000cd frontend
npm install
npm run dev -- --host --port 5173cd backend
pytest- FastAPI app exposes
/schema,/health, and/ws/chatfor streaming agent replies. - MCP bridge: schema discovery via SQLAlchemy inspector; read-only execution guard on SELECT statements.
- Agent stub streams incremental text; swap in a LangChain chain to generate SQL and call the bridge.
- React + Vite UI with WebSocket streaming and minimal styling; room to add Chart.js rendering when numeric series are returned.
DATABASE_URLshould point at your Postgres instance (docker-compose provides one atpostgresql://postgres:postgres@db:5432/sql_genie).OPENAI_API_KEYoptional placeholder; wire into the agent when adding a real LLM.- The LLM API key entries in
.envare empty by default. Fill in the appropriate key (OpenAI or Anthropic) to make LLMs accessible. ALLOWED_ORIGINScomma-separated origins for CORS.