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.
