AI-powered Natural Language Interface for MongoDB
NeuroQuery allows users to query MongoDB databases using plain English instead of writing complex queries.
It combines AI query generation, schema inference, validation, and explainability to provide a safe and transparent way to interact with MongoDB.
Built for developers, analysts, and non-technical users, NeuroQuery transforms MongoDB into an intelligent self-service data assistant.
✅ Natural Language Queries
Ask questions like:
"Show customers who signed up last month"
✅ Automatic Schema Inference
NeuroQuery samples MongoDB documents to understand fields and data types.
✅ AI Query Generation
Uses LangChain + Ollama to convert natural language into MongoDB queries.
✅ Query Validation
Detects risky operations such as:
- global deletes
- unsafe updates
- destructive queries
✅ Query Explainability
Shows a human-readable explanation before the query executes.
✅ Cost Estimation & Optimization Hints
Detects:
- collection scans
- missing indexes
and suggests improvements.
✅ Safe Query Execution
✅ Pagination & Result Views
- Table view
- JSON viewer
✅ CSV Export
✅ Query History Logs
✅ Role-Based Access Control
- Admin
- Developer
- ReadOnly
✅ Database Explorer
- List databases
- List collections
NeuroQuery follows a modular AI-driven architecture.
Frontend (React + Vite + Tailwind)
⬇
Backend API (Node.js + Express)
⬇
AI Layer (LangChain + Ollama)
⬇
MongoDB
Flow:
- User enters a natural language query
- Frontend sends request to backend
- Backend gathers schema context
- LLM generates MongoDB query
- Query is validated
- Query is explained
- Query executes safely
- Results return to frontend
React (Vite)
Tailwind CSS
Axios
JSON Viewer
Node.js
Express.js
MongoDB Native Driver
JWT Authentication
LangChain
Ollama (local LLM)
Model: llama3.1:8b
Authentication
POST /api/auth/login
Query Processing
POST /api/query/generate
POST /api/query/validate
POST /api/query/explain
POST /api/query/execute
Query History
GET /api/query/history
PORT
MONGODB_URI
MONGODB_DB
JWT_SECRET
OLLAMA_BASE_URL
OLLAMA_MODEL
REDIS_URL (optional)
ADMIN_EMAIL
ADMIN_PASSWORD
ADMIN_ROLE
CORS_ORIGIN
Example:
PORT=8080
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB=testdb
JWT_SECRET=supersecret
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=admin123
ADMIN_ROLE=Admin
VITE_API_URL=http://localhost:8080
From project root:
npm install
npm --prefix backend install
npm --prefix frontend install
Copy environment files.
backend/.env.example → backend/.env
frontend/.env.example → frontend/.env
Update values as needed.
Install Ollama:
Pull the model:
ollama run llama3.1:8b
Ensure these match your configuration:
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1:8b
From project root:
npm run dev
Frontend:
Backend:
Run the full stack using Docker:
docker compose up --build
This will start:
- frontend
- backend
- MongoDB (if configured)
Use the admin credentials from backend .env.
Example:
Email: admin@example.com
Password: admin123
Try natural language queries like:
Show all users from India
Find orders above 500 placed last month
List the top 10 products by sales
Show customers who signed up this year
NeuroQuery will:
- Generate a MongoDB query
- Explain what it does
- Validate safety
- Execute the query
- Return results
Results can be displayed as:
Table format
JSON format
CSV export
Pagination ensures large datasets are handled efficiently.
All queries are logged with metadata:
- natural language input
- generated MongoDB query
- execution time
- user
- timestamp
This supports auditing and debugging.
If AI queries fail:
Ensure Ollama is running:
ollama run llama3.1:8b
Check configuration:
OLLAMA_BASE_URL=http://localhost:11434
Change backend port in .env:
PORT=8081
Update frontend:
VITE_API_URL=http://localhost:8081
Verify MongoDB is running:
mongodb://localhost:27017
Check:
MONGODB_URI
MONGODB_DB
Voice queries
Multi-database support
Query visualization
Auto index creation
Query performance dashboards
MIT License
(Add LICENSE file if distributing publicly)
Contributions are welcome.
Steps:
- Fork the repository
- Create a feature branch
- Submit a pull request
NeuroQuery
AI-powered database interface for modern data workflows.
If you find this project useful, consider starring the repository ⭐