Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,18 @@ cargo build --release --bin codegraph-setup --features all-cloud-providers

### Manual Configuration

**Configuration directory: `~/.codegraph/`**

All configuration files are stored in `~/.codegraph/` in TOML format.

Configuration is loaded from (in order):
1. `./.codegraph.toml` (project-specific)
2. `~/.codegraph/config.toml` (global)
3. Environment variables
1. `~/.codegraph/default.toml` (base configuration)
2. `~/.codegraph/{environment}.toml` (e.g., development.toml, production.toml)
3. `~/.codegraph/local.toml` (local overrides, machine-specific)
4. `./config/` (fallback for backward compatibility)
5. Environment variables (CODEGRAPH__* prefix)

**See [Configuration Guide](docs/CONFIGURATION_GUIDE.md) for complete documentation.**

**Full configuration example:**
```toml
Expand Down
128 changes: 128 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# CodeGraph Configuration Files

## Important: Configuration Directory Migration

**As of the latest version, CodeGraph uses `~/.codegraph` as the primary configuration directory.**

### New Location: `~/.codegraph`

All user-level configuration files should now be placed in:

```
~/.codegraph/
```

This provides a centralized, uniform location for all CodeGraph configuration across your system.

### Why the Change?

- **Centralized**: All CodeGraph configs in one place, regardless of project
- **User-level**: Configurations follow you across different projects
- **Standard practice**: Follows Unix/Linux convention for user configuration
- **Cleaner projects**: Keeps project directories focused on code

### Migration

To migrate your existing configurations:

```bash
# Create the directory
mkdir -p ~/.codegraph

# Copy existing configs
cp config/*.toml ~/.codegraph/

# Or symlink for development (keeps backward compatibility)
ln -s $(pwd)/config ~/.codegraph
```

### Backward Compatibility

CodeGraph maintains backward compatibility by checking directories in this order:

1. **`~/.codegraph/`** (Primary)
2. **`./config/`** (This directory - fallback)
3. **Current directory** (last resort)

If `~/.codegraph` exists, it will be used. Otherwise, CodeGraph falls back to `./config/`.

## Configuration Files in This Directory

This directory contains **example configuration files** that can be copied to `~/.codegraph/`:

- `default.toml` - Base configuration example
- `surrealdb_example.toml` - SurrealDB configuration
- `example_embedding.toml` - Embedding provider configuration
- `example_performance.toml` - Performance tuning
- `production.toml` - Production settings example

## Quick Start

### 1. Initialize User Config

```bash
# Create ~/.codegraph with default configs
mkdir -p ~/.codegraph
cp config/default.toml ~/.codegraph/
```

### 2. Customize Your Configuration

```bash
# Edit your user config
nano ~/.codegraph/default.toml

# Or create environment-specific configs
cp ~/.codegraph/default.toml ~/.codegraph/development.toml
cp ~/.codegraph/default.toml ~/.codegraph/production.toml
```

### 3. Set Environment

```bash
export APP_ENV=development # Loads ~/.codegraph/development.toml
# or
export APP_ENV=production # Loads ~/.codegraph/production.toml
```

## Environment Variables

Override any config value using environment variables:

```bash
# Database backend
export CODEGRAPH__DATABASE__BACKEND=surrealdb

# SurrealDB connection
export CODEGRAPH__DATABASE__SURREALDB__CONNECTION=ws://localhost:8000

# Server port
export CODEGRAPH__SERVER__PORT=8080
```

## Further Documentation

- **[Full Configuration Guide](../docs/CONFIGURATION_GUIDE.md)** - Complete configuration documentation
- **[SurrealDB Guide](../docs/SURREALDB_GUIDE.md)** - SurrealDB-specific configuration
- **[Environment Variables](../docs/CONFIGURATION_GUIDE.md#environment-variables)** - Full list of env vars

## Development

For development, you can continue using this `./config` directory, but we recommend migrating to `~/.codegraph` for consistency:

```bash
# Option 1: Copy to ~/.codegraph
mkdir -p ~/.codegraph && cp config/*.toml ~/.codegraph/

# Option 2: Symlink (for active development)
ln -s $(pwd)/config ~/.codegraph

# Option 3: Keep using ./config (backward compatible)
# CodeGraph will use ./config if ~/.codegraph doesn't exist
```

## Need Help?

- Check the [Configuration Guide](../docs/CONFIGURATION_GUIDE.md)
- See example configs in this directory
- Use `CODEGRAPH__LOGGING__LEVEL=debug` to see which config directory is being used
22 changes: 21 additions & 1 deletion config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,30 @@ env = "development"
host = "0.0.0.0"
port = 3000

[rocksdb]
# Database configuration
[database]
# Backend options: "rocksdb" (default), "surrealdb"
backend = "rocksdb"

[database.rocksdb]
path = "data/graph.db"
read_only = false

[database.surrealdb]
# Example SurrealDB configuration (uncomment to use)
# connection = "ws://localhost:8000" # Standard SurrealDB WebSocket connection
# namespace = "codegraph"
# database = "graph"
# auto_migrate = true
# strict_mode = false
# Alternative: file://data/surrealdb/graph.db for embedded mode

# Deprecated: Legacy rocksdb configuration (use database.rocksdb instead)
# This is kept for backward compatibility
# [rocksdb]
# path = "data/graph.db"
# read_only = false

[vector]
dimension = 384
index = "ivf_flat"
Expand Down
20 changes: 20 additions & 0 deletions config/example_embedding.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,26 @@ api_base = "https://api.openai.com/v1"
max_retries = 3
timeout_secs = 30

# Example Jina configuration (uncomment to use)
# [embedding]
# provider = "jina"
# dimension = 1024
# cache_enabled = true
# cache_ttl_secs = 3600
# normalize_embeddings = true
#
# [embedding.jina]
# model = "jina-embeddings-v4"
# api_key_env = "JINA_API_KEY"
# api_base = "https://api.jina.ai/v1"
# max_retries = 3
# timeout_secs = 30
# task = "code.query"
# late_chunking = true
# enable_reranking = true
# reranking_model = "jina-reranker-v3"
# reranking_top_n = 10

[performance]
mode = "balanced"

Expand Down
64 changes: 64 additions & 0 deletions config/surrealdb_example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# CodeGraph Configuration with SurrealDB

[database]
# Select SurrealDB as the database backend
backend = "surrealdb"

# RocksDB configuration (not used when backend is surrealdb, but kept for backward compatibility)
[database.rocksdb]
path = "data/graph.db"
read_only = false

# SurrealDB configuration
[database.surrealdb]
# Connection string options:
# - WebSocket (default): "ws://localhost:8000"
# - Local file: "file://data/surrealdb/graph.db"
# - Memory (testing): "mem://"
# - Remote HTTP: "http://localhost:8000"
# - Remote HTTPS: "https://example.com:8000"
connection = "ws://localhost:8000"

# Namespace for multi-tenancy (default: "codegraph")
namespace = "codegraph"

# Database name (default: "graph")
database = "graph"

# Optional: Authentication credentials
# username = "root"
# password = "root" # Can also be set via CODEGRAPH__DATABASE__SURREALDB__PASSWORD env var

# Enable strict schema validation (default: false)
# When true, SurrealDB will enforce the defined schema strictly
# When false, allows for schema flexibility and easier migrations
strict_mode = false

# Auto-apply migrations on startup (default: true)
# When true, automatically runs pending migrations when connecting
auto_migrate = true

# Example: Remote SurrealDB server configuration
# [database.surrealdb]
# connection = "https://your-surrealdb-server.com:8000"
# namespace = "production"
# database = "codegraph"
# username = "admin"
# # Password should be set via environment variable:
# # CODEGRAPH__DATABASE__SURREALDB__PASSWORD=your_password
# strict_mode = true
# auto_migrate = false

[server]
host = "0.0.0.0"
port = 3000

[vector]
dimension = 1024

[logging]
level = "info"

[security]
require_auth = false
rate_limit_per_minute = 1200
Loading