QueryCortex is a production-grade agentic AI orchestration platform designed to perform deep reasoning, intent understanding, and autonomous decision-making across:
- 📊 Structured data (SQL databases)
- 📄 Unstructured knowledge (PDFs, documents)
- 🔐 Role-aware enterprise environments
Unlike traditional chatbots, QueryCortex thinks before it answers.
It plans execution paths, validates reasoning, selects tools dynamically, and ensures responses are complete, explainable, and safe.
💡 Built for real-world systems where AI must operate across data silos, security boundaries, and business logic.
- System Architecture
- Core Capabilities
- Agentic Intelligence Layer
- Database Intelligence
- Observability & Auditability
- Timezone Handling
- Technology Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- Database Schema Overview
- Document Processing Pipeline
- Security & Compliance
- Video Walkthroughs
- License
- Contact
QueryCortex uses a multi-agent reasoning architecture where each user query flows through an intelligent decision layer.
Depending on intent and context, the system dynamically selects:
- 📄 Semantic document reasoning (Vector-based RAG)
- 🗄️ Schema-aware SQL execution
- 🔁 Hybrid multi-hop reasoning pipelines
This ensures transparent, auditable AI workflows, not black-box responses.
- OAuth2-compliant authentication
- JWT-based access tokens (30-minute expiry)
- Secure logout with server-side invalidation
- Full session lifecycle tracking
- Fine-grained authorization at query & document level
- Role-scoped default knowledge bases via
ROLE_PDFS - Strict isolation between roles and datasets
- Role-aware PDF ingestion
- Semantic chunking and embeddings
- High-recall vector search with grounding
- Auto-loading of default documents at startup
QueryCortex is not a simple chatbot — it is an agent-driven reasoning system.
-
Intent Detection Agent
- Deep NLP-based intent classification
- Distinguishes analytical, informational, and operational queries
-
Auto-Thinking Planning Agent
- Decomposes complex queries into steps
- Plans optimal execution order
-
Routing & Strategy Agent
- Selects SQL, RAG, or Hybrid execution
- Prevents unsafe or invalid query paths
-
Query Completion Checker
- Ensures answers are complete and grounded
- Prevents hallucinations and partial responses
-
Reasoning Validator
- Verifies alignment between intent, execution, and output
- PostgreSQL-backed persistence layer
- SQLAlchemy ORM with schema introspection
- Safe, explainable SQL execution
- Natural-language-to-SQL reasoning with result interpretation
- Full query execution history
- Latency and execution-time metrics
- Login metadata capture (IP, OS, browser, device)
- Secure logging with zero secret exposure
- All timestamps standardized to Asia/Kolkata
- Automatic handling of legacy offset-naive records
| Layer | Technologies |
|---|---|
| Backend API | FastAPI |
| Authentication | OAuth2 · JWT |
| Database | PostgreSQL · SQLAlchemy |
| NLP & RAG | Vector Stores · Semantic Search |
| Agentic AI | Planning Agents · Reasoning Agents |
| Frontend | Vue 3 · Vite · TypeScript |
| Security | RBAC · CORS · Bcrypt |
- Python ≥ 3.8
- PostgreSQL ≥ 12
- Node.js (Vite compatible)
- npm / pnpm
git clone https://github.com/shib1111111/QueryCortex
cd QueryCortexpython -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activatepip install -r requirements.txtcd frontend
npm installDB_URI=postgresql://username:password@localhost:5432/querycortex
JWT_SECRET_KEY=your-secret-key
ANTHROPIC_API_KEY=your-anthropic-api-keyVITE_BASE_URL=http://localhost:8080Best Practices
- Generate JWT secret using:
os.urandom(32).hex() - Default role documents auto-load via
ROLE_PDFS
uvicorn app:app --host 0.0.0.0 --port 8080➡ API: http://localhost:8080
cd frontend
npm run dev➡ UI: http://localhost:5173
- User – identity and role metadata
- UserSession – token lifecycle management
- UserLog – authentication environment data
- Documents – role-based PDFs
- ChatHistory – reasoning trace & timing
- Role-based PDF upload
- Secure storage at
ROOT_DIR/dataset/pdfs/<role> - Embedding generation
- Semantic retrieval during agent execution
- JWT-secured endpoints
- Bcrypt password hashing
- Strict CORS enforcement
- Automatic session expiration
- No sensitive data in logs
-
Agentic AI Architecture https://youtu.be/mWcpJCHRmog
-
End-to-End System Demo https://youtu.be/E_-fb--rXds
Released under the MIT License. See LICENSE for details.
Shib Kumar 📧 shibkumarsaraf05@gmail.com 🐙 GitHub: https://github.com/shib1111111
⭐ If QueryCortex aligns with your vision for intelligent systems, consider starring the repository.
