How to Start the Memgraph and Qdrant Stack for Code-Graph-RAG

Start the Memgraph and Qdrant stack for Code-Graph-RAG by running cgr daemon up, which orchestrates both services via Docker Compose and blocks until health checks pass.

Code-Graph-RAG relies on Memgraph for knowledge graph storage and Qdrant for vector similarity search. The codebase provides a unified CLI command that renders the Docker Compose configuration, launches both containers, and verifies service readiness before returning control to the user. This guide walks through the exact implementation in the vitali87/code-graph-rag repository.

Prerequisites

Before starting the stack, ensure your environment meets the following requirements:

  • Docker and Docker Compose installed and running
  • Python 3.12+ with the package installed: pip install "code-graph-rag[semantic]"
  • Ports 7687 (Memgraph Bolt) and 6333 (Qdrant HTTP) available on your host machine

The [semantic] extra is required to enable Qdrant integration for embedding storage and similarity search.

Starting the Stack

The primary entry point for launching infrastructure is the cgr daemon up command. This single operation handles container orchestration, configuration rendering, and health verification.

The StackManager Implementation

Under the hood, the StackManager class in codebase_rag/stack/manager.py controls the container lifecycle. When you invoke cgr daemon up, the CLI routes to daemon_up() (lines 27–34), which performs three critical operations:

  1. Renders the compose file – If no existing configuration is found in $CGR_HOME, the manager copies the packaged template from codebase_rag/stack/package-compose.yaml
  2. Launches containers – Executes docker compose up -d to start Memgraph and Qdrant in detached mode
  3. Validates health – Calls wait_healthy() to block until both services respond to network probes

The manager also implements _warn_if_ports_are_public() (lines 38–46) to alert you if the Docker Compose configuration binds services to all network interfaces, which may expose ports unnecessarily.

Docker Compose Configuration

The default package-compose.yaml defines the following service topology:

  • memgraph: Exposes the Bolt protocol on port 7687 for graph database connections
  • qdrant: Exposes the HTTP API on port 6333 for vector search operations

During the first run, the manager copies this file into your $CGR_HOME directory, allowing you to customize volumes, environment variables, or network settings for subsequent executions.

Verifying Service Health

After container startup, Code-Graph-RAG automatically verifies connectivity before marking the stack as ready. The health check logic resides in codebase_rag/stack/health.py, which implements:

  • wait_for_memgraph: Probes the configured host and port for Bolt protocol availability
  • wait_for_qdrant: Issues an HTTP request to Qdrant's REST endpoint to confirm responsiveness

Once both checks succeed, the system returns a StackStatus object containing memgraph_endpoint and qdrant_endpoint, confirming the stack is operational.

To manually verify the current state:

cgr daemon status

This command displays RUNNING status along with the reachable endpoints for both services.

Managing the Stack

Beyond initial startup, the daemon subsystem provides lifecycle management commands:


# View real-time logs from all services

cgr daemon logs --follow

# Stream logs for a specific container

cgr daemon logs memgraph
cgr daemon logs qdrant

# Restart the stack (preserving data volumes)

cgr daemon restart

# Stop and remove containers

cgr daemon down

These commands map directly to the daemon subcommand registered in codebase_rag/cli.py, providing a consistent interface for stack administration without requiring direct Docker Compose interaction.

Summary

  • Execute cgr daemon up to start both Memgraph and Qdrant via Docker Compose with automatic health verification
  • The StackManager class in codebase_rag/stack/manager.py handles configuration rendering, container orchestration, and security warnings
  • Health probes in codebase_rag/stack/health.py validate that Memgraph (port 7687) and Qdrant (port 6333) are reachable before completing startup
  • Use cgr daemon status to confirm endpoints and cgr daemon down to terminate the stack
  • Install with the [semantic] extra to ensure Qdrant dependencies are available

Frequently Asked Questions

What ports does Code-Graph-RAG use for Memgraph and Qdrant?

Code-Graph-RAG exposes Memgraph on port 7687 (Bolt protocol) and Qdrant on port 6333 (HTTP API). These ports are defined in codebase_rag/stack/package-compose.yaml and must be available on your host machine before starting the stack. The StackManager warns you if the configuration binds these to all network interfaces, as this may create security exposure on shared networks.

How does the CLI know when the services are ready to accept connections?

The daemon_up() method calls wait_healthy(), which delegates to wait_for_memgraph and wait_for_qdrant in codebase_rag/stack/health.py. These functions perform active health checks—attempting TCP connections and HTTP requests—until both services respond, ensuring you cannot start indexing or querying before the database layer is fully initialized.

Can I modify the Docker Compose configuration?

Yes. During the first execution, StackManager copies package-compose.yaml into your $CGR_HOME directory. You can edit this generated file to add persistent volumes, configure authentication, or change network settings. Subsequent calls to cgr daemon up use your customized version rather than the packaged template.

How do I stop the stack without losing data?

Run cgr daemon down to stop and remove the containers. By default, data persists in Docker volumes defined in the compose file. If you have mapped host directories for Memgraph or Qdrant storage in your customized configuration, your graph data and vector embeddings remain intact after the containers are removed.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →