Intelligent Code Analysis & RAG System with Neo4j Graph Memory
EVA-Code-Brain is an advanced code intelligence system that combines vector embeddings, graph-based memory, and AI agents to provide deep code understanding, quality analysis, and intelligent search capabilities.
- 🔍 Semantic Code Search - Find code by meaning, not just keywords
- 📊 Code Quality Analysis - Automated quality scoring and recommendations
- 🧪 Test Generation - AI-powered unit test creation
- 📈 Health Analytics - Codebase health metrics and trends
- 🔄 Git Integration - Automatic indexing on commits
- 🤖 Multi-Agent System - Specialized AI agents for different tasks
- Ollama (Local) -
nomic-embed-text,llama3 - OpenAI - GPT-4, text-embedding-ada-002
- Anthropic - Claude 3.5 Sonnet
- PostgreSQL - Primary data storage with pgvector
- Neo4j - Graph-based code relationships
- Vector Search - Semantic similarity search
┌─────────────────────────────────────────────────────────────┐
│ EVA-Code-Brain │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Indexer │ │ Search │ │ Agents │ │
│ │ │ │ │ │ │ │
│ │ • Chunking │ │ • Semantic │ │ • Quality │ │
│ │ • Embedding │ │ • Reranking │ │ • Testing │ │
│ │ • Neo4j │ │ • Hybrid │ │ • Git │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
├─────────────────────────────────────────────────────────────┤
│ Storage Layer │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ PostgreSQL │ │ Neo4j │ │ Ollama │ │
│ │ │ │ │ │ │ │
│ │ • Vectors │ │ • Graph │ │ • Local LLM │ │
│ │ • Metadata │ │ • Relations │ │ • Embeddings │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
EVA-Code-Brain/
├── cmd/ # Command-line tools
│ └── eva-code-brain/ # Main application
├── internal/ # Internal packages
│ ├── agents/ # AI agent implementations
│ ├── chunker/ # Code chunking logic
│ ├── graph/ # Neo4j client
│ ├── indexer/ # Code indexing
│ ├── llm/ # LLM clients (Ollama, OpenAI, Anthropic)
│ ├── memory/ # Memory management
│ ├── quality/ # Code quality analysis
│ ├── search/ # Search & reranking
│ └── tools/ # Agent tools
├── migrations/ # Database migrations
│ ├── schema.sql # Initial schema
│ ├── v2_migration.sql # Version 2
│ └── ... # Incremental migrations
├── scripts/ # Utility scripts
│ ├── deploy.sh # Deployment script
│ ├── index_all.sh # Bulk indexing
│ ├── migrate.sh # Run migrations
│ └── setup.sh # Initial setup
├── web/ # Web interface
│ └── index.html # Search UI
├── .env # Environment variables
├── go.mod # Go dependencies
└── README.md # This file
- Go 1.21+
- PostgreSQL 14+ with pgvector extension
- Neo4j 5.0+
- Ollama (optional, for local models)
# 1. Clone repository
git clone https://github.com/JoseRFJuniorLLMs/EVA-Code-Brain.git
cd EVA-Code-Brain
# 2. Install dependencies
go mod download
# 3. Setup environment
cp .env.example .env
# Edit .env with your configuration
# 4. Run setup script
chmod +x scripts/setup.sh
./scripts/setup.sh
# 5. Run migrations
chmod +x scripts/migrate.sh
./scripts/migrate.sh
# 6. Build
go build -o eva-code-brain main.go
# 7. Run
./eva-code-brain# Start all services
docker-compose up -d
# Run migrations
docker-compose exec app ./scripts/migrate.sh
# View logs
docker-compose logs -f app# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=your_password
DB_NAME=eva_code_brain
# Neo4j
NEO4J_URI=bolt://localhost:7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_password
# Ollama (Local)
OLLAMA_HOST=http://localhost:11434
OLLAMA_EMBEDDING_MODEL=nomic-embed-text
OLLAMA_CHAT_MODEL=llama3
# OpenAI (Optional)
OPENAI_API_KEY=sk-...
# Anthropic (Optional)
ANTHROPIC_API_KEY=sk-ant-...
# Server
PORT=8080
LOG_LEVEL=info# Index current directory
./eva-code-brain index .
# Index specific directory
./eva-code-brain index /path/to/code
# Index with custom chunk size
./eva-code-brain index . --chunk-size 1000# Semantic search
./eva-code-brain search "how to authenticate users"
# Search with filters
./eva-code-brain search "database query" --language go --limit 10# Analyze file
./eva-code-brain quality analyze main.go
# Analyze directory
./eva-code-brain quality analyze ./internal
# Generate report
./eva-code-brain quality report --output report.html# Generate tests for file
./eva-code-brain test generate main.go
# Generate tests for package
./eva-code-brain test generate ./internal/agents# Start web server
./eva-code-brain serve
# Access at http://localhost:8080POST /api/search
{
"query": "authentication logic",
"limit": 10,
"language": "go"
}POST /api/index
{
"path": "/path/to/code",
"recursive": true
}GET /api/quality/{file_path}GET /api/health# Run all tests
go test ./...
# Run with coverage
go test -cover ./...
# Run specific package
go test ./internal/search
# Benchmark
go test -bench=. ./internal/chunker| Operation | Time | Memory |
|---|---|---|
| Chunk 1000 LOC | ~50ms | ~5MB |
| Embed 100 chunks | ~200ms | ~10MB |
| Search (semantic) | ~30ms | ~2MB |
| Neo4j query | ~10ms | ~1MB |
- Indexed Files: 100K+ files
- Code Chunks: 1M+ chunks
- Search Latency: < 100ms (p95)
- Concurrent Users: 100+
- Code Style:
gofmt+golint - Testing: Minimum 70% coverage
- Documentation: GoDoc comments
- Commits: Conventional Commits
- Create feature branch:
git checkout -b feature/my-feature - Implement with tests
- Run quality checks:
go test ./... && golint ./... - Commit:
git commit -m "feat: add my feature" - Push and create PR
# Create new migration
./scripts/create_migration.sh "add_new_table"
# Run migrations
./scripts/migrate.sh
# Rollback
./scripts/migrate.sh downContributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes with tests
- Submit a pull request
See CONTRIBUTING.md for details.
MIT License - see LICENSE file for details.
- Ollama - Local LLM infrastructure
- Neo4j - Graph database
- pgvector - PostgreSQL vector extension
- OpenAI - GPT models
- Anthropic - Claude models
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@eva-ia.org
- Multi-language support (Python, JavaScript, Java)
- Real-time code analysis
- IDE plugins (VSCode, IntelliJ)
- Cloud deployment templates
- Advanced visualization dashboard
- Code refactoring suggestions
- Security vulnerability detection
Made with ❤️ by the EVA-IA Team