Skip to main content

Crate vibe_graph_api

Crate vibe_graph_api 

Source
Expand description

REST + WebSocket API service for Vibe-Graph.

This crate provides a clean API layer that can be consumed by any frontend. It separates data serving from visualization concerns.

§Endpoints

§Graph & WebSocket API (stateful, for visualization)

  • GET /api/health - Health check with node/edge counts
  • GET /api/graph - Full SourceCodeGraph JSON
  • GET /api/graph/nodes - Nodes only
  • GET /api/graph/edges - Edges only
  • GET /api/graph/metadata - Graph metadata
  • GET /api/git/changes - Current git change snapshot
  • GET /api/ws - WebSocket for real-time updates

§Operations API (stateless, for CLI-like operations)

  • POST /api/ops/sync - Sync a codebase
  • GET /api/ops/sync?source=... - Sync with query params
  • POST /api/ops/graph - Build source code graph
  • GET /api/ops/graph?path=... - Build graph with query params
  • GET /api/ops/status?path=... - Get workspace status
  • GET /api/ops/load?path=... - Load project from .self
  • DELETE /api/ops/clean?path=... - Clean .self folder
  • GET /api/ops/git-changes?path=... - Get git changes

§Git Commands API (for executing git operations)

  • POST /api/git/cmd/add - Stage files
  • POST /api/git/cmd/commit - Create commit
  • POST /api/git/cmd/reset - Unstage files
  • GET /api/git/cmd/branches - List branches
  • POST /api/git/cmd/checkout - Switch branch
  • GET /api/git/cmd/log - Commit history
  • GET /api/git/cmd/diff - Get diff

§Usage

use vibe_graph_api::{create_api_router, create_api_state, create_ops_router};
use vibe_graph_ops::{Config, OpsContext};

// For visualization server with pre-loaded graph
let graph = vibe_graph_core::SourceCodeGraph::default();
let state = create_api_state(graph);
let router = create_api_router(state);

// For operations API
let config = Config::load().unwrap();
let ctx = OpsContext::new(config);
let ops_router = create_ops_router(ctx);

Structs§

ApiResponse
Response wrapper with timestamp.
ApiState
Shared application state for the API.

Enums§

WsClientMessage
WebSocket message sent from client to server.
WsServerMessage
WebSocket message sent from server to client.

Functions§

create_api_router
Create the API router with all endpoints.
create_api_state
Create a new API state with the given graph.
create_api_state_with_changes
Create a new API state with the given graph and git changes.
create_file_router
Create a file content router for serving workspace files.
create_full_api_router
Create a combined API router with both graph/ws and ops endpoints.
create_full_api_router_with_git
Create a complete API router including git commands (single-repo).
create_full_api_router_with_git_multi
Create a complete API router including git commands (multi-repo).
create_git_commands_router
Create a git commands router for a single-repo workspace.
create_git_commands_router_multi
Create a git commands router for a multi-repo workspace.
create_ops_router
Create the operations router with all ops endpoints.