Skip to main content
CodeGraph is configured through environment variables. This guide covers all available options.

Environment Variables

Neo4j Connection

VariableDescriptionDefault
Neo4j__UriNeo4j connection URIbolt://localhost:7687
Neo4j__UsernameNeo4j usernameneo4j
Neo4j__PasswordNeo4j password(required)
Neo4j__DatabaseNeo4j database nameneo4j
Alternative format also supported: NEO4J_URI, NEO4J_USERNAME, NEO4J_PASSWORD, NEO4J_DATABASE

API Server

VariableDescriptionDefault
API_PORTPort for the API server5050
API_HOSTHost to bind tolocalhost
CORS_ORIGINSAllowed CORS originshttp://localhost:5173

GPU Layout (GraphPU)

VariableDescriptionDefault
GRAPHPU_URIWebSocket URI for GPU serverws://localhost:9002
GRAPHPU_TIMEOUTLayout computation timeout (ms)30000

Configuration File

Create a .env file in the project root:
# Neo4j
Neo4j__Uri=bolt://localhost:7687
Neo4j__Username=neo4j
Neo4j__Password=your-secure-password
Neo4j__Database=neo4j

# API
API_PORT=5050
CORS_ORIGINS=http://localhost:5173,http://localhost:3000

# GPU Layout
GRAPHPU_URI=ws://localhost:9002

Encrypted Secrets

For production, encrypt your .env file:
# Encrypt
npx @dotenvx/dotenvx encrypt

# This creates .env.keys (keep this safe!)
# Your .env now contains encrypted values

# Run with decryption
npx @dotenvx/dotenvx run -- dotnet run --project src/adapters/driving/api
Never commit .env.keys to version control. Add it to your .gitignore.

Neo4j Configuration

Database Setup

CodeGraph works with Neo4j Community Edition (free) or Enterprise. Recommended settings:
# neo4j.conf
dbms.memory.heap.initial_size=512m
dbms.memory.heap.max_size=1G
dbms.memory.pagecache.size=512m

Multiple Databases

You can analyze different codebases into separate Neo4j databases:
# Analyze Project A
Neo4j__Database=project_a codegraph analyze ./ProjectA.sln

# Analyze Project B
Neo4j__Database=project_b codegraph analyze ./ProjectB.sln
Multiple databases require Neo4j Enterprise Edition or Neo4j 5.x Community with multi-database enabled.

Frontend Configuration

The web frontend reads configuration from environment variables at build time:
# In src/adapters/driving/web/.env
VITE_API_URL=http://localhost:5050
For production builds:
VITE_API_URL=https://api.yourdomain.com pnpm build

Layout Options

Configure the default layout algorithm settings:
{
  "layout": {
    "algorithm": "forceAtlas2",
    "iterations": 1000,
    "gravity": 1.0,
    "scalingRatio": 2.0,
    "strongGravityMode": false,
    "outboundAttractionDistribution": true
  }
}
These can be overridden per-request via the API.

What’s Next?