|
| 1 | +# Code Graph Builder |
| 2 | + |
| 3 | +Created and maintained by Jagan Jijo. |
| 4 | + |
| 5 | +Portfolio: https://jagan-jijo.github.io/portfolio/ |
| 6 | + |
| 7 | +Code Graph Builder is a local-first codebase analysis tool with a FastAPI backend and a React frontend. |
| 8 | + |
| 9 | +It indexes a repository, builds a navigable code graph, and lets you: |
| 10 | + |
| 11 | +- analyze Python and PHP codebases |
| 12 | +- inspect files, modules, classes, functions, and methods |
| 13 | +- explore call, reference, import, and inheritance relationships |
| 14 | +- filter the graph to focus on code you wrote |
| 15 | +- optionally use Ollama, Open WebUI, or another OpenAI-compatible endpoint for model-assisted graph refinement |
| 16 | + |
| 17 | +This project is designed to run on a developer machine. Users can point it at their own local or self-hosted model endpoints. |
| 18 | + |
| 19 | +## What the app does |
| 20 | + |
| 21 | +The app has two parts: |
| 22 | + |
| 23 | +- Backend: scans a project, parses source files, builds graph nodes and edges, and exposes HTTP and WebSocket APIs |
| 24 | +- Frontend: provides the setup form, graph viewer, filters, node details, and progress UI |
| 25 | + |
| 26 | +Current graph features include: |
| 27 | + |
| 28 | +- repository, directory, file, and module structure |
| 29 | +- classes, functions, methods, interfaces, and traits |
| 30 | +- imports and module usage |
| 31 | +- call graph edges and unresolved call placeholders |
| 32 | +- inheritance edges |
| 33 | +- semantic reference hints for Python when available |
| 34 | +- graph filters for inferred edges, provenance, grouping, native library nodes, and third-party dependency nodes |
| 35 | + |
| 36 | +## Requirements |
| 37 | + |
| 38 | +- Python 3.11+ |
| 39 | +- Node.js 18+ |
| 40 | +- npm |
| 41 | + |
| 42 | +## Project layout |
| 43 | + |
| 44 | +- [backend](backend): FastAPI API, indexing pipeline, parsers, graph storage, model adapters |
| 45 | +- [frontend](frontend): React + TypeScript + Vite UI |
| 46 | +- [start.ps1](start.ps1): Windows startup helper |
| 47 | +- [start.cmd](start.cmd): Windows wrapper for PowerShell startup |
| 48 | +- [start.sh](start.sh): macOS/Linux startup helper |
| 49 | +- [requirements.txt](requirements.txt): Python dependencies |
| 50 | +- [package.json](package.json): root scripts for backend and frontend |
| 51 | + |
| 52 | +## Quick start |
| 53 | + |
| 54 | +### Windows |
| 55 | + |
| 56 | +From the project root: |
| 57 | + |
| 58 | +```powershell |
| 59 | +start.cmd |
| 60 | +``` |
| 61 | + |
| 62 | +Or: |
| 63 | + |
| 64 | +```powershell |
| 65 | +powershell -NoProfile -ExecutionPolicy Bypass -File .\start.ps1 |
| 66 | +``` |
| 67 | + |
| 68 | +### macOS / Linux |
| 69 | + |
| 70 | +From the project root: |
| 71 | + |
| 72 | +```bash |
| 73 | +chmod +x ./start.sh |
| 74 | +./start.sh |
| 75 | +``` |
| 76 | + |
| 77 | +## Manual start |
| 78 | + |
| 79 | +If you prefer to run each part yourself: |
| 80 | + |
| 81 | +### 1. Create the virtual environment and install backend dependencies |
| 82 | + |
| 83 | +Windows: |
| 84 | + |
| 85 | +```powershell |
| 86 | +py -3 -m venv .venv |
| 87 | +.\.venv\Scripts\pip.exe install -r requirements.txt |
| 88 | +``` |
| 89 | + |
| 90 | +macOS / Linux: |
| 91 | + |
| 92 | +```bash |
| 93 | +python3 -m venv .venv |
| 94 | +./.venv/bin/pip install -r requirements.txt |
| 95 | +``` |
| 96 | + |
| 97 | +### 2. Install frontend dependencies |
| 98 | + |
| 99 | +Root dependencies: |
| 100 | + |
| 101 | +```bash |
| 102 | +npm install |
| 103 | +``` |
| 104 | + |
| 105 | +Frontend dependencies: |
| 106 | + |
| 107 | +```bash |
| 108 | +cd frontend |
| 109 | +npm install |
| 110 | +cd .. |
| 111 | +``` |
| 112 | + |
| 113 | +### 3. Start the app |
| 114 | + |
| 115 | +Run both backend and frontend: |
| 116 | + |
| 117 | +```bash |
| 118 | +npm start |
| 119 | +``` |
| 120 | + |
| 121 | +This starts: |
| 122 | + |
| 123 | +- backend API on `http://127.0.0.1:8000` |
| 124 | +- frontend UI on `http://127.0.0.1:3000` |
| 125 | + |
| 126 | +## Configuration |
| 127 | + |
| 128 | +The backend reads configuration from environment variables in [backend/config.py](backend/config.py). It also loads a root `.env` file automatically. |
| 129 | + |
| 130 | +Recommended setup: |
| 131 | + |
| 132 | +1. Copy `.env.example` to `.env` |
| 133 | +2. Fill in only the values you need |
| 134 | +3. Start the app |
| 135 | + |
| 136 | +Example: |
| 137 | + |
| 138 | +```bash |
| 139 | +cp .env.example .env |
| 140 | +``` |
| 141 | + |
| 142 | +On Windows PowerShell: |
| 143 | + |
| 144 | +```powershell |
| 145 | +Copy-Item .env.example .env |
| 146 | +``` |
| 147 | + |
| 148 | +### Core settings |
| 149 | + |
| 150 | +- `HOST`: backend bind address, default `127.0.0.1` |
| 151 | +- `PORT`: backend port, default `8000` |
| 152 | +- `PROJECTS_DIR`: where indexed project data is stored. If empty, the app uses the user home directory default. |
| 153 | +- `GRAPH_BACKEND`: graph storage backend, default `sqlite` |
| 154 | + |
| 155 | +### Model provider settings |
| 156 | + |
| 157 | +The app supports three provider styles: |
| 158 | + |
| 159 | +- Ollama native API |
| 160 | +- Open WebUI API |
| 161 | +- OpenAI-compatible API |
| 162 | + |
| 163 | +You can still override the provider and model settings in the UI per project, but these environment variables are the default values the backend will use. |
| 164 | + |
| 165 | +#### Ollama |
| 166 | + |
| 167 | +```env |
| 168 | +OLLAMA_BASE_URL=http://localhost:11434 |
| 169 | +OLLAMA_API_KEY= |
| 170 | +``` |
| 171 | + |
| 172 | +Notes: |
| 173 | + |
| 174 | +- Standard local Ollama usually does not require an API key |
| 175 | +- If you are exposing Ollama behind a proxy that requires auth, set `OLLAMA_API_KEY` |
| 176 | + |
| 177 | +#### Open WebUI |
| 178 | + |
| 179 | +```env |
| 180 | +OPENWEBUI_BASE_URL=http://localhost:3001 |
| 181 | +OPENWEBUI_API_KEY=your_openwebui_key |
| 182 | +``` |
| 183 | + |
| 184 | +The backend uses the Open WebUI API endpoints under `/api/...`, so the base URL should be the root of your Open WebUI server. |
| 185 | + |
| 186 | +#### OpenAI-compatible endpoint |
| 187 | + |
| 188 | +```env |
| 189 | +OPENAI_COMPATIBLE_BASE_URL=http://localhost:8001 |
| 190 | +OPENAI_COMPATIBLE_API_KEY=your_api_key |
| 191 | +``` |
| 192 | + |
| 193 | +The app appends `/v1` internally for the OpenAI-compatible adapter, so use the server root as the base URL unless your deployment requires a different shape. |
| 194 | + |
| 195 | +## Example `.env` setups |
| 196 | + |
| 197 | +### Local Ollama only |
| 198 | + |
| 199 | +```env |
| 200 | +HOST=127.0.0.1 |
| 201 | +PORT=8000 |
| 202 | +GRAPH_BACKEND=sqlite |
| 203 | +OLLAMA_BASE_URL=http://localhost:11434 |
| 204 | +OLLAMA_API_KEY= |
| 205 | +``` |
| 206 | + |
| 207 | +### Open WebUI only |
| 208 | + |
| 209 | +```env |
| 210 | +HOST=127.0.0.1 |
| 211 | +PORT=8000 |
| 212 | +GRAPH_BACKEND=sqlite |
| 213 | +OPENWEBUI_BASE_URL=http://localhost:3001 |
| 214 | +OPENWEBUI_API_KEY=your_openwebui_key |
| 215 | +``` |
| 216 | + |
| 217 | +## Using your own Ollama or Open WebUI instance |
| 218 | + |
| 219 | +After the app starts: |
| 220 | + |
| 221 | +1. Open the UI in the browser |
| 222 | +2. In the setup form, choose the provider |
| 223 | +3. Set the base URL and API key if needed |
| 224 | +4. Test the connection |
| 225 | +5. List available models |
| 226 | +6. Choose planner, code, and query models |
| 227 | +7. Start analysis |
| 228 | + |
| 229 | +For most users: |
| 230 | + |
| 231 | +- Ollama base URL: `http://localhost:11434` |
| 232 | +- Open WebUI base URL: `http://localhost:3001` |
| 233 | + |
| 234 | +## Typical workflow |
| 235 | + |
| 236 | +1. Start the application |
| 237 | +2. Enter a local path or supported GitHub repository URL |
| 238 | +3. Choose language and analysis depth |
| 239 | +4. Optionally configure model refinement |
| 240 | +5. Run indexing |
| 241 | +6. Explore the graph and node details |
| 242 | +7. Use graph controls to hide native library and third-party dependency noise |
| 243 | + |
| 244 | +## Notes for publishing this repo |
| 245 | + |
| 246 | +If you are distributing this for other users: |
| 247 | + |
| 248 | +- commit [README.md](README.md) |
| 249 | +- commit [LICENSE](LICENSE) |
| 250 | +- commit [.env.example](.env.example) |
| 251 | +- do not commit a real `.env` with private keys |
| 252 | +- tell users to provide their own Ollama or Open WebUI endpoint details |
| 253 | + |
| 254 | +## Author |
| 255 | + |
| 256 | +- Creator: Jagan Jijo |
| 257 | +- Portfolio: https://jagan-jijo.github.io/portfolio/ |
| 258 | + |
| 259 | +## Troubleshooting |
| 260 | + |
| 261 | +### Backend does not start |
| 262 | + |
| 263 | +- make sure Python 3.11+ is installed |
| 264 | +- make sure `.venv` exists or rerun the startup script |
| 265 | +- reinstall dependencies with `pip install -r requirements.txt` |
| 266 | + |
| 267 | +### Frontend does not start |
| 268 | + |
| 269 | +- make sure Node.js 18+ is installed |
| 270 | +- run `npm install` in the root and in [frontend](frontend) |
| 271 | + |
| 272 | +### Model connection test fails |
| 273 | + |
| 274 | +- verify the base URL is correct |
| 275 | +- verify your Ollama or Open WebUI server is already running |
| 276 | +- verify the API key if your endpoint requires one |
| 277 | + |
| 278 | +### Graph looks noisy |
| 279 | + |
| 280 | +Use the graph controls to: |
| 281 | + |
| 282 | +- hide inferred edges below the confidence threshold |
| 283 | +- hide native / built-in library nodes |
| 284 | +- hide third-party dependency nodes |
| 285 | +- group functions by module lane |
| 286 | + |
| 287 | +## License |
| 288 | + |
| 289 | +This project is licensed under the custom attribution license in [LICENSE](LICENSE). |
| 290 | + |
| 291 | +Summary: |
| 292 | + |
| 293 | +- free for personal use |
| 294 | +- free for commercial use |
| 295 | +- you must keep the original credit to Jagan Jijo |
| 296 | +- if you redistribute or publish modified versions, the attribution must remain intact |
| 297 | + |
| 298 | +This summary is only a convenience note. The [LICENSE](LICENSE) file is the controlling text. |
0 commit comments