|
| 1 | +# CodeGraph Installation Guide |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +CodeGraph supports two installation profiles optimized for different use cases: |
| 6 | + |
| 7 | +1. **Local AI Profile** (`install-codegraph-osx.sh`) - Original script with local models |
| 8 | +2. **Cloud Profile** (`install-codegraph-cloud.sh`) - New script with cloud services ⭐ **Recommended for production** |
| 9 | + |
| 10 | +## Quick Comparison |
| 11 | + |
| 12 | +| Feature | Local AI (`install-codegraph-osx.sh`) | Cloud (`install-codegraph-cloud.sh`) | |
| 13 | +|---------|--------------------------------------|-------------------------------------| |
| 14 | +| **Embeddings** | ONNX (local), Ollama (local) | Jina (cloud, includes reranking) | |
| 15 | +| **LLM** | Qwen (local, resource-intensive) | Anthropic, OpenAI, Compatible APIs | |
| 16 | +| **Database** | RocksDB (embedded) | SurrealDB (scalable, distributed) | |
| 17 | +| **Setup** | Simpler, no external services | Requires SurrealDB + API keys | |
| 18 | +| **Cost** | Free, uses local compute | Paid API usage | |
| 19 | +| **Performance** | Good for small projects | Excellent for large codebases | |
| 20 | +| **Quality** | Good embeddings | Superior with Jina reranking | |
| 21 | + |
| 22 | +## Cloud Profile Installation (Recommended) |
| 23 | + |
| 24 | +### Prerequisites |
| 25 | + |
| 26 | +1. **macOS with Homebrew** |
| 27 | + ```bash |
| 28 | + # Install Homebrew if not already installed |
| 29 | + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
| 30 | + ``` |
| 31 | + |
| 32 | +2. **Rust toolchain** |
| 33 | + ```bash |
| 34 | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| 35 | + ``` |
| 36 | + |
| 37 | +### Installation Steps |
| 38 | + |
| 39 | +1. **Run the installation script:** |
| 40 | + ```bash |
| 41 | + ./install-codegraph-cloud.sh |
| 42 | + ``` |
| 43 | + |
| 44 | + This will: |
| 45 | + - Install FAISS (via Homebrew) |
| 46 | + - Install SurrealDB (via Homebrew) |
| 47 | + - Build CodeGraph with cloud features |
| 48 | + - Install to `~/.local/bin/codegraph` |
| 49 | + |
| 50 | +2. **Start SurrealDB:** |
| 51 | + |
| 52 | + Choose one of these options based on your needs: |
| 53 | + |
| 54 | + ```bash |
| 55 | + # Development (memory mode - data lost on restart) |
| 56 | + surreal start --log trace memory |
| 57 | + |
| 58 | + # Development with persistence |
| 59 | + surreal start --log trace file://$HOME/.codegraph/surrealdb |
| 60 | + |
| 61 | + # Production (recommended) |
| 62 | + surreal start --log trace rocksdb://$HOME/.codegraph/surrealdb |
| 63 | + ``` |
| 64 | + |
| 65 | + Keep this running in a separate terminal or use a process manager like `launchd`. |
| 66 | + |
| 67 | +3. **Set up API keys:** |
| 68 | + |
| 69 | + Add to your `~/.zshrc` or `~/.bashrc`: |
| 70 | + |
| 71 | + ```bash |
| 72 | + # Jina (required for embeddings) |
| 73 | + export JINA_API_KEY='your-jina-api-key' |
| 74 | + |
| 75 | + # Anthropic (recommended for LLM) |
| 76 | + export ANTHROPIC_API_KEY='your-anthropic-api-key' |
| 77 | + |
| 78 | + # Or OpenAI |
| 79 | + export OPENAI_API_KEY='your-openai-api-key' |
| 80 | + |
| 81 | + # CodeGraph configuration |
| 82 | + export CODEGRAPH_EMBEDDING_PROVIDER=jina |
| 83 | + export CODEGRAPH_LLM_PROVIDER=anthropic |
| 84 | + export CODEGRAPH_SURREALDB_URL=ws://localhost:8000 |
| 85 | + |
| 86 | + # Add to PATH |
| 87 | + export PATH="$HOME/.local/bin:$PATH" |
| 88 | + ``` |
| 89 | + |
| 90 | + Then reload: `source ~/.zshrc` |
| 91 | + |
| 92 | +4. **Verify installation:** |
| 93 | + ```bash |
| 94 | + codegraph --version |
| 95 | + ``` |
| 96 | + |
| 97 | +### Getting API Keys |
| 98 | + |
| 99 | +- **Jina AI**: https://jina.ai/ - Sign up for API access |
| 100 | +- **Anthropic**: https://console.anthropic.com/ - Get Claude API key |
| 101 | +- **OpenAI**: https://platform.openai.com/ - Get OpenAI API key |
| 102 | + |
| 103 | +## Local AI Profile Installation |
| 104 | + |
| 105 | +For development without cloud dependencies: |
| 106 | + |
| 107 | +```bash |
| 108 | +./install-codegraph-osx.sh |
| 109 | +``` |
| 110 | + |
| 111 | +This installs with: |
| 112 | +- ONNX embeddings (local, fast) |
| 113 | +- Ollama embeddings (local, higher quality) |
| 114 | +- Qwen integration (local LLM) |
| 115 | +- RocksDB (embedded database) |
| 116 | + |
| 117 | +No API keys needed, but requires more local compute resources. |
| 118 | + |
| 119 | +## Feature Flags Breakdown |
| 120 | + |
| 121 | +### Cloud Profile Features |
| 122 | +```bash |
| 123 | +ai-enhanced # Core AI + FAISS + embeddings |
| 124 | +codegraph-vector/jina # Jina cloud embeddings + reranking |
| 125 | +codegraph-graph/surrealdb # SurrealDB backend |
| 126 | +codegraph-ai/all-cloud-providers # Anthropic + OpenAI + compatible |
| 127 | +``` |
| 128 | + |
| 129 | +### Local Profile Features |
| 130 | +```bash |
| 131 | +ai-enhanced # Core AI + FAISS + embeddings |
| 132 | +qwen-integration # Local Qwen LLM |
| 133 | +embeddings # Base embedding support |
| 134 | +faiss # Vector search |
| 135 | +embeddings-ollama # Ollama embeddings |
| 136 | +codegraph-vector/onnx # ONNX embeddings |
| 137 | +``` |
| 138 | + |
| 139 | +## Usage After Installation |
| 140 | + |
| 141 | +### Initialize a Project |
| 142 | + |
| 143 | +```bash |
| 144 | +cd /path/to/your/project |
| 145 | +codegraph init . |
| 146 | +``` |
| 147 | + |
| 148 | +### Index Your Codebase |
| 149 | + |
| 150 | +```bash |
| 151 | +codegraph index . |
| 152 | +``` |
| 153 | + |
| 154 | +This auto-detects and indexes all supported languages: |
| 155 | +- Rust, Python, JavaScript, TypeScript |
| 156 | +- Swift, C#, Ruby, PHP |
| 157 | +- Go, Java, C++ |
| 158 | + |
| 159 | +### Using with Claude Code |
| 160 | + |
| 161 | +CodeGraph tools are automatically available in Claude Code via MCP. No additional configuration needed! |
| 162 | + |
| 163 | +Available tools: |
| 164 | +- `enhanced_search` - Semantic code search |
| 165 | +- `semantic_intelligence` - AI-powered code analysis |
| 166 | +- `impact_analysis` - Change impact assessment |
| 167 | +- `pattern_detection` - Find code patterns |
| 168 | +- `vector_search` - Similarity search |
| 169 | +- `graph_neighbors` - Explore dependencies |
| 170 | +- `graph_traverse` - Navigate code graph |
| 171 | +- `performance_metrics` - System monitoring |
| 172 | + |
| 173 | +## Troubleshooting |
| 174 | + |
| 175 | +### SurrealDB Connection Issues |
| 176 | + |
| 177 | +```bash |
| 178 | +# Check if SurrealDB is running |
| 179 | +ps aux | grep surreal |
| 180 | + |
| 181 | +# Verify connection |
| 182 | +curl http://localhost:8000/health |
| 183 | +``` |
| 184 | + |
| 185 | +### FAISS Linking Errors |
| 186 | + |
| 187 | +```bash |
| 188 | +brew reinstall faiss |
| 189 | +brew link faiss |
| 190 | +``` |
| 191 | + |
| 192 | +### API Key Issues |
| 193 | + |
| 194 | +Verify your keys are set: |
| 195 | +```bash |
| 196 | +echo $JINA_API_KEY |
| 197 | +echo $ANTHROPIC_API_KEY |
| 198 | +``` |
| 199 | + |
| 200 | +### Build Failures |
| 201 | + |
| 202 | +```bash |
| 203 | +# Clean and rebuild |
| 204 | +cargo clean |
| 205 | +./install-codegraph-cloud.sh |
| 206 | +``` |
| 207 | + |
| 208 | +## Advanced Configuration |
| 209 | + |
| 210 | +### Custom SurrealDB URL |
| 211 | + |
| 212 | +```bash |
| 213 | +export CODEGRAPH_SURREALDB_URL=ws://custom-host:8000 |
| 214 | +``` |
| 215 | + |
| 216 | +### Custom Install Directory |
| 217 | + |
| 218 | +```bash |
| 219 | +export CODEGRAPH_INSTALL_DIR=/custom/path |
| 220 | +./install-codegraph-cloud.sh |
| 221 | +``` |
| 222 | + |
| 223 | +### Mixing Local and Cloud Features |
| 224 | + |
| 225 | +You can customize feature flags by editing the script: |
| 226 | + |
| 227 | +```bash |
| 228 | +# Example: Use Jina but keep RocksDB |
| 229 | +FEATURE_FLAGS="ai-enhanced,codegraph-vector/jina,codegraph-ai/anthropic" |
| 230 | +``` |
| 231 | + |
| 232 | +## Recommendation |
| 233 | + |
| 234 | +**For production and serious development**: Use the **Cloud Profile** |
| 235 | +- Superior embedding quality with Jina |
| 236 | +- Scalable with SurrealDB |
| 237 | +- Better LLM responses with Claude/GPT |
| 238 | +- Professional reranking capabilities |
| 239 | + |
| 240 | +**For quick testing or offline work**: Use the **Local AI Profile** |
| 241 | +- No API costs |
| 242 | +- Works offline |
| 243 | +- Good for smaller projects |
| 244 | +- Faster initial setup |
| 245 | + |
| 246 | +## Next Steps |
| 247 | + |
| 248 | +1. Install using your chosen profile |
| 249 | +2. Set up API keys (if using cloud profile) |
| 250 | +3. Start SurrealDB (if using cloud profile) |
| 251 | +4. Index your first project |
| 252 | +5. Try the tools in Claude Code! |
| 253 | + |
| 254 | +For detailed tool documentation, see `CODEGRAPH-MCP-TOOLS-GUIDE.md`. |
0 commit comments