# kabirkhanuja/repoarchitectagent architecture

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

- Interactive diagram: https://gitdiagram.com/kabirkhanuja/repoarchitectagent
- Repository: https://github.com/kabirkhanuja/repoarchitectagent

## Overview

#### Purpose and Entry Points
RepoArchitectAgent analyzes a GitHub repository, builds a structured representation, produces AI-assisted explanations/diagrams/recommendations, and presents results in a browser. Backend entry point: `api/index.py` (FastAPI, served via Uvicorn). Frontend entry points: `web/app/page.tsx` and `web/app/dashboard/page.tsx` (Next.js App Router). A CLI-capable analysis orchestrator exists at `api/orchestration/analyze_repo.py`.

#### API Boundary and Request Orchestration
`api/index.py` exposes analysis and generation endpoints. It coordinates repository analysis and dedicated LLM-backed output generation, returning data consumed by the Next.js client. `api/orchestration/actions.py` and `api/orchestration/analyze_repo.py` form the workflow layer separating HTTP handling from repository-processing steps.

#### Repository Acquisition and Metadata
The ingestion boundary accepts a GitHub repository reference, clones or materializes it locally, and gathers GitHub-facing metadata. `api/ingestion/clone_repo.py` manages source checkout; `api/ingestion/github_meta.py` handles repository metadata. Local filesystem and Git operations are isolated through `api/utils/fs.py` and `api/utils/git.py`, with cleanup in `api/utils/cleanup.py`.

#### Static Analysis Pipeline
Analysis reads the checked-out repository and derives stack, structure, dependencies, and risks. Key stages are `api/analysis/detect_stack.py`, `api/analysis/parse_structure.py`, `api/analysis/dependencies.py`, and `api/analysis/risks.py`. Shared parsing logic in `api/helpers/repo_parsers.py` provides the boundary between raw source files and normalized analysis facts.

#### Intermediate Representation
The system consolidates analysis results into a repository IR, rather than coupling generators directly to filesystem scans. `api/ir/schema.py` defines the representation contract and `api/ir/builder.py` constructs it. This IR is the principal handoff from deterministic analysis to API responses and AI-generated artifacts.

#### AI Generation and External Services
LLM adapters generate repository summaries, Mermaid source, and CI-oriented output from analysis/IR context: `api/llm/summarize.py`, `api/llm/generate_mermaid.py`, and `api/llm/generate_ci.py`. The stated external providers are Groq (LLaMA) and optional Anthropic Claude; GitHub API access supports metadata and recommendation-oriented analysis. Environment-driven configuration is centralized in `api/config.py`.

#### Web Presentation
The Next.js/TypeScript frontend calls the backend through `web/lib/api.ts`, with result shapes in `web/lib/types.ts`. Repository submission and user flow are centered in `web/components/repository-analyzer.tsx`; results rendering is in `web/components/analysis-results.tsx`; Mermaid visualization is rendered by `web/components/MermaidViewer.tsx`. This client is a presentation layer and depends on FastAPI for repository processing and AI calls.

#### Automation and Deployment
Kestra can execute the repository-analysis workflow through `kestra/blueprint_repo_analysis.yml`. GitHub Actions define CI/deployment automation in `.github/workflows/ci-generated.yml` and `.github/workflows/deploy.yml`. Material runtimes are Python 3.9+ for FastAPI/analysis and Node.js 18+ for Next.js; the frontend is suitable for Vercel-style deployment, while API hosting must provide credentials and local temporary clone storage.

Main entry points: [`api/ir/builder.py`](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ir/builder.py) (IR builder), [`api/index.py`](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/index.py) (FastAPI API), [`api/orchestration/actions.py`](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/orchestration/actions.py) (Workflow actions), [`api/llm/summarize.py`](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/summarize.py) (Summary generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["FastAPI &amp; workflow"]
  node_api_entry["FastAPI API<br/>Python service<br/>[index.py]"]
  node_workflow["Analysis workflow<br/>orchestrator<br/>[analyze_repo.py]"]
  node_actions["Workflow actions<br/>workflow steps<br/>[actions.py]"]
end

subgraph group_ingestion["Repository ingestion"]
  node_clone["Repository checkout<br/>Git ingestion<br/>[clone_repo.py]"]
  node_github_meta["GitHub metadata<br/>GitHub client<br/>[github_meta.py]"]
  node_local_repo[("Local repository<br/>temporary workspace")]
end

subgraph group_analysis["Analysis &amp; IR"]
  node_parsers["Source parsers<br/>normalizer<br/>[repo_parsers.py]"]
  node_static_analysis["Static analysis<br/>analysis stages<br/>[detect_stack.py]"]
  node_ir_builder["IR builder<br/>representation builder<br/>[builder.py]"]
  node_ir_schema["Repository IR schema<br/>data contract<br/>[schema.py]"]
end

subgraph group_generation["AI generation"]
  node_summary["Summary generator<br/>LLM adapter<br/>[summarize.py]"]
  node_mermaid_gen["Diagram generator<br/>LLM adapter"]
  node_ci_gen["CI generator<br/>LLM adapter<br/>[generate_ci.py]"]
  node_llm_providers{{"Groq / Claude<br/>external LLM providers"}}
end

subgraph group_web["Next.js client"]
  node_web_pages["App &amp; dashboard pages<br/>Next.js routes<br/>[page.tsx]"]
  node_repository_form["Repository analyzer<br/>client workflow"]
  node_api_client["Backend API client<br/>TypeScript client<br/>[api.ts]"]
  node_results["Results &amp; Mermaid viewer<br/>result presentation"]
end

subgraph group_automation["Automation"]
  node_kestra["Kestra workflow<br/>automation workflow"]
  node_github_actions["GitHub Actions<br/>CI/deployment<br/>[ci-generated.yml]"]
end

node_web_pages -->|"hosts"| node_repository_form
node_repository_form -->|"submits repository"| node_api_client
node_api_client -->|"calls"| node_api_entry
node_api_entry -->|"orchestrates"| node_workflow
node_workflow -->|"uses"| node_actions
node_actions -->|"checks out"| node_clone
node_actions -->|"collects"| node_github_meta
node_clone -->|"materializes"| node_local_repo
node_local_repo -->|"source files"| node_parsers
node_parsers -->|"normalized facts"| node_static_analysis
node_static_analysis -->|"analysis results"| node_ir_builder
node_ir_schema -.->|"defines"| node_ir_builder
node_ir_builder -->|"IR context"| node_summary
node_ir_builder -->|"IR context"| node_mermaid_gen
node_ir_builder -->|"IR context"| node_ci_gen
node_summary -->|"generates via"| node_llm_providers
node_mermaid_gen -->|"generates via"| node_llm_providers
node_ci_gen -->|"generates via"| node_llm_providers
node_summary -->|"artifacts"| node_api_entry
node_mermaid_gen -->|"Mermaid source"| node_results
node_api_entry -->|"analysis response"| node_results
node_kestra -->|"executes"| node_workflow
node_github_actions -.->|"CI/deployment automation"| node_kestra

click node_api_entry "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/index.py"
click node_workflow "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/orchestration/analyze_repo.py"
click node_actions "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/orchestration/actions.py"
click node_clone "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ingestion/clone_repo.py"
click node_github_meta "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ingestion/github_meta.py"
click node_parsers "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/helpers/repo_parsers.py"
click node_static_analysis "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/analysis/detect_stack.py"
click node_ir_builder "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ir/builder.py"
click node_ir_schema "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ir/schema.py"
click node_summary "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/summarize.py"
click node_mermaid_gen "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/generate_mermaid.py"
click node_ci_gen "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/generate_ci.py"
click node_web_pages "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/app/page.tsx"
click node_repository_form "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/components/repository-analyzer.tsx"
click node_api_client "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/lib/api.ts"
click node_results "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/components/analysis-results.tsx"
click node_kestra "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/kestra/blueprint_repo_analysis.yml"
click node_github_actions "https://github.com/kabirkhanuja/repoarchitectagent/blob/main/.github/workflows/ci-generated.yml"

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_api_entry,node_workflow,node_actions toneBlue
class node_clone,node_github_meta,node_local_repo toneAmber
class node_parsers,node_static_analysis,node_ir_builder,node_ir_schema toneMint
class node_summary,node_mermaid_gen,node_ci_gen,node_llm_providers toneRose
class node_web_pages,node_repository_form,node_api_client,node_results toneIndigo
class node_kestra,node_github_actions toneTeal
```

## Components

### FastAPI & workflow

- [FastAPI API](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/index.py): Python service · HTTP boundary for analysis and generation. · `api/index.py`
- [Analysis workflow](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/orchestration/analyze_repo.py): orchestrator · `api/orchestration/analyze_repo.py`
- [Workflow actions](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/orchestration/actions.py): workflow steps · `api/orchestration/actions.py`

### Repository ingestion

- [Repository checkout](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ingestion/clone_repo.py): Git ingestion · `api/ingestion/clone_repo.py`
- [GitHub metadata](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ingestion/github_meta.py): GitHub client · `api/ingestion/github_meta.py`
- **Local repository**: temporary workspace · Checked-out source available to pipeline stages.

### Analysis & IR

- [Source parsers](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/helpers/repo_parsers.py): normalizer · `api/helpers/repo_parsers.py`
- [Static analysis](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/analysis/detect_stack.py): analysis stages · Detects stack, structure, dependencies, and risks. · `api/analysis/detect_stack.py`
- [IR builder](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ir/builder.py): representation builder · `api/ir/builder.py`
- [Repository IR schema](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/ir/schema.py): data contract · `api/ir/schema.py`

### AI generation

- [Summary generator](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/summarize.py): LLM adapter · `api/llm/summarize.py`
- [Diagram generator](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/generate_mermaid.py): LLM adapter · `api/llm/generate_mermaid.py`
- [CI generator](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/api/llm/generate_ci.py): LLM adapter · `api/llm/generate_ci.py`
- **Groq / Claude**: external LLM providers

### Next.js client

- [App & dashboard pages](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/app/page.tsx): Next.js routes · `web/app/page.tsx`
- [Repository analyzer](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/components/repository-analyzer.tsx): client workflow · `web/components/repository-analyzer.tsx`
- [Backend API client](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/lib/api.ts): TypeScript client · `web/lib/api.ts`
- [Results & Mermaid viewer](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/web/components/analysis-results.tsx): result presentation · `web/components/analysis-results.tsx`

### Automation

- [Kestra workflow](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/kestra/blueprint_repo_analysis.yml): automation workflow · `kestra/blueprint_repo_analysis.yml`
- [GitHub Actions](https://github.com/kabirkhanuja/repoarchitectagent/blob/main/.github/workflows/ci-generated.yml): CI/deployment · `.github/workflows/ci-generated.yml`

## Connections

- App & dashboard pages → Repository analyzer: hosts
- Repository analyzer → Backend API client: submits repository
- Backend API client → FastAPI API: calls
- FastAPI API → Analysis workflow: orchestrates
- Analysis workflow → Workflow actions: uses
- Workflow actions → Repository checkout: checks out
- Workflow actions → GitHub metadata: collects
- Repository checkout → Local repository: materializes
- Local repository → Source parsers: source files
- Source parsers → Static analysis: normalized facts
- Static analysis → IR builder: analysis results
- Repository IR schema → IR builder: defines
- IR builder → Summary generator: IR context
- IR builder → Diagram generator: IR context
- IR builder → CI generator: IR context
- Summary generator → Groq / Claude: generates via
- Diagram generator → Groq / Claude: generates via
- CI generator → Groq / Claude: generates via
- Summary generator → FastAPI API: artifacts
- Diagram generator → Results & Mermaid viewer: Mermaid source
- FastAPI API → Results & Mermaid viewer: analysis response
- Kestra workflow → Analysis workflow: executes
- GitHub Actions → Kestra workflow: CI/deployment automation
