A modern, full-stack application that enables natural language querying of Neo4j graph databases using AI. Ask questions in plain English and get intelligent answers powered by LLMs, with real-time graph visualizations and comprehensive conversation management.
- Ask in Plain English: "Which actors played in Casino?" → Automatic Cypher query generation
- Intelligent Context Understanding: Leverages Groq's Llama 3 LLM for accurate query interpretation
- Schema-Aware: Automatically adapts to your Neo4j database schema
- Cypher Transparency: View the generated Cypher queries to learn and verify
- Real-time Visualization: See your query results as interactive graphs
- Powered by vis-network: Drag, zoom, and explore node relationships
- Smart Node Detection: Automatically extracts and displays nodes and relationships
- Color-Coded: Different node types (Movie, Person, Genre) have distinct colors
- Export Options: Download visualizations as PNG images
- Persistent History: All conversations saved in browser localStorage
- Time-based Filtering: View today's, this week's, or all conversations
- One-Click Restore: Instantly reload any past conversation with full context
- Bulk Management: Clear individual items or entire history
- Glassmorphism Design: Beautiful frosted-glass aesthetic with animated backgrounds
- Typing Animation: Smooth text reveal with skip option for fast reading
- Toast Notifications: Real-time feedback for every action
- Smart Suggestions: Autocomplete with sample questions and recent queries
- Keyboard Shortcuts:
Ctrl+K- Focus searchEscape- Clear/close modalsCtrl+L- Clear conversationArrow keys- Navigate suggestions
- Backend Status Indicator: Live connection monitoring
- Multi-stage Loading: Clear progress indicators during query processing
- Response Feedback: Thumbs up/down rating system for answers
- JSON: Machine-readable format for data analysis
- Markdown: Human-readable with formatted code blocks
- PDF: Professional documents with proper styling and pagination
The app comes with intelligent sample questions that adapt to your database:
- "How many movies did Tom Hanks act in?"
- "Which actors played in the movie 'Casino'?"
- "List all movies from the 'Comedy' genre"
- "Find people who both directed and acted in the same movie"
┌─────────────────────┐ ┌─────────────────────┐
│ React Frontend │ HTTP/REST API │ FastAPI Backend │
│ (Vite + React) │ ◄─────────────────────► │ (Python + async) │
│ │ │ │
│ • Modern UI/UX │ │ • LangChain │
│ • State Management │ │ • Pydantic │
│ • Local Storage │ │ • CORS enabled │
│ • vis-network │ │ │
└─────────────────────┘ └─────────────────────┘
│
│ Neo4j Driver
▼
┌───────────────────┐
│ Neo4j Database │
│ (Graph Store) │
└───────────────────┘
▲
│ GraphCypherQAChain
│
┌───────────────────┐
│ Groq LLM API │
│ (Llama 3 Model) │
└───────────────────┘
- FastAPI - Modern, high-performance async web framework
- LangChain - LLM orchestration and chaining
- LangChain-Neo4j - Neo4j integration for LangChain
- LangChain-Groq - Groq LLM provider integration
- Uvicorn - Lightning-fast ASGI server
- Pydantic - Data validation using Python type annotations
- Python-dotenv - Environment variable management
- React - UI library with latest concurrent features
- Vite - Next-generation frontend build tool
- Tailwind CSS - Utility-first CSS framework
- vis-network - Network visualization library
- jsPDF - Client-side PDF generation
- Custom React Hooks - useLocalStorage, useKeyboard
- Neo4j - Graph database (local or Aura cloud)
- Groq API - Fast LLM inference (Llama 3 models)
Before you begin, ensure you have:
- Python 3.10 or higher - Download Python
- Node.js 18 or higher - Download Node.js
- Git - Download Git
- Neo4j Database - Choose one:
- Neo4j Desktop (Local installation)
- Neo4j Aura (Free cloud tier)
- Groq API Key - Get free API key
- RAM: 4GB minimum, 8GB+ recommended
- Storage: 2GB free space
- OS: Windows 10/11, macOS 10.15+, or Linux
- Browser: Chrome, Firefox, Safari, or Edge (latest versions)
git clone https://github.com/Aafimalek/graphdb
cd graphdb# Install all Python dependencies from root
pip install -r requirements.txt# Copy the example file
cp env.example backend/.env
# Edit the .env file with your actual credentials
# Use any text editor:
notepad backend/.env # Windows
nano backend/.env # macOS/LinuxRequired configuration in backend/.env:
# Neo4j Connection (Local)
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_actual_password_here
NEO4J_DATABASE=neo4j
# Neo4j Aura (Cloud) - Use this format instead if using Aura
# NEO4J_URI=neo4j+s://xxxxx.databases.neo4j.io
# Groq API Configuration
GROQ_API_KEY=your_groq_api_key_here
GROQ_MODEL=llama3-8b-8192
# Alternative Models (uncomment to use):
# GROQ_MODEL=llama3-70b-8192 # More accurate, slightly slower
# GROQ_MODEL=mixtral-8x7b-32768 # Good for complex queries
# GROQ_MODEL=gemma2-9b-it # Fast alternative modelImportant Notes:
⚠️ Never commit the.envfile to git (it's in.gitignore)- 🔑 Get your Groq API key from console.groq.com
- 🔒 Keep your Neo4j password secure
# Navigate to frontend directory
cd frontend
# Install Node.js dependencies
npm install
# Return to root directory
cd ..This installs all frontend dependencies including React, Vite, Tailwind CSS, vis-network, and jsPDF.
-
Download and Install
- Download Neo4j Desktop
- Install and launch Neo4j Desktop
-
Create Database
- Click "New" → "Create Project"
- Click "Add" → "Local DBMS"
- Name it (e.g., "Movie Graph")
- Set password (use this in your
.envfile) - Version: 5.x (recommended)
- Click "Create"
-
Start Database
- Click "Start" on your database
- Wait for status to show "Active"
-
Load Sample Data
- Click "Open" to launch Neo4j Browser
- In the command bar, type:
:play movies - Follow the interactive guide to load the Movies dataset
- Click the code blocks to run the Cypher queries
-
Create Free Account
- Go to Neo4j Aura
- Sign up for a free account
- Click "Create Database" → "Free"
-
Save Credentials
- IMPORTANT: Download and save the credentials file
- Note the connection URI (format:
neo4j+s://xxxxx.databases.neo4j.io) - Note the password (you can't retrieve it later!)
-
Update Configuration
- Use the Aura URI in your
backend/.envfile - Format:
NEO4J_URI=neo4j+s://xxxxx.databases.neo4j.io
- Use the Aura URI in your
-
Load Sample Data
- Open Neo4j Browser from Aura Console
- Run:
:play movies - Follow the guide to load data
# From the root directory
cd backend
python -c "from config import settings; from langchain_neo4j import Neo4jGraph; graph = Neo4jGraph(url=settings.NEO4J_URI, username=settings.NEO4J_USERNAME, password=settings.NEO4J_PASSWORD); print('✓ Connected to Neo4j successfully!')"# Navigate to backend directory
cd backend
# Run the FastAPI server
python main.pyExpected output:
Starting FastAPI server on http://127.0.0.1:8000
Access the API docs at http://127.0.0.1:8000/docs
INFO: Uvicorn running on http://127.0.0.1:8000
INFO: Application startup complete.
The backend will be available at: http://127.0.0.1:8000
# Open a NEW terminal
# Navigate to frontend directory
cd frontend
# Run the Vite development server
npm run devExpected output:
VITE v7.1.7 ready in 1234 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
The frontend will be available at: http://localhost:5173
If you prefer using uvicorn directly:
cd backend
uvicorn main:app --reload --host 127.0.0.1 --port 8000-
Check Backend Health
- Open: http://127.0.0.1:8000
- Should see:
{"message": "Welcome to the Graph Q&A API!"}
-
Check Backend Status
- Open: http://127.0.0.1:8000/status
- Should see JSON with
neo4j_connected: true
-
Open Frontend
- Open: http://localhost:5173
- Look for green "Connected" indicator at top
- Try a sample question
-
View API Documentation
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
-
Open the App
- Navigate to http://localhost:5173 in your browser
- Check the green "Backend Connected" indicator at the top
-
Ask a Question
- Click a sample question, or
- Type your own question in the input box
- Press Enter or click "Ask"
-
View Results
- Answer: Appears with typing animation (click to skip)
- Cypher Query: Toggle the "Show Cypher" button to see the generated query
- Graph Visualization: Click the purple graph icon (📊) if available
Basic Queries:
- "How many movies are in the database?"
- "List all actors"
- "What movies were released in 1995?"
Relationship Queries:
- "Which actors played in Casino?"
- "Who directed The Matrix?"
- "Show me all movies directed by Martin Scorsese"
Complex Queries:
- "Find people who both directed and acted in the same movie"
- "Which actors have worked with Tom Hanks?"
- "List movies in the Comedy genre with rating above 7"
Note: Graph visualization works best with queries that return nodes and relationships, not just counts or lists.
| Shortcut | Action |
|---|---|
Ctrl+K / Cmd+K |
Focus search input |
Escape |
Clear input or close modal |
Ctrl+L / Cmd+L |
Clear current conversation |
Enter |
Submit question |
↑ / ↓ |
Navigate autocomplete suggestions |
- Access: Click the history icon (🕐) in the top-left corner
- View: Browse all past conversations
- Filter: Today, This Week, This Month, All Time
- Restore: Click any conversation to reload it
- Delete: Remove individual items or clear all
- Trigger: Appears automatically for compatible queries
- Icon: Purple graph icon (📊) next to the answer
- Features:
- Drag nodes to rearrange
- Zoom with mouse wheel
- Hover to see properties
- Double-click node to highlight connections
- Download as PNG
- Access: Click the quick actions button (⚡) in bottom-right
- Formats:
- JSON: Full conversation data
- Markdown: Formatted text with code blocks
- PDF: Professional document with styling
- Thumbs Up 👍: Mark helpful answers
- Thumbs Down 👎: Mark unhelpful answers
- Comment: Optional feedback text
- (Currently logged; can be extended to store in database)
Welcome endpoint for API health check.
Response:
{
"message": "Welcome to the Graph Q&A API!",
"docs": "/docs"
}Check backend services status.
Response:
{
"neo4j_connected": true,
"neo4j_schema": "Node properties:\nMovie {...}\nPerson {...}...",
"llm_initialized": true,
"qa_chain_ready": true,
"llm_model_name": "llama3-8b-8192"
}Submit a natural language question.
Request Body:
{
"question": "How many movies did Tom Hanks act in?"
}Response:
{
"answer": "Tom Hanks acted in 12 movies.",
"generated_cypher": "MATCH (p:Person {name: 'Tom Hanks'})-[:ACTED_IN]->(m:Movie) RETURN count(m)",
"graph_data": {
"nodes": [
{
"id": "p_1",
"label": "Tom Hanks",
"labels": ["Person"],
"properties": {"name": "Tom Hanks"}
}
],
"relationships": []
},
"error": null
}Submit user feedback on answers.
Request Body:
{
"question": "Who directed Casino?",
"answer": "Martin Scorsese directed Casino.",
"rating": "positive",
"comment": "Very helpful!"
}Response:
{
"status": "success",
"message": "Thank you for your feedback!"
}# Ask a question
curl -X POST http://127.0.0.1:8000/ask \
-H "Content-Type: application/json" \
-d '{"question": "How many movies are there?"}'
# Check status
curl http://127.0.0.1:8000/status
# Submit feedback
curl -X POST http://127.0.0.1:8000/feedback \
-H "Content-Type: application/json" \
-d '{
"question": "test",
"answer": "test",
"rating": "positive"
}'graphdb/
├── backend/
│ ├── main.py # FastAPI app entry point & endpoints
│ ├── services.py # GraphQAService with LangChain integration
│ ├── config.py # Configuration & settings management
│ ├── .env # Environment variables (create this!)
│ └── __pycache__/ # Python cache (auto-generated)
│
├── frontend/
│ ├── src/
│ │ ├── components/
│ │ │ ├── Toast.jsx # Toast notification system
│ │ │ ├── HistorySidebar.jsx # Conversation history panel
│ │ │ ├── TypingAnimation.jsx # Animated text reveal
│ │ │ ├── QuickActions.jsx # Floating action button
│ │ │ └── GraphVisualization.jsx # Interactive graph viewer
│ │ ├── hooks/
│ │ │ ├── useLocalStorage.jsx # Persistent state hook
│ │ │ └── useKeyboard.jsx # Keyboard shortcuts hook
│ │ ├── utils/
│ │ │ └── exportUtils.js # Export to PDF/JSON/MD
│ │ ├── App.jsx # Main application component
│ │ ├── App.css # Component styles
│ │ ├── main.jsx # React entry point
│ │ └── index.css # Global styles (Tailwind)
│ ├── public/
│ │ └── vite.svg # App icon
│ ├── index.html # HTML template
│ ├── package.json # Node dependencies
│ ├── package-lock.json # Locked dependency versions
│ ├── vite.config.js # Vite configuration
│ ├── eslint.config.js # ESLint configuration
│ └── node_modules/ # Installed packages (auto-generated)
│
├── experiments/
│ ├── experiments.ipynb # Jupyter notebook for testing
│ └── promptstatergies.ipynb # Prompt engineering experiments
│
├── requirements.txt # Python dependencies
├── env.example # Example environment variables
├── README.md # This file
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
Symptoms: Backend returns 500 errors, logs show connection failures
Solutions:
- Verify Neo4j is running:
- Desktop: Check if database is "Active"
- Aura: Check cloud console status
- Verify credentials in
backend/.env:# Test connection cd backend python -c "from config import settings; print(f'URI: {settings.NEO4J_URI}')"
- Check URI format:
- Local:
bolt://localhost:7687 - Aura:
neo4j+s://xxxxx.databases.neo4j.io
- Local:
- Test from Neo4j Browser first
Symptoms: Backend fails to start, validation error
Solutions:
- Verify
.envfile exists inbackend/directory - Check file contains:
GROQ_API_KEY=your_key_here - No spaces around the
=sign - Get new key from console.groq.com
- Restart backend after updating
Symptoms: ImportError or ModuleNotFoundError
Solutions:
# Reinstall all dependencies
pip install -r requirements.txt
# Verify installation
pip list | grep -E "(fastapi|langchain|uvicorn)"
# If using virtual environment, ensure it's activatedSymptoms: "Address already in use"
Solutions:
# Windows
netstat -ano | findstr :8000
taskkill /PID <process_id> /F
# macOS/Linux
lsof -i :8000
kill -9 <process_id>
# Or use a different port
uvicorn main:app --port 8001Symptoms: White screen, no UI visible
Solutions:
- Check backend is running: http://127.0.0.1:8000
- Check browser console (F12) for errors
- Verify backend URL in
src/App.jsx:const BACKEND_URL = 'http://127.0.0.1:8000';
- Clear browser cache and reload
- Check for CORS errors (should be enabled by default)
Symptoms: npm install errors
Solutions:
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm cache clean --force
npm install
# If peer dependency issues
npm install --legacy-peer-deps
# Update npm itself
npm install -g npm@latestSymptoms: No graph icon appears after query
Solutions:
- Check query type - only MATCH queries show graphs
- Try known working query: "Show me actors in Casino"
- Check browser console for errors
- Verify vis-network installed:
npm list vis-network - Count queries won't show graphs (e.g., "How many...")
Symptoms: Vite build errors mentioning Tailwind
Solutions:
# Ensure Tailwind plugin is installed
npm install -D @tailwindcss/vite
# Check vite.config.js has:
# import tailwindcss from '@tailwindcss/vite'
# plugins: [react(), tailwindcss()]Causes & Solutions:
- First query slow: LLM cold start (normal, ~5-10s)
- All queries slow:
- Check internet connection
- Try faster model:
GROQ_MODEL=llama3-8b-8192 - Check Groq API status
- Graph queries slow: Large result sets (limited to 50 nodes)
Symptoms: "blocked by CORS policy"
Solutions:
- Verify CORS middleware in
backend/main.py - Should include:
app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], )
- Restart backend after changes
Causes & Solutions:
- Empty database: Load sample data (
:play movies) - Schema mismatch: Database has different structure
- Ambiguous question: Be more specific
- LLM confusion: Try rephrasing the question
Symptoms: History not saving
Solutions:
// Clear history from app UI (History → Clear All)
// Or manually in browser console:
localStorage.clear();Contributions are welcome! Here's how to contribute:
- Fork the repository
- Clone your fork:
git clone <your-fork-url> - Create a branch:
git checkout -b feature/amazing-feature - Make your changes
- Test thoroughly
- Commit:
git commit -m 'Add amazing feature' - Push:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style
- Add comments for complex logic
- Update README if adding features
- Test on multiple browsers/OS if UI changes
- Keep PRs focused on single feature/fix
This project is licensed under the MIT License - see the LICENSE file for details.
- ✅ Commercial use allowed
- ✅ Modification allowed
- ✅ Distribution allowed
- ✅ Private use allowed
- ❌ No liability
- ❌ No warranty
- LangChain - LLM orchestration framework
- Groq - Fast LLM inference API
- Neo4j - Graph database platform
- FastAPI - Modern Python web framework
- React - UI library
- Vite - Build tool
- Tailwind CSS - CSS framework
- vis-network - Graph visualization
- Neo4j's example projects
- LangChain documentation and examples
- Modern UI/UX design patterns
- 📖 Documentation: Read this README thoroughly
- 🐛 Bug Reports: Open an issue on GitHub
- 💡 Feature Requests: Open an issue with [Feature] tag
- 💬 Questions: Use GitHub Discussions
- Neo4j Documentation
- LangChain Documentation
- Groq Documentation
- FastAPI Documentation
- React Documentation
If you find this project useful, please consider giving it a ⭐ on GitHub!
Built with ❤️ using React, FastAPI, Neo4j, LangChain, and Groq AI
Last Updated: November 2025