# Complete Guide to Dependencies for Running Code-Graph-RAG

> Discover the essential dependencies for running Code-Graph-RAG. Learn about core requirements and optional groups for full language support, testing, and more.

- Repository: [Vitali Avagyan/code-graph-rag](https://github.com/vitali87/code-graph-rag)
- Tags: how-to-guide
- Published: 2026-08-18

---

**Code-Graph-RAG requires a minimal core of `loguru`, `mcp`, and `tree-sitter`, with five optional dependency groups available for testing, full language support, semantic search, Milvus integration, and AST pattern matching.**

The `vitali87/code-graph-rag` repository structures its Python package to remain lightweight by default while offering feature-rich extras for specific use cases. All dependency declarations reside in the `[project.optional-dependencies]` table of [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) (lines 87–131), allowing selective installation based on your target environment.

## Core Dependencies

The base installation includes only essential runtime packages needed for fundamental operation:

- **`loguru`** – Structured logging utilities
- **`mcp`** – Model Context Protocol implementation
- **`tree-sitter`** – Core Tree-Sitter library for parsing

These ship automatically when running `pip install codegraph-rag`. All additional functionality is gated behind optional extras to prevent bloat.

## Optional Dependency Groups

The project defines five distinct extras in [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml), each targeting specific workflows or integrations.

### Test Dependencies

Install the **`test`** extra to execute the repository's test suite, generate coverage reports, and run integration tests. This group includes:

- `pytest`, `pytest-asyncio`, `pytest-cov`, `pytest-xdist`
- `testcontainers`, `libclang`, `filelock`
- `ast-grep-py`, `pyyaml`

### Tree-Sitter Full Language Support

The **`treesitter-full`** extra provides comprehensive grammar support for multi-language code graph construction. According to [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) (lines 100–114), this adds:

- `tree-sitter-python`
- `tree-sitter-javascript`, `tree-sitter-typescript`
- `tree-sitter-rust`, `tree-sitter-go`, `tree-sitter-scala`
- `tree-sitter-java`, `tree-sitter-c`, `tree-sitter-cpp`
- `tree-sitter-lua`, `tree-sitter-php`, `tree-sitter-c-sharp`, `tree-sitter-dart`

Without this extra, the parser relies on a limited subset of grammars.

### Semantic Search Dependencies

Enable embedding-based retrieval and LLM integration with the **`semantic`** extra. As declared in [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) (lines 116–120), this installs:

- `qdrant-client` – Vector database client
- `torch` – PyTorch for tensor operations
- `transformers` – Hugging Face model library

These dependencies power the modules in `codebase_rag/semantic/` for vector-based similarity search.

### Milvus Vector Store Integration

For teams preferring Milvus over Qdrant, the **`milvus`** extra installs `pymilvus[milvus-lite]` as specified in [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) (lines 122–124).

### AST-Grep Pattern Matching

The **`ast-grep`** extra adds structural query capabilities through `ast-grep-py` and `pyyaml` (lines 126–129), enabling pattern matching against abstract syntax trees.

## Installation Commands

Install the core library without optional features:

```bash
pip install code-graph-rag

```

Add specific functionality using bracket notation:

```bash

# Testing tools

pip install "code-graph-rag[test]"

# Full language support

pip install "code-graph-rag[treesitter-full]"

# Semantic search stack

pip install "code-graph-rag[semantic]"

# Milvus vector store

pip install "code-graph-rag[milvus]"

# AST pattern matching

pip install "code-graph-rag[ast-grep]"

```

Combine multiple extras for development environments:

```bash
pip install "code-graph-rag[semantic,treesitter-full,test]"

```

## Conditional Import Architecture

The library implements lazy loading to prevent import errors when extras are missing. In [`codebase_rag/cli.py`](https://github.com/vitali87/code-graph-rag/blob/main/codebase_rag/cli.py), the CLI entry point checks for available dependencies before importing modules from `codebase_rag/semantic/` or `codebase_rag/parsers/`.

This design ensures that:
- Core functionality remains available without heavy ML frameworks
- Import errors only occur when accessing specific features that require missing dependencies
- Container images stay small unless extended language support is explicitly requested

## Summary

- **Core dependencies** (`loguru`, `mcp`, `tree-sitter`) always install automatically
- **`test`** extra provides pytest suite and coverage tools for CI/CD pipelines
- **`treesitter-full`** adds 13 Tree-Sitter grammars for multi-language code graph generation
- **`semantic`** enables Qdrant, PyTorch, and Transformers for vector-based RAG
- **`milvus`** offers an alternative vector database to Qdrant
- **`ast-grep`** supports structural code pattern matching
- All extras are declared in [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) (lines 87–131) and installable via pip bracket syntax

## Frequently Asked Questions

### What are the minimum dependencies required to run code-graph-rag?

The minimal installation requires only `loguru`, `mcp`, and `tree-sitter`. These support basic code parsing and logging functionality without requiring PyTorch, Hugging Face, or additional grammar packages. This lightweight core suits environments where you need only specific language support or basic graph construction.

### How do I install support for multiple programming languages?

Add the `treesitter-full` extra to gain support for 13 additional languages including Rust, Go, Java, C, C++, and TypeScript. Without this extra, the parser operates with limited grammar support. Install via `pip install "code-graph-rag[treesitter-full]"` as defined in [`pyproject.toml`](https://github.com/vitali87/code-graph-rag/blob/main/pyproject.toml) lines 100–114.

### Which dependencies are needed for semantic search and RAG?

Semantic retrieval requires the `semantic` extra, which installs `qdrant-client`, `torch`, and `transformers`. These power the embedding generation and vector similarity search features located in `codebase_rag/semantic/`. For alternative vector storage, add the `milvus` extra for `pymilvus` support.

### Can I use Milvus instead of Qdrant for vector storage?

Yes. While the `semantic` extra defaults to Qdrant via `qdrant-client`, you can install `pymilvus[milvus-lite]` using the `milvus` extra. The codebase supports conditional imports for different vector backends, though you must ensure the appropriate client library is present in your environment.