An Agentic Context Engine with Explainable Graph Memory
- Overview
- Key Features
- Architecture
- Quick Start
- Documentation
- Technology Stack
- Project Structure
- Development
- Deployment
- Contributing
- License
NeuroGraph is an enterprise-grade AI system that combines graph-based memory, autonomous agents, and explainable reasoning to dynamically build context for LLM applications. Unlike traditional RAG (Retrieval-Augmented Generation) systems that rely on static vector searches, NeuroGraph actively decides what information is relevant, explains its reasoning process, and evolves its knowledge over time.
The system implements a three-layer memory architecture (Personal, Organization, Global) with automatic conflict detection, temporal decay, and full provenance tracking for every stored fact.
- Personal Layer: Private user memory, isolated per user
- Organization Layer: Shared team knowledge, scoped to tenant
- Global Layer: Public world knowledge, write-protected (confidence > 0.85)
- Every relationship stored with reason, timestamp, and confidence score
- Traceable reasoning paths through the knowledge graph
- Temporal decay algorithm for confidence degradation
- Full provenance tracking (source, author, storage method)
- Dynamic agent spawning based on query complexity
- Parallel and sequential execution strategies
- Stateless agent design for horizontal scalability
- Event-driven architecture with priority queueing
- Model Context Protocol (MCP) server for direct LLM integration
- Plug into Claude Desktop, Cursor, Cline, or any MCP client
- Transport-agnostic: stdio for local clients, HTTP/SSE for remote
- No middleware required for MCP clients
- Internal graph memory (Neo4j) for structured knowledge
- External web search (Tavily) for current information
- Vector similarity search (pgvector) for semantic matching
- Context assembly with token budget management
- D3.js-powered interactive graph visualization
- WebSocket updates for live graph changes
- Reasoning path highlighting
- Conflict detection visualization (red edges)
graph TB
subgraph "User Interfaces"
UI[Chat Interface<br/>React + Vite]
MCP[MCP Clients<br/>Claude, Cursor]
WH[Webhooks<br/>Slack, GitHub, Gmail]
end
subgraph "Processing Layer"
ORC[Orchestrator<br/>Groq Llama 3.3<br/>Chat Only]
MCPS[MCP Server<br/>FastAPI<br/>Direct Access]
EB[Event Bus<br/>Upstash Redis<br/>Priority Queue]
end
subgraph "Agent Layer"
MM[Memory Manager]
CB[Context Builder]
WS[Web Surfer]
IA[Import Agent]
CR[Conflict Resolver]
RA[Reminder Agent]
end
subgraph "Data Layer"
NEO[(Neo4j<br/>Graph DB<br/>Docker)]
PG[(PostgreSQL<br/>pgvector<br/>Docker)]
REDIS[(Upstash Redis<br/>Cache + Queue)]
end
UI -->|User Query| ORC
MCP -->|Tool Call| MCPS
WH -->|Event| EB
ORC -->|Plan + Spawn| EB
MCPS -->|Direct| MM
EB --> MM
EB --> WS
EB --> IA
MM --> CB
MM --> CR
MM --> RA
MM --> NEO
MM --> PG
CR --> NEO
RA --> REDIS
style ORC fill:#f9f,stroke:#333
style MCPS fill:#9ff,stroke:#333
style MM fill:#ff9,stroke:#333
- Separation of Orchestration: Chat interface uses orchestrator for dynamic planning; MCP clients bypass orchestrator for direct access
- Event-Driven Processing: All triggers (user, integration, LLM) normalize to standard events
- Stateless Agents: Agents spawn, execute, return results, and terminate with no persistent state
- Graph as Source of Truth: All memory operations flow through Neo4j for consistency
- Layer Isolation: Memory layers enforce strict access controls and tenant boundaries
- Docker and Docker Compose
- Python 3.11+ (for local development)
- Node.js 18+ (for frontend development)
- Clone the repository:
git clone https://github.com/NeerajCodz/neurograph.git
cd neurograph- Copy environment templates:
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env-
Edit
.envfiles with your API keys:GEMINI_API_KEY: Google Gemini API keyGROQ_API_KEY: Groq API key (optional, for orchestrator)TAVILY_API_KEY: Tavily search API keyUPSTASH_REDIS_URLandUPSTASH_REDIS_TOKEN: Upstash Redis credentials
-
Start all services:
docker-compose -f docker/docker-compose.yml up -d- Access the application:
- Chat Interface: http://localhost:3000
- API Documentation: http://localhost:8000/docs
- Neo4j Browser: http://localhost:7474 (username: neo4j, password: from .env)
- Navigate to http://localhost:3000
- Log in or create an account
- Select memory mode:
- General: Uses personal memory only
- Organization: Select organization from dropdown (uses personal + organization layers)
- Toggle Global Memory in settings to include/exclude public knowledge
- Start chatting - memory is handled automatically
Configure your MCP client (e.g., Claude Desktop):
{
"mcpServers": {
"neurograph": {
"command": "python",
"args": ["-m", "neurograph.mcp.server"],
"env": {
"NEO4J_URI": "neo4j://localhost:7687",
"NEO4J_PASSWORD": "your-password",
"POSTGRES_URI": "postgresql://user:pass@localhost:5432/neurograph",
"TENANT_ID": "your-org-id",
"USER_ID": "your-user-id"
}
}
}
}Available MCP tools:
recall(query)- Retrieve relevant memoryremember(entity1, relation, entity2, reason)- Store new factexplain(node_id)- Get provenance of a factforget(entity1, relation, entity2)- Delete a relationshipswitch_mode(mode)- Change active memory layermemory_status()- Get memory statisticsresolve_conflict(conflict_id, resolution)- Resolve memory conflictsimport_context(source, content)- Bulk import from integrationssearch_assets(query)- Search stored files and documentsexplain_last_response()- Get full reasoning trail
Comprehensive documentation is available in the /docs folder:
| Document | Description |
|---|---|
| Architecture | System design, components, data flows |
| API Reference | REST API and MCP tool specifications |
| MCP | MCP server setup and client integration |
| Frontend | React application, D3.js visualization |
| Backend | FastAPI services, Docker configuration |
| Agents | Agent system, orchestration, lifecycle |
| Memory | Three-layer architecture, scoring, decay |
| Graph | Neo4j schema, queries, indexing |
| Databases | Neo4j, PostgreSQL, Upstash configuration |
| RAG | Vector embeddings, similarity search, hybrid retrieval |
| Models | Gemini and Groq integration |
| Webhooks | Integration endpoints, event normalization |
| Integrations | Slack, GitHub, Gmail, and other third-party connections |
| Component | Technology | Purpose |
|---|---|---|
| Framework | Python FastAPI | High-performance async API server |
| MCP Server | Python MCP SDK | Model Context Protocol implementation |
| Graph Database | Neo4j (Docker) | Knowledge graph storage |
| Vector Store | PostgreSQL + pgvector (Docker) | Semantic similarity search |
| Cache/Queue | Upstash Redis | Event bus and distributed cache |
| LLM (Main) | Google Gemini | Primary reasoning model |
| LLM (Orchestrator) | Groq Llama 3.3 | Fast agent planning |
| Embeddings | Gemini Embeddings | Vector generation |
| Web Search | Tavily API | External knowledge retrieval |
| Component | Technology | Purpose |
|---|---|---|
| Build Tool | Vite | Fast development and build |
| Framework | React 18 | UI component library |
| Language | TypeScript | Type-safe development |
| State Management | Zustand | Lightweight state management |
| Visualization | D3.js | Interactive graph rendering |
| Styling | Tailwind CSS | Utility-first CSS |
| Real-time | WebSocket | Live graph updates |
| Component | Technology | Purpose |
|---|---|---|
| Containerization | Docker + Docker Compose | Service orchestration |
| Reverse Proxy | Nginx | Request routing and SSL termination |
| Monitoring | Prometheus + Grafana | Metrics and dashboards |
| Tracing | Jaeger | Distributed request tracing |
| Logging | Structured JSON logs | Centralized log aggregation |
neurograph/
├── backend/ # Python FastAPI backend
│ ├── src/
│ │ ├── api/ # REST API endpoints
│ │ ├── mcp/ # MCP server and tools
│ │ ├── agents/ # Agent system
│ │ ├── memory/ # Memory management
│ │ ├── rag/ # RAG pipeline
│ │ ├── models/ # LLM integration
│ │ ├── integrations/ # Third-party connections
│ │ ├── webhooks/ # Webhook handlers
│ │ └── events/ # Event system
│ └── tests/ # Backend tests
│
├── frontend/ # React frontend
│ ├── src/
│ │ ├── pages/ # Page components
│ │ ├── components/ # Reusable components
│ │ ├── stores/ # Zustand stores
│ │ ├── hooks/ # Custom React hooks
│ │ └── services/ # API clients
│ └── tests/ # Frontend tests
│
├── docker/ # Docker configurations
│ ├── docker-compose.yml
│ ├── neo4j/
│ ├── postgres/
│ └── nginx/
│
├── docs/ # Documentation
└── scripts/ # Utility scripts
See FOLDER_STRUCTURE.md for complete project structure.
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python src/main.pycd frontend
npm install
npm run dev# Backend
cd backend
pytest
# Frontend
cd frontend
npm test# Neo4j
python backend/scripts/migrate.py --database neo4j --version latest
# PostgreSQL
python backend/scripts/migrate.py --database postgres --version latestdocker-compose -f docker/docker-compose.yml -f docker/docker-compose.dev.yml updocker-compose -f docker/docker-compose.yml -f docker/docker-compose.prod.yml up -dRequired environment variables for production:
# Backend
NEO4J_URI=neo4j+s://production-instance.databases.neo4j.io
NEO4J_PASSWORD=<strong-password>
POSTGRES_URI=postgresql://user:pass@postgres-host:5432/neurograph
UPSTASH_REDIS_URL=https://production.upstash.io
UPSTASH_REDIS_TOKEN=<token>
GEMINI_API_KEY=<key>
GROQ_API_KEY=<key>
TAVILY_API_KEY=<key>
SECRET_KEY=<strong-secret-key>
ENVIRONMENT=production
# Frontend
VITE_API_URL=https://api.yourcompany.com
VITE_WS_URL=wss://api.yourcompany.com/wsTrack device-user relationships across time to identify suspicious patterns and explain detection reasoning.
Map threat actors, affected systems, and remediation actions with full audit trail and temporal tracking.
Maintain organizational memory that explains decision provenance, tracks context changes, and surfaces relevant historical information.
Build context-aware assistants that remember user preferences, adapt to organizational knowledge, and explain their reasoning.
Track patient history, treatment relationships, and outcomes with explainability and confidence scoring for clinical decisions.
Contributions are welcome. Please follow these guidelines:
- Code Style: Follow PEP 8 for Python, ESLint configuration for TypeScript
- Naming Convention: lowercase-hyphen-separated for files, PascalCase for classes, snake_case for functions
- Testing: All new features must include unit tests and integration tests
- Documentation: Update relevant documentation for any feature changes
- Commit Messages: Use conventional commits format (feat:, fix:, docs:, etc.)
MIT License. See LICENSE for details.
- Documentation: See
/docsfolder - Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@neurograph.dev
- Multi-agent collaboration (agents spawning other agents)
- What-if simulation mode for scenario planning
- Real-time learning feedback loop
- Domain-specific fine-tuning for specialized use cases
- Mobile applications (iOS/Android)
- Additional integrations (Jira, Linear, Confluence)
- GraphQL API endpoint
- SSO/SAML authentication support
NeuroGraph - Memory that thinks, explains, and evolves.