# adithya-s-k/gitvizz architecture

> Architecture diagram of the GitHub repository adithya-s-k/gitvizz, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adithya-s-k/gitvizz
- Repository: https://github.com/adithya-s-k/gitvizz

## Overview

#### Purpose and Entry Points
GitVizz is a repository-understanding platform: it ingests GitHub/source repositories, derives AST-based dependency graphs, presents interactive code exploration, and adds LLM chat/documentation. Runtime entry points are the FastAPI app at `backend/server.py`, optional Modal deployment entry at `backend/modal_server.py`, and Next.js App Router at `frontend/app/layout.tsx` and `frontend/app/page.tsx`. Docker orchestration is defined in `docker-compose.yaml`.

#### Frontend Application
The Next.js/TypeScript client drives repository submission, results navigation, graph exploration, code viewing, chat, API-key management, and authentication. Repository/result pages are parameterized by owner, repo, branch, or uploaded archive:
- `frontend/app/[owner]/[repo]/page.tsx`
- `frontend/app/results/[owner]/[repo]/[branch]/page.tsx`
- `frontend/app/results/zip/[zipname]/page.tsx`

It calls the backend through a generated API layer in `frontend/api-client/sdk.gen.ts`; authenticated request handling and result state are centralized in `frontend/hooks/useApiWithAuth.ts` and `frontend/context/ResultDataContext.tsx`.

#### Graph Analysis Core
The standalone, Apache-licensed `gitvizz` Python package is the structural-analysis boundary. It accepts repository file data, parses supported languages with Tree-sitter-oriented AST logic, and emits dependency/relationship graph data. Its primary engine and query capabilities are:
- `gitvizz/gitvizz/graph_generator.py`
- `gitvizz/gitvizz/custom_ast_parser.py`
- `gitvizz/gitvizz/graph_search_tool.py`

The backend adapts this output for API/UI consumption through `backend/utils/gitvizz_tools.py` and `backend/utils/graph_utils.py`. This separation allows core graph generation to be used independently of the web product.

#### Backend API and Repository Lifecycle
FastAPI routes delegate to controllers for repository ingestion/indexing, graphs, chat, identity, credentials, and GitHub access. Core HTTP boundaries include:
- `backend/server.py`
- `backend/routes/repo_routes.py`
- `backend/routes/indexed_repos_routes.py`

Repository operations are handled in `backend/controllers/repo_controller.py` and indexed-repository operations in `backend/controllers/indexed_repos_controller.py`. GitHub-specific acquisition/authentication is isolated in `backend/controllers/github_controller.py`, supporting public/private access via personal tokens, OAuth, or GitHub App credentials.

#### AI Documentation and Chat
Documentation generation is a distinct pipeline that analyzes repository content, structures prompts/data, selects an AI client, and can embed material for retrieval-like use:
- `backend/documentation_generator/core.py`
- `backend/documentation_generator/analyzers.py`
- `backend/documentation_generator/ai_client.py`

Chat endpoints/controller feed repository and graph context into LLM services, including LangChain- and LangGraph-based implementations:
- `backend/controllers/chat_controller.py`
- `backend/utils/langchain_llm_service.py`
- `backend/utils/langgraph_chat_service.py`

Configured providers include OpenAI, Anthropic, Gemini, and Groq; users can manage provider keys through `backend/controllers/api_key_controller.py`.

#### Visualization and User Interaction
Graph data is rendered client-side using alternate graph visualization components, with search and hierarchy filtering layered over the same repository result model:
- `frontend/components/ReagraphVisualization.tsx`
- `frontend/components/SigmaGraphVisualization.tsx`
- `frontend/hooks/useGraphSearch.ts`

Code and AI outputs are integrated into the exploration UI through `frontend/components/CodeViewer.tsx`, `frontend/components/floating-chat-button.tsx`, and `frontend/components/documentation.tsx`.

#### Persistence, Security, and Operations
MongoDB persists users, repositories, chats, and task-like records via `backend/utils/db.py` and models such as `backend/models/repository.py`. JWT auth and request protection are implemented at `backend/utils/jwt_utils.py` and `backend/middleware/auth_middleware.py`; sensitive user API keys are a separate concern. File storage is locally configurable. Deployment supports Docker and a Modal workflow (`.github/workflows/modal_backend_deploy.yaml`). Phoenix is an optional external LLM tracing/observability service, integrated through `backend/utils/observability.py`.

Main entry points: [`backend/server.py`](https://github.com/adithya-s-k/gitvizz/blob/main/backend/server.py) (FastAPI server), [`backend/controllers/repo_controller.py`](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/repo_controller.py) (Repository lifecycle), [`gitvizz/gitvizz/graph_generator.py`](https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/graph_generator.py) (GitVizz graph engine), [`backend/controllers/chat_controller.py`](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/chat_controller.py) (Chat controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_next_app["Next.js application<br/>web client<br/>[page.tsx]"]
  node_result_pages["Repository result pages<br/>App Router pages<br/>[page.tsx]"]
  node_api_client["Generated API client<br/>TypeScript SDK<br/>[sdk.gen.ts]"]
  node_result_state["Result data state<br/>React context"]
  node_graph_ui["Graph exploration<br/>visualization components"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI server<br/>API entry point<br/>[server.py]"]
  node_repo_routes["Repository routes<br/>HTTP routes<br/>[repo_routes.py]"]
  node_repo_controller["Repository lifecycle<br/>controller<br/>[repo_controller.py]"]
  node_github_controller["GitHub acquisition<br/>controller"]
  node_indexed_repos["Indexed repository API<br/>routes and controller"]
  node_graph_adapter["Graph API adapter<br/>backend utility<br/>[gitvizz_tools.py]"]
end

subgraph group_analysis["Graph Analysis"]
  node_gitvizz_engine{{"GitVizz graph engine<br/>Python package<br/>[graph_generator.py]"}}
  node_ast_parser["AST parser<br/>Tree-sitter analysis"]
  node_graph_search["Graph search<br/>query capability"]
end

subgraph group_ai["AI Services"]
  node_chat_controller["Chat controller<br/>[chat_controller.py]"]
  node_llm_chat["LLM chat service<br/>LangChain service"]
  node_documentation["Documentation pipeline<br/>AI generation<br/>[core.py]"]
  node_api_keys["Provider key management<br/>controller"]
end

subgraph group_data["Data &amp; Operations"]
  node_mongodb[("MongoDB persistence<br/>database layer<br/>[db.py]")]
  node_auth["JWT authentication<br/>middleware<br/>[auth_middleware.py]"]
  node_docker["Docker orchestration<br/>deployment"]
end

node_next_app -->|"navigates to"| node_result_pages
node_result_pages -->|"uses"| node_result_state
node_result_state -->|"supplies graph data"| node_graph_ui
node_next_app -->|"calls through"| node_api_client
node_api_client -->|"HTTP API"| node_fastapi
node_fastapi -->|"protects requests with"| node_auth
node_fastapi -->|"mounts"| node_repo_routes
node_fastapi -->|"mounts"| node_indexed_repos
node_fastapi -->|"routes chat to"| node_chat_controller
node_repo_routes -->|"delegates"| node_repo_controller
node_repo_controller -->|"acquires repositories via"| node_github_controller
node_repo_controller -->|"analyzes files with"| node_gitvizz_engine
node_indexed_repos -->|"serves graphs through"| node_graph_adapter
node_graph_adapter -->|"adapts output from"| node_gitvizz_engine
node_gitvizz_engine -->|"parses with"| node_ast_parser
node_gitvizz_engine -->|"exposes queries to"| node_graph_search
node_repo_controller -->|"persists indexed repositories"| node_mongodb
node_chat_controller -->|"delegates to"| node_llm_chat
node_chat_controller -->|"uses graph context"| node_graph_adapter
node_documentation -->|"uses AI clients"| node_llm_chat
node_api_keys -->|"stores user key records"| node_mongodb
node_docker -->|"orchestrates"| node_fastapi
node_docker -->|"orchestrates"| node_next_app

click node_next_app "https://github.com/adithya-s-k/gitvizz/blob/main/frontend/app/page.tsx"
click node_result_pages "https://github.com/adithya-s-k/gitvizz/blob/main/frontend/app/results/%5Bowner%5D/%5Brepo%5D/%5Bbranch%5D/page.tsx"
click node_api_client "https://github.com/adithya-s-k/gitvizz/blob/main/frontend/api-client/sdk.gen.ts"
click node_result_state "https://github.com/adithya-s-k/gitvizz/blob/main/frontend/context/ResultDataContext.tsx"
click node_graph_ui "https://github.com/adithya-s-k/gitvizz/blob/main/frontend/components/ReagraphVisualization.tsx"
click node_fastapi "https://github.com/adithya-s-k/gitvizz/blob/main/backend/server.py"
click node_repo_routes "https://github.com/adithya-s-k/gitvizz/blob/main/backend/routes/repo_routes.py"
click node_repo_controller "https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/repo_controller.py"
click node_github_controller "https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/github_controller.py"
click node_indexed_repos "https://github.com/adithya-s-k/gitvizz/blob/main/backend/routes/indexed_repos_routes.py"
click node_graph_adapter "https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/gitvizz_tools.py"
click node_gitvizz_engine "https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/graph_generator.py"
click node_ast_parser "https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/custom_ast_parser.py"
click node_graph_search "https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/graph_search_tool.py"
click node_chat_controller "https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/chat_controller.py"
click node_llm_chat "https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/langchain_llm_service.py"
click node_documentation "https://github.com/adithya-s-k/gitvizz/blob/main/backend/documentation_generator/core.py"
click node_api_keys "https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/api_key_controller.py"
click node_mongodb "https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/db.py"
click node_auth "https://github.com/adithya-s-k/gitvizz/blob/main/backend/middleware/auth_middleware.py"
click node_docker "https://github.com/adithya-s-k/gitvizz/blob/main/docker-compose.yaml"

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_next_app,node_result_pages,node_api_client,node_result_state,node_graph_ui toneBlue
class node_fastapi,node_repo_routes,node_repo_controller,node_github_controller,node_indexed_repos,node_graph_adapter toneAmber
class node_gitvizz_engine,node_ast_parser,node_graph_search toneMint
class node_chat_controller,node_llm_chat,node_documentation,node_api_keys toneRose
class node_mongodb,node_auth,node_docker toneIndigo
```

## Components

### Frontend

- [Next.js application](https://github.com/adithya-s-k/gitvizz/blob/main/frontend/app/page.tsx): web client · Repository submission and exploration UI. · `frontend/app/page.tsx`
- [Repository result pages](https://github.com/adithya-s-k/gitvizz/blob/main/frontend/app/results/%5Bowner%5D/%5Brepo%5D/%5Bbranch%5D/page.tsx): App Router pages · Supports GitHub repositories and uploaded archives. · `frontend/app/results/[owner]/[repo]/[branch]/page.tsx`
- [Generated API client](https://github.com/adithya-s-k/gitvizz/blob/main/frontend/api-client/sdk.gen.ts): TypeScript SDK · `frontend/api-client/sdk.gen.ts`
- [Result data state](https://github.com/adithya-s-k/gitvizz/blob/main/frontend/context/ResultDataContext.tsx): React context · `frontend/context/ResultDataContext.tsx`
- [Graph exploration](https://github.com/adithya-s-k/gitvizz/blob/main/frontend/components/ReagraphVisualization.tsx): visualization components · Alternate renderers share graph search and result data. · `frontend/components/ReagraphVisualization.tsx`

### Backend API

- [FastAPI server](https://github.com/adithya-s-k/gitvizz/blob/main/backend/server.py): API entry point · `backend/server.py`
- [Repository routes](https://github.com/adithya-s-k/gitvizz/blob/main/backend/routes/repo_routes.py): HTTP routes · `backend/routes/repo_routes.py`
- [Repository lifecycle](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/repo_controller.py): controller · Ingests and indexes submitted repositories. · `backend/controllers/repo_controller.py`
- [GitHub acquisition](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/github_controller.py): controller · Handles public/private repository access and GitHub credentials. · `backend/controllers/github_controller.py`
- [Indexed repository API](https://github.com/adithya-s-k/gitvizz/blob/main/backend/routes/indexed_repos_routes.py): routes and controller · `backend/routes/indexed_repos_routes.py`
- [Graph API adapter](https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/gitvizz_tools.py): backend utility · Converts core graph output for API and UI use. · `backend/utils/gitvizz_tools.py`

### Graph Analysis

- [GitVizz graph engine](https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/graph_generator.py): Python package · Independent structural-analysis boundary. · `gitvizz/gitvizz/graph_generator.py`
- [AST parser](https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/custom_ast_parser.py): Tree-sitter analysis · Parses supported repository languages. · `gitvizz/gitvizz/custom_ast_parser.py`
- [Graph search](https://github.com/adithya-s-k/gitvizz/blob/main/gitvizz/gitvizz/graph_search_tool.py): query capability · `gitvizz/gitvizz/graph_search_tool.py`

### AI Services

- [Chat controller](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/chat_controller.py): controller · Supplies repository and graph context to chat. · `backend/controllers/chat_controller.py`
- [LLM chat service](https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/langchain_llm_service.py): LangChain service · Connects chat to configured LLM providers. · `backend/utils/langchain_llm_service.py`
- [Documentation pipeline](https://github.com/adithya-s-k/gitvizz/blob/main/backend/documentation_generator/core.py): AI generation · Analyzes repository content and generates structured documentation. · `backend/documentation_generator/core.py`
- [Provider key management](https://github.com/adithya-s-k/gitvizz/blob/main/backend/controllers/api_key_controller.py): controller · `backend/controllers/api_key_controller.py`

### Data & Operations

- [MongoDB persistence](https://github.com/adithya-s-k/gitvizz/blob/main/backend/utils/db.py): database layer · Persists users, repositories, chats, and task records. · `backend/utils/db.py`
- [JWT authentication](https://github.com/adithya-s-k/gitvizz/blob/main/backend/middleware/auth_middleware.py): middleware · Protects authenticated backend requests. · `backend/middleware/auth_middleware.py`
- [Docker orchestration](https://github.com/adithya-s-k/gitvizz/blob/main/docker-compose.yaml): deployment · `docker-compose.yaml`

## Connections

- Next.js application → Repository result pages: navigates to
- Repository result pages → Result data state: uses
- Result data state → Graph exploration: supplies graph data
- Next.js application → Generated API client: calls through
- Generated API client → FastAPI server: HTTP API
- FastAPI server → JWT authentication: protects requests with
- FastAPI server → Repository routes: mounts
- FastAPI server → Indexed repository API: mounts
- FastAPI server → Chat controller: routes chat to
- Repository routes → Repository lifecycle: delegates
- Repository lifecycle → GitHub acquisition: acquires repositories via
- Repository lifecycle → GitVizz graph engine: analyzes files with
- Indexed repository API → Graph API adapter: serves graphs through
- Graph API adapter → GitVizz graph engine: adapts output from
- GitVizz graph engine → AST parser: parses with
- GitVizz graph engine → Graph search: exposes queries to
- Repository lifecycle → MongoDB persistence: persists indexed repositories
- Chat controller → LLM chat service: delegates to
- Chat controller → Graph API adapter: uses graph context
- Documentation pipeline → LLM chat service: uses AI clients
- Provider key management → MongoDB persistence: stores user key records
- Docker orchestration → FastAPI server: orchestrates
- Docker orchestration → Next.js application: orchestrates
