# aksh1810/gitvize architecture

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

- Interactive diagram: https://gitdiagram.com/aksh1810/gitvize
- Repository: https://github.com/aksh1810/gitvize

## Overview

#### Purpose and Entry Points
Gitvize is a Next.js application that turns a public GitHub repository into interactive views of its files, code relationships, architecture, dependencies, commits, branches, and contributors. The landing input starts at `src/app/page.tsx`; repository views resolve through `src/app/[owner]/[repo]/page.tsx` and the client orchestrator `src/app/[owner]/[repo]/repo-page-client.tsx`.

#### Repository Acquisition Boundary
Server routes proxy GitHub access rather than exposing GitHub calls directly from visualization components. The central repository endpoint is `src/app/api/github/repo/route.ts`; specialized endpoints provide access validation, incremental SSE loading, commit pagination, and file-content retrieval under `src/app/api/github/repo/access/route.ts`, `src/app/api/github/repo/stream/route.ts`, and `src/app/api/github/repo/files/route.ts`. `src/lib/github.ts` encapsulates GitHub API fetching and optional PAT use.

#### Client Dashboard and Visualization Shell
The repository client composes metadata, onboarding/progress states, settings, and tab navigation before mounting visualization-specific components. Key dashboard boundaries are `src/app/[owner]/[repo]/repo-page-client.tsx`, `src/components/dashboard/repo-overview.tsx`, and `src/components/dashboard/pipeline-status.tsx`. Browser-held GitHub tokens and Gemini keys allow optional authenticated GitHub access and AI features without making them core persisted user accounts.

#### Code Analysis and Knowledge-Graph Pipeline
Source content is fetched from GitHub, parsed into symbols/imports, and transformed into typed file/symbol relationship graphs. `src/lib/symbol-parser.ts` handles multi-language symbol and import extraction; `src/lib/graph-builder.ts` builds graph nodes and edges; `src/lib/impact-analyzer.ts` supports relationship/impact analysis. Heavy analysis and force simulation can move into browser workers at `src/workers/symbol-analysis.worker.ts`, `src/workers/file-tree-sim.worker.ts`, and `src/workers/knowledge-graph-sim.worker.ts`.

#### Graph Rendering and Interaction
Interactive graph surfaces are isolated in diagram components, separating graph construction from rendering. The file/code graph is represented by `src/components/diagrams/file-tree-graph.tsx` and `src/components/diagrams/knowledge-graph.tsx`; dependency visualization is `src/components/diagrams/dependency-graph.tsx`; commit and branch topology use `src/components/diagrams/git-rail-graph.tsx` and `src/components/diagrams/branch-graph.tsx`. Graph/layout data can be cached through `src/lib/graph-cache.ts` and seeded server-side by `src/app/api/graph/seed/route.ts`.

#### Architecture and AI Generation
Deterministic architecture diagrams derive Mermaid source from repository structure and dependency relationships via `src/lib/mermaid-generator.ts`, rendered by `src/components/diagrams/architecture-diagram.tsx` and `src/components/diagrams/mermaid-diagram.tsx`. Premium analysis enters through `src/app/api/analyze/route.ts` and `src/lib/ai.ts`, which integrates Gemini (`gemini-2.5-flash`) and credit/key handling in `src/lib/ai-credits.ts`. This is an optional external-service boundary; deterministic diagramming remains available without it.

#### Supporting Data, Runtime, and Persistence
The app runs on the Next.js App Router with React client components, API route handlers, Web Workers, and browser session/local storage caches. Dependency manifests are interpreted by `src/lib/dep-parser.ts`; client search is `src/lib/search-engine.ts`; diagram cache is `src/lib/diagram-cache.ts`. An optional Drizzle/Postgres persistence layer is defined by `src/db/index.ts` and `src/db/schema.ts`, but GitHub retrieval and client-side derived graph state are the primary operational flow.

Main entry points: [`src/lib/graph-builder.ts`](https://github.com/aksh1810/gitvize/blob/main/src/lib/graph-builder.ts) (Typed graph builder), [`src/app/[owner]/[repo]/repo-page-client.tsx`](https://github.com/aksh1810/gitvize/blob/main/src/app/%5Bowner%5D/%5Brepo%5D/repo-page-client.tsx) (Dashboard orchestrator), [`src/app/api/github/repo/stream/route.ts`](https://github.com/aksh1810/gitvize/blob/main/src/app/api/github/repo/stream/route.ts) (Access, stream, and files APIs), [`src/lib/symbol-parser.ts`](https://github.com/aksh1810/gitvize/blob/main/src/lib/symbol-parser.ts) (Symbol and import parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Next.js UI"]
  node_landing["Repository input<br/>page<br/>[page.tsx]"]
  node_repo_route["Repository route<br/>page<br/>[page.tsx]"]
  node_repo_client["Dashboard orchestrator<br/>client component"]
  node_dashboard["Overview and pipeline UI<br/>dashboard components<br/>[repo-overview.tsx]"]
end

subgraph group_github["GitHub acquisition"]
  node_repo_api{{"Repository API<br/>route handler<br/>[route.ts]"}}
  node_github_endpoints{{"Access, stream, and files APIs<br/>route handlers<br/>[route.ts]"}}
  node_github_client["GitHub client<br/>API integration<br/>[github.ts]"]
  node_github(("GitHub<br/>external service"))
end

subgraph group_analysis["Analysis pipeline"]
  node_symbol_parser["Symbol and import parser<br/>analysis library<br/>[symbol-parser.ts]"]
  node_graph_builder["Typed graph builder<br/>analysis library<br/>[graph-builder.ts]"]
  node_impact["Impact analyzer<br/>analysis library<br/>[impact-analyzer.ts]"]
  node_workers["Browser analysis workers<br/>Web Workers"]
  node_graph_cache[("Graph cache and seed API<br/>cache boundary<br/>[graph-cache.ts]")]
end

subgraph group_visuals["Diagram rendering"]
  node_file_graph["File and knowledge graphs<br/>diagram components"]
  node_dependency_graph["Dependency graph<br/>diagram component"]
  node_git_graphs["Commit and branch graphs<br/>diagram components<br/>[git-rail-graph.tsx]"]
  node_mermaid_generator["Architecture generator<br/>diagram generator"]
  node_architecture_diagram["Architecture diagram<br/>diagram component"]
end

subgraph group_optional["Optional services"]
  node_ai_api{{"Premium analysis API<br/>route handler<br/>[route.ts]"}}
  node_gemini(("Gemini integration<br/>AI integration<br/>[ai.ts]"))
  node_postgres[("Drizzle/Postgres<br/>optional persistence<br/>[index.ts]")]
end

node_landing -->|"opens repository"| node_repo_route
node_repo_route -->|"mounts"| node_repo_client
node_repo_client -->|"composes"| node_dashboard
node_repo_client -->|"loads repository"| node_repo_api
node_repo_client -->|"streams and fetches files"| node_github_endpoints
node_repo_api -->|"uses"| node_github_client
node_github_endpoints -->|"uses"| node_github_client
node_github_client -->|"fetches public or PAT data"| node_github
node_github_endpoints -->|"source content"| node_symbol_parser
node_symbol_parser -->|"symbols and imports"| node_graph_builder
node_graph_builder -->|"relationship graph"| node_impact
node_symbol_parser -.->|"offloads heavy analysis"| node_workers
node_graph_builder -.->|"offloads force layout"| node_workers
node_graph_builder -->|"caches graph and layout"| node_graph_cache
node_graph_builder -->|"file and symbol graph"| node_file_graph
node_graph_builder -->|"dependency relationships"| node_dependency_graph
node_github_endpoints -->|"commit and branch data"| node_git_graphs
node_graph_builder -->|"structure and dependencies"| node_mermaid_generator
node_mermaid_generator -->|"Mermaid source"| node_architecture_diagram
node_repo_client -.->|"optional premium analysis"| node_ai_api
node_ai_api -->|"generates analysis"| node_gemini
node_ai_api -.->|"optional credits persistence"| node_postgres

click node_landing "https://github.com/aksh1810/gitvize/blob/main/src/app/page.tsx"
click node_repo_route "https://github.com/aksh1810/gitvize/blob/main/src/app/%5Bowner%5D/%5Brepo%5D/page.tsx"
click node_repo_client "https://github.com/aksh1810/gitvize/blob/main/src/app/%5Bowner%5D/%5Brepo%5D/repo-page-client.tsx"
click node_dashboard "https://github.com/aksh1810/gitvize/blob/main/src/components/dashboard/repo-overview.tsx"
click node_repo_api "https://github.com/aksh1810/gitvize/blob/main/src/app/api/github/repo/route.ts"
click node_github_endpoints "https://github.com/aksh1810/gitvize/blob/main/src/app/api/github/repo/stream/route.ts"
click node_github_client "https://github.com/aksh1810/gitvize/blob/main/src/lib/github.ts"
click node_symbol_parser "https://github.com/aksh1810/gitvize/blob/main/src/lib/symbol-parser.ts"
click node_graph_builder "https://github.com/aksh1810/gitvize/blob/main/src/lib/graph-builder.ts"
click node_impact "https://github.com/aksh1810/gitvize/blob/main/src/lib/impact-analyzer.ts"
click node_workers "https://github.com/aksh1810/gitvize/blob/main/src/workers/symbol-analysis.worker.ts"
click node_graph_cache "https://github.com/aksh1810/gitvize/blob/main/src/lib/graph-cache.ts"
click node_file_graph "https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/file-tree-graph.tsx"
click node_dependency_graph "https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/dependency-graph.tsx"
click node_git_graphs "https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/git-rail-graph.tsx"
click node_mermaid_generator "https://github.com/aksh1810/gitvize/blob/main/src/lib/mermaid-generator.ts"
click node_architecture_diagram "https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/architecture-diagram.tsx"
click node_ai_api "https://github.com/aksh1810/gitvize/blob/main/src/app/api/analyze/route.ts"
click node_gemini "https://github.com/aksh1810/gitvize/blob/main/src/lib/ai.ts"
click node_postgres "https://github.com/aksh1810/gitvize/blob/main/src/db/index.ts"

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_landing,node_repo_route,node_repo_client,node_dashboard toneBlue
class node_repo_api,node_github_endpoints,node_github_client,node_github toneAmber
class node_symbol_parser,node_graph_builder,node_impact,node_workers,node_graph_cache toneMint
class node_file_graph,node_dependency_graph,node_git_graphs,node_mermaid_generator,node_architecture_diagram toneRose
class node_ai_api,node_gemini,node_postgres toneIndigo
```

## Components

### Next.js UI

- [Repository input](https://github.com/aksh1810/gitvize/blob/main/src/app/page.tsx): page · `src/app/page.tsx`
- [Repository route](https://github.com/aksh1810/gitvize/blob/main/src/app/%5Bowner%5D/%5Brepo%5D/page.tsx): page · `src/app/[owner]/[repo]/page.tsx`
- [Dashboard orchestrator](https://github.com/aksh1810/gitvize/blob/main/src/app/%5Bowner%5D/%5Brepo%5D/repo-page-client.tsx): client component · Composes loading states, settings, tabs, and repository views. · `src/app/[owner]/[repo]/repo-page-client.tsx`
- [Overview and pipeline UI](https://github.com/aksh1810/gitvize/blob/main/src/components/dashboard/repo-overview.tsx): dashboard components · `src/components/dashboard/repo-overview.tsx`

### GitHub acquisition

- [Repository API](https://github.com/aksh1810/gitvize/blob/main/src/app/api/github/repo/route.ts): route handler · Central server-side repository acquisition endpoint. · `src/app/api/github/repo/route.ts`
- [Access, stream, and files APIs](https://github.com/aksh1810/gitvize/blob/main/src/app/api/github/repo/stream/route.ts): route handlers · Validate access, stream incremental loading, and retrieve file content. · `src/app/api/github/repo/stream/route.ts`
- [GitHub client](https://github.com/aksh1810/gitvize/blob/main/src/lib/github.ts): API integration · Uses an optional personal access token for GitHub fetching. · `src/lib/github.ts`
- **GitHub**: external service

### Analysis pipeline

- [Symbol and import parser](https://github.com/aksh1810/gitvize/blob/main/src/lib/symbol-parser.ts): analysis library · Extracts multi-language symbols and imports from source content. · `src/lib/symbol-parser.ts`
- [Typed graph builder](https://github.com/aksh1810/gitvize/blob/main/src/lib/graph-builder.ts): analysis library · Builds file and symbol relationship nodes and edges. · `src/lib/graph-builder.ts`
- [Impact analyzer](https://github.com/aksh1810/gitvize/blob/main/src/lib/impact-analyzer.ts): analysis library · `src/lib/impact-analyzer.ts`
- [Browser analysis workers](https://github.com/aksh1810/gitvize/blob/main/src/workers/symbol-analysis.worker.ts): Web Workers · Offloads symbol analysis and force simulation. · `src/workers/symbol-analysis.worker.ts`
- [Graph cache and seed API](https://github.com/aksh1810/gitvize/blob/main/src/lib/graph-cache.ts): cache boundary · Caches layout data and can receive server-side seeds. · `src/lib/graph-cache.ts`

### Diagram rendering

- [File and knowledge graphs](https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/file-tree-graph.tsx): diagram components · `src/components/diagrams/file-tree-graph.tsx`
- [Dependency graph](https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/dependency-graph.tsx): diagram component · `src/components/diagrams/dependency-graph.tsx`
- [Commit and branch graphs](https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/git-rail-graph.tsx): diagram components · `src/components/diagrams/git-rail-graph.tsx`
- [Architecture generator](https://github.com/aksh1810/gitvize/blob/main/src/lib/mermaid-generator.ts): diagram generator · Derives deterministic Mermaid architecture from structure and dependencies. · `src/lib/mermaid-generator.ts`
- [Architecture diagram](https://github.com/aksh1810/gitvize/blob/main/src/components/diagrams/architecture-diagram.tsx): diagram component · `src/components/diagrams/architecture-diagram.tsx`

### Optional services

- [Premium analysis API](https://github.com/aksh1810/gitvize/blob/main/src/app/api/analyze/route.ts): route handler · Optional AI analysis entry point. · `src/app/api/analyze/route.ts`
- [Gemini integration](https://github.com/aksh1810/gitvize/blob/main/src/lib/ai.ts): AI integration · Uses Gemini with client-provided keys or credit handling. · `src/lib/ai.ts`
- [Drizzle/Postgres](https://github.com/aksh1810/gitvize/blob/main/src/db/index.ts): optional persistence · `src/db/index.ts`

## Connections

- Repository input → Repository route: opens repository
- Repository route → Dashboard orchestrator: mounts
- Dashboard orchestrator → Overview and pipeline UI: composes
- Dashboard orchestrator → Repository API: loads repository
- Dashboard orchestrator → Access, stream, and files APIs: streams and fetches files
- Repository API → GitHub client: uses
- Access, stream, and files APIs → GitHub client: uses
- GitHub client → GitHub: fetches public or PAT data
- Access, stream, and files APIs → Symbol and import parser: source content
- Symbol and import parser → Typed graph builder: symbols and imports
- Typed graph builder → Impact analyzer: relationship graph
- Symbol and import parser → Browser analysis workers: offloads heavy analysis
- Typed graph builder → Browser analysis workers: offloads force layout
- Typed graph builder → Graph cache and seed API: caches graph and layout
- Typed graph builder → File and knowledge graphs: file and symbol graph
- Typed graph builder → Dependency graph: dependency relationships
- Access, stream, and files APIs → Commit and branch graphs: commit and branch data
- Typed graph builder → Architecture generator: structure and dependencies
- Architecture generator → Architecture diagram: Mermaid source
- Dashboard orchestrator → Premium analysis API: optional premium analysis
- Premium analysis API → Gemini integration: generates analysis
- Premium analysis API → Drizzle/Postgres: optional credits persistence
