How aksh1810/gitvize works
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: graph-builder.ts Typed graph builder · repo-page-client.tsx Dashboard orchestrator · route.ts Access, stream, and files APIs · symbol-parser.ts Symbol and import parser
Components 21
Next.js UI
- Repository input
src/app/page.tsx - Repository route
src/app/[owner]/[repo]/page.tsx - Dashboard orchestrator · Composes loading states, settings, tabs, and repository views.
src/app/[owner]/[repo]/repo-page-client.tsx - Overview and pipeline UI
src/components/dashboard/repo-overview.tsx
GitHub acquisition
- Repository API · Central server-side repository acquisition endpoint.
src/app/api/github/repo/route.ts - Access, stream, and files APIs · Validate access, stream incremental loading, and retrieve file content.
src/app/api/github/repo/stream/route.ts - GitHub client · Uses an optional personal access token for GitHub fetching.
src/lib/github.ts - GitHub
Analysis pipeline
- Symbol and import parser · Extracts multi-language symbols and imports from source content.
src/lib/symbol-parser.ts - Typed graph builder · Builds file and symbol relationship nodes and edges.
src/lib/graph-builder.ts - Impact analyzer
src/lib/impact-analyzer.ts - Browser analysis workers · Offloads symbol analysis and force simulation.
src/workers/symbol-analysis.worker.ts - Graph cache and seed API · Caches layout data and can receive server-side seeds.
src/lib/graph-cache.ts
Diagram rendering
- File and knowledge graphs
src/components/diagrams/file-tree-graph.tsx - Dependency graph
src/components/diagrams/dependency-graph.tsx - Commit and branch graphs
src/components/diagrams/git-rail-graph.tsx - Architecture generator · Derives deterministic Mermaid architecture from structure and dependencies.
src/lib/mermaid-generator.ts - Architecture diagram
src/components/diagrams/architecture-diagram.tsx
Optional services
- Premium analysis API · Optional AI analysis entry point.
src/app/api/analyze/route.ts - Gemini integration · Uses Gemini with client-provided keys or credit handling.
src/lib/ai.ts - Drizzle/Postgres
src/db/index.ts
Connections 22
- 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