TraceCore is a production-style AI decision engine. It is designed to feel like a real backend system instead of a chatbot demo:
- FastAPI API with JWT and API key authentication
- PostgreSQL-ready SQLAlchemy persistence
- LangGraph workflow orchestration with LangChain prompts
- Redis-backed caching and rate limiting with in-memory fallback
- PyTorch-based query classification and evidence reranking
- Background jobs for ingestion and post-run learning signals
- Evaluation, feedback capture, and run history endpoints
- Language and API: Python, FastAPI, Uvicorn
- Auth: JWT bearer tokens, API key authentication
- Database: SQLAlchemy ORM, PostgreSQL-ready schema, SQLite local dev mode
- Caching and limits: Redis with in-memory fallback
- AI orchestration: LangGraph, LangChain
- ML component: PyTorch query classification and evidence reranking
- Background processing: FastAPI background tasks
- Frontend: bundled HTML, CSS, and vanilla JavaScript control panel
- Local infra: Docker, Docker Compose
- Testing: pytest, FastAPI TestClient
- A user registers or logs in.
- The user submits a protected query to
/v1/query. - TraceCore stores the request and runs a LangGraph workflow.
- The workflow classifies the query, retrieves evidence, reasons over it, and scores the response.
- The system logs runs, tool calls, outputs, feedback, and evaluation metadata.
- Expensive responses can be served from cache on later calls.
POST /auth/registerPOST /auth/loginGET /auth/mePOST /v1/documents/ingestPOST /v1/queryGET /v1/runsPOST /v1/feedbackGET /healthGET /control/statusPOST /control/pausePOST /control/resumePOST /control/stop
- Copy
.env.exampleto.env. - Install the app with
pip install -e .[dev]. - Run the API with
python -m uvicorn app.main:app --reload. - Open
http://127.0.0.1:8000/uifor the guided control panel. - Open
http://127.0.0.1:8000/docsif you want the raw Swagger view too.
This path uses SQLite by default and falls back to in-memory caching if Redis is not running.
- Start Docker Desktop.
- Run
docker compose up postgres redis -d. - Change
DATABASE_URLin.envtopostgresql+psycopg://tracecore:tracecore@localhost:5432/tracecore. - Start the API with
python -m uvicorn app.main:app --reload.
Run tests with python -m pytest.
TraceCore now exposes a control-plane-friendly runtime contract:
GET /control/statusPOST /control/pausePOST /control/resumePOST /control/stop
pause blocks new query, ingest, and feedback intake while keeping health and observability online. stop places the service in maintenance mode so business routes return 503 until resume is called, while operator login, health, and control access remain available.
If you want to protect these endpoints, set CONTROL_API_TOKEN in .env and send it as a bearer token.
- By default the workflow uses a deterministic mock reasoner so tests stay stable.
- If
OPENAI_API_KEYis set andMOCK_LLM_ENABLED=false, the reasoning stage will uselangchain-openai. - The default retrieval path uses stored documents and prior session history.