How hardikkhyal/graphcore works
Purpose and Delivery Modes
GraphCore is a local-first TypeScript/JavaScript code-analysis product that turns source files into an interactive dependency/architecture graph, with refactor-impact, data-flow, rule, and AI-context views. It is delivered as both a Vite/React browser application and a VS Code extension/webview; an offline CLI preprocessor is also present. Entry points are src/main.tsx, src/extension.ts, and scripts/scan.js.
Application Shell and Interaction State
The React root mounts the workspace UI and coordinates ingestion, selected graph entities, modal workflows, and analysis panels. src/App.tsx is the primary orchestration boundary; src/components/Header.tsx exposes project-loading and workspace actions, while src/components/UploadModal.tsx handles folder/snippet ingestion.
Source Ingestion and Parsing Boundary
Local files are read through browser-native file APIs in standalone mode, or supplied from the VS Code workspace through an extension bridge. Source parsing is isolated from UI rendering in src/services/tsParser.ts; it recognizes JS/TS-family files and extracts structural/dependency telemetry. The CLI path in scripts/scan.js supports large-repository scanning and emits a graph artifact under dist/.
Graph Domain and Analysis Engine
The canonical graph model—nodes, edges, symbols, metadata, and analysis-oriented fields—is defined in src/types/graph.ts. src/services/graphEngine.ts transforms parsed source results into graph topology, architectural categorization, traversal results, and derived risk/flow information. This is the central computational boundary: UI consumers should operate on graph-domain outputs rather than raw source text or parser structures.
Spatial Visualization
src/components/GraphCanvas.tsx renders the graph with a custom HTML Canvas spatial layout, architectural lanes, dependency routing, animation, and level-of-detail behavior. It consumes graph-engine output and emits node-selection/navigation events upward. Canvas rendering is intentionally separate from inspector and analysis UI so visual interaction does not define graph semantics.
Analysis and Decision Surfaces
Selected nodes/symbols are examined in src/components/NodeInspector.tsx. Downstream dependency traversal and refactor-risk presentation live in src/components/BlastRadiusPanel.tsx. Architecture-rule authoring/enforcement is surfaced through src/components/RulesModal.tsx; these features depend on graph classification and edge direction rather than external services.
VS Code and MCP Integration
src/services/vscodeBridge.ts abstracts message passing between the React webview and VS Code APIs. src/extension.ts activates the extension, opens the graph experience, scans the active workspace, and supports editor navigation from inspected entities. src/components/McpModal.tsx packages selected graph subgraphs as token-conscious AI context; the repository describes this as local generation, not a hosted MCP or cloud backend.
Runtime, Build, and Deployment Shape
The browser runtime is React 18 + TypeScript, bundled by Vite and styled with Tailwind. vite.config.ts and package.json define the app/extension build surface; dist/index.html and dist/axiom-auto-telemetry.js indicate prebuilt webview/static assets. No server, database, remote API, or telemetry backend is represented in the repository tree; code parsing and graph computation are designed to remain on-device.
Main entry points: App.tsx Workspace orchestration · graphEngine.ts Graph analysis engine · scan.js Repository scanner · GraphCanvas.tsx Spatial graph canvas
Components 17
Browser App
- React entry
src/main.tsx - Workspace orchestration · Coordinates ingestion, selection, modal workflows, and analysis panels.
src/App.tsx - Workspace actions
src/components/Header.tsx - Folder and snippet ingestion
src/components/UploadModal.tsx - Spatial graph canvas · Renders layout and emits selection and navigation events.
src/components/GraphCanvas.tsx - Node inspector
src/components/NodeInspector.tsx - Blast-radius panel
src/components/BlastRadiusPanel.tsx - Architecture rules
src/components/RulesModal.tsx - AI context packaging · Packages selected subgraphs as local token-conscious context.
src/components/McpModal.tsx
Analysis Pipeline
- Local source files · Browser file APIs or VS Code workspace supply source files.
- Source parser · Extracts structural and dependency telemetry from JS/TS-family files.
src/services/tsParser.ts - Canonical graph model · Defines nodes, edges, symbols, metadata, and analysis fields.
src/types/graph.ts - Graph analysis engine · Builds topology, classification, traversal, risk, and flow outputs.
src/services/graphEngine.ts
VS Code Integration
- Extension host · Opens the graph, scans workspaces, and supports editor navigation.
src/extension.ts - Webview bridge · Abstracts React webview and VS Code API messaging.
src/services/vscodeBridge.ts
Offline CLI
- Repository scanner · Scans large repositories and emits a graph artifact under dist/.
scripts/scan.js - Graph artifact
Connections 24
- React entry → Workspace orchestration: mounts
- Workspace orchestration → Workspace actions: hosts
- Workspace orchestration → Folder and snippet ingestion: opens
- Workspace orchestration → Spatial graph canvas: renders graph
- Spatial graph canvas → Workspace orchestration: selection events
- Workspace orchestration → Node inspector: selected entity
- Workspace orchestration → Blast-radius panel: analysis results
- Workspace orchestration → Architecture rules: rule workflows
- Workspace orchestration → AI context packaging: selected subgraph
- Folder and snippet ingestion → Local source files: reads
- Local source files → Source parser: source text
- Source parser → Graph analysis engine: parsed telemetry
- Canonical graph model → Graph analysis engine: defines outputs
- Graph analysis engine → Spatial graph canvas: graph topology
- Graph analysis engine → Node inspector: symbols and metadata
- Graph analysis engine → Blast-radius panel: traversal and risk
- Graph analysis engine → Architecture rules: classification and edges
- Graph analysis engine → AI context packaging: graph subgraphs
- Extension host → Webview bridge: connects webview
- Webview bridge → Workspace orchestration: workspace input and navigation
- Extension host → Local source files: scans workspace
- Repository scanner → Source parser: scans files
- Repository scanner → Graph analysis engine: builds graph
- Repository scanner → Graph artifact: emits