# hardikkhyal/graphcore architecture

> Architecture diagram of the GitHub repository hardikkhyal/graphcore, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hardikkhyal/graphcore
- Repository: https://github.com/hardikkhyal/graphcore

## Overview

#### 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: [`src/App.tsx`](https://github.com/hardikkhyal/graphcore/blob/main/src/App.tsx) (Workspace orchestration), [`src/services/graphEngine.ts`](https://github.com/hardikkhyal/graphcore/blob/main/src/services/graphEngine.ts) (Graph analysis engine), [`scripts/scan.js`](https://github.com/hardikkhyal/graphcore/blob/main/scripts/scan.js) (Repository scanner), [`src/components/GraphCanvas.tsx`](https://github.com/hardikkhyal/graphcore/blob/main/src/components/GraphCanvas.tsx) (Spatial graph canvas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Browser App"]
  node_web_entry["React entry<br/>entrypoint<br/>[main.tsx]"]
  node_app["Workspace orchestration<br/>React application<br/>[App.tsx]"]
  node_header["Workspace actions<br/>React component<br/>[Header.tsx]"]
  node_upload["Folder and snippet ingestion<br/>React component<br/>[UploadModal.tsx]"]
  node_canvas["Spatial graph canvas<br/>Canvas renderer<br/>[GraphCanvas.tsx]"]
  node_inspector["Node inspector<br/>analysis UI<br/>[NodeInspector.tsx]"]
  node_blast_radius["Blast-radius panel<br/>analysis UI"]
  node_rules["Architecture rules<br/>modal UI<br/>[RulesModal.tsx]"]
  node_mcp["AI context packaging<br/>modal UI<br/>[McpModal.tsx]"]
end

subgraph group_analysis["Analysis Pipeline"]
  node_source_input["Local source files<br/>browser or workspace input"]
  node_parser["Source parser<br/>JS/TS parser<br/>[tsParser.ts]"]
  node_graph_model["Canonical graph model<br/>domain model<br/>[graph.ts]"]
  node_engine{{"Graph analysis engine<br/>[graphEngine.ts]"}}
end

subgraph group_vscode["VS Code Integration"]
  node_extension["Extension host<br/>VS Code extension<br/>[extension.ts]"]
  node_bridge["Webview bridge<br/>message bridge<br/>[vscodeBridge.ts]"]
end

subgraph group_cli["Offline CLI"]
  node_scan_cli["Repository scanner<br/>offline CLI<br/>[scan.js]"]
  node_graph_artifact["Graph artifact<br/>generated output"]
end

node_web_entry -->|"mounts"| node_app
node_app -->|"hosts"| node_header
node_app -->|"opens"| node_upload
node_app -->|"renders graph"| node_canvas
node_canvas -->|"selection events"| node_app
node_app -->|"selected entity"| node_inspector
node_app -->|"analysis results"| node_blast_radius
node_app -->|"rule workflows"| node_rules
node_app -->|"selected subgraph"| node_mcp
node_upload -->|"reads"| node_source_input
node_source_input -->|"source text"| node_parser
node_parser -->|"parsed telemetry"| node_engine
node_graph_model -->|"defines outputs"| node_engine
node_engine -->|"graph topology"| node_canvas
node_engine -->|"symbols and metadata"| node_inspector
node_engine -->|"traversal and risk"| node_blast_radius
node_engine -->|"classification and edges"| node_rules
node_engine -->|"graph subgraphs"| node_mcp
node_extension -->|"connects webview"| node_bridge
node_bridge -->|"workspace input and navigation"| node_app
node_extension -->|"scans workspace"| node_source_input
node_scan_cli -->|"scans files"| node_parser
node_scan_cli -->|"builds graph"| node_engine
node_scan_cli -->|"emits"| node_graph_artifact

click node_web_entry "https://github.com/hardikkhyal/graphcore/blob/main/src/main.tsx"
click node_app "https://github.com/hardikkhyal/graphcore/blob/main/src/App.tsx"
click node_header "https://github.com/hardikkhyal/graphcore/blob/main/src/components/Header.tsx"
click node_upload "https://github.com/hardikkhyal/graphcore/blob/main/src/components/UploadModal.tsx"
click node_canvas "https://github.com/hardikkhyal/graphcore/blob/main/src/components/GraphCanvas.tsx"
click node_inspector "https://github.com/hardikkhyal/graphcore/blob/main/src/components/NodeInspector.tsx"
click node_blast_radius "https://github.com/hardikkhyal/graphcore/blob/main/src/components/BlastRadiusPanel.tsx"
click node_rules "https://github.com/hardikkhyal/graphcore/blob/main/src/components/RulesModal.tsx"
click node_mcp "https://github.com/hardikkhyal/graphcore/blob/main/src/components/McpModal.tsx"
click node_parser "https://github.com/hardikkhyal/graphcore/blob/main/src/services/tsParser.ts"
click node_graph_model "https://github.com/hardikkhyal/graphcore/blob/main/src/types/graph.ts"
click node_engine "https://github.com/hardikkhyal/graphcore/blob/main/src/services/graphEngine.ts"
click node_extension "https://github.com/hardikkhyal/graphcore/blob/main/src/extension.ts"
click node_bridge "https://github.com/hardikkhyal/graphcore/blob/main/src/services/vscodeBridge.ts"
click node_scan_cli "https://github.com/hardikkhyal/graphcore/blob/main/scripts/scan.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_entry,node_app,node_header,node_upload,node_canvas,node_inspector,node_blast_radius,node_rules,node_mcp toneBlue
class node_source_input,node_parser,node_graph_model,node_engine toneAmber
class node_extension,node_bridge toneMint
class node_scan_cli,node_graph_artifact toneRose
```

## Components

### Browser App

- [React entry](https://github.com/hardikkhyal/graphcore/blob/main/src/main.tsx): entrypoint · `src/main.tsx`
- [Workspace orchestration](https://github.com/hardikkhyal/graphcore/blob/main/src/App.tsx): React application · Coordinates ingestion, selection, modal workflows, and analysis panels. · `src/App.tsx`
- [Workspace actions](https://github.com/hardikkhyal/graphcore/blob/main/src/components/Header.tsx): React component · `src/components/Header.tsx`
- [Folder and snippet ingestion](https://github.com/hardikkhyal/graphcore/blob/main/src/components/UploadModal.tsx): React component · `src/components/UploadModal.tsx`
- [Spatial graph canvas](https://github.com/hardikkhyal/graphcore/blob/main/src/components/GraphCanvas.tsx): Canvas renderer · Renders layout and emits selection and navigation events. · `src/components/GraphCanvas.tsx`
- [Node inspector](https://github.com/hardikkhyal/graphcore/blob/main/src/components/NodeInspector.tsx): analysis UI · `src/components/NodeInspector.tsx`
- [Blast-radius panel](https://github.com/hardikkhyal/graphcore/blob/main/src/components/BlastRadiusPanel.tsx): analysis UI · `src/components/BlastRadiusPanel.tsx`
- [Architecture rules](https://github.com/hardikkhyal/graphcore/blob/main/src/components/RulesModal.tsx): modal UI · `src/components/RulesModal.tsx`
- [AI context packaging](https://github.com/hardikkhyal/graphcore/blob/main/src/components/McpModal.tsx): modal UI · Packages selected subgraphs as local token-conscious context. · `src/components/McpModal.tsx`

### Analysis Pipeline

- **Local source files**: browser or workspace input · Browser file APIs or VS Code workspace supply source files.
- [Source parser](https://github.com/hardikkhyal/graphcore/blob/main/src/services/tsParser.ts): JS/TS parser · Extracts structural and dependency telemetry from JS/TS-family files. · `src/services/tsParser.ts`
- [Canonical graph model](https://github.com/hardikkhyal/graphcore/blob/main/src/types/graph.ts): domain model · Defines nodes, edges, symbols, metadata, and analysis fields. · `src/types/graph.ts`
- [Graph analysis engine](https://github.com/hardikkhyal/graphcore/blob/main/src/services/graphEngine.ts): analysis engine · Builds topology, classification, traversal, risk, and flow outputs. · `src/services/graphEngine.ts`

### VS Code Integration

- [Extension host](https://github.com/hardikkhyal/graphcore/blob/main/src/extension.ts): VS Code extension · Opens the graph, scans workspaces, and supports editor navigation. · `src/extension.ts`
- [Webview bridge](https://github.com/hardikkhyal/graphcore/blob/main/src/services/vscodeBridge.ts): message bridge · Abstracts React webview and VS Code API messaging. · `src/services/vscodeBridge.ts`

### Offline CLI

- [Repository scanner](https://github.com/hardikkhyal/graphcore/blob/main/scripts/scan.js): offline CLI · Scans large repositories and emits a graph artifact under dist/. · `scripts/scan.js`
- **Graph artifact**: generated output

## Connections

- 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
