Expand description
API route definitions and handlers for the ICB server.
§Overview
This module exposes a REST API consumed by the ICB dashboard. All
routes are mounted under /api and operate on a shared
CodePropertyGraph that is built once at startup and held in an
Arc<Mutex<…>>.
§Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /api/graph | Subgraph filtered by kind, focus, depth, max nodes, cycle/dead highlights |
| GET | /api/node | Detailed information about a single function |
| GET | /api/functions | All function metrics |
| GET | /api/classes | All class metrics |
| GET | /api/files | Per‑file aggregate metrics |
| GET | /api/diff | Compare two projects or cached graphs |
| POST | /api/load | Load a new project, auto‑detecting its language |
| POST | /api/upload | Upload a ZIP archive and analyse it |
| GET | /api/call-tree | Call tree from a root function or forest of all roots (*) |
§Security
In its current form the server is intended for local use. The diff endpoint can read arbitrary files reachable from the server process; restrict network access appropriately.
Structs§
- Call
Tree 🔒Query - Parameters for the call‑tree endpoint.
- Diff
Query 🔒 - Parameters for the diff endpoint.
- Graph
Query 🔒 - Parameters for the graph endpoint.
- Load
Request 🔒 - Payload for the load endpoint.
- Tree
Node 🔒 - A single node in the call tree returned to the client.
Functions§
- build_
call_ 🔒tree - Recursively build a call tree from
node_idx. - configure
- find_
node_ 🔒index_ by_ name - Look up a node index by name (linear scan, used only for annotations).
- find_
root_ 🔒functions - Collect every function (or class) that has no incoming
Edge::Calledges – i.e. the roots of the call forest. - focal_
graph 🔒 - Build a subgraph centred on a specific function.
- get_
call_ 🔒tree - Return a call tree (or forest) starting from the requested root.
- get_
classes 🔒 - Return all class metrics.
- get_
diff 🔒 - Compare two projects or cached graphs and return a diff report.
- get_
files 🔒 - Return per‑file aggregate metrics.
- get_
functions 🔒 - Return all function metrics.
- get_
graph 🔒 - Return a subgraph of the main CPG, filtered by the given parameters.
- get_
node_ 🔒detail - Return detailed information about a single function.
- post_
load 🔒 - Load a new project, auto‑detecting its language.
- subgraph_
by_ 🔒kind - Build a subgraph limited to nodes of a given kind.