# rohityadav483/repo2arch architecture

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

- Interactive diagram: https://gitdiagram.com/rohityadav483/repo2arch
- Repository: https://github.com/rohityadav483/repo2arch

## Overview

1. **What this repo is**
   Repo2Arch is a two-tier application that takes a public GitHub repository URL, clones and analyzes the code on the backend, then presents diagrams and summaries in a Streamlit frontend. The core architectural boundary is between the UI layer and the analysis API.

2. **Frontend subsystem**
   The `frontend/` app is a Streamlit single-page interface. It collects the GitHub URL, calls the backend through `frontend/utils/api_client.py`, and renders four result types through separate components: architecture diagram, dependency graph, AI summary, and tech stack badges. This layer is presentation-only and does not perform code analysis itself.

3. **Backend API boundary**
   The `backend/app/` package is a FastAPI service exposing versioned endpoints under `/api/v1`. `backend/app/main.py` wires the application together, while `backend/app/api/routes.py` hosts the public endpoints for health checks, analysis requests, history lookup, and cached repo retrieval. `models/schemas.py` defines the request/response contract between frontend and backend.

4. **Analysis pipeline**
   A repo analysis request flows through a sequence of services: fetch the repository, inspect files, extract structural metadata, build graph representations, generate Mermaid text, optionally generate an AI summary, then persist and return the result. This pipeline is the main backend workflow and is designed to be reusable across API calls and cached history reads.

5. **Repository ingestion**
   `backend/app/services/github_fetcher.py` is responsible for obtaining source code from GitHub public repositories, typically by cloning into a temporary local workspace. The `temp_clones/` directory in the repo reflects this working-set concept: cloned repositories are treated as transient analysis inputs, not long-lived application assets.

6. **Code understanding and tech detection**
   `backend/app/services/code_analyzer.py` performs static inspection using AST plus regex-based heuristics. It identifies languages, frameworks, entry points, tests, CI/Docker indicators, and other repo-level signals. These extracted facts feed both the diagram builders and the summary/insight outputs.

7. **Graph and diagram generation**
   `backend/app/services/graph_builder.py` constructs a file-level dependency graph, likely using NetworkX as the underlying graph model. `backend/app/services/mermaid_generator.py` converts that structure into Mermaid `graph TD` syntax for the architecture diagram. The frontend then renders the Mermaid output and an interactive graph view, giving two different visualizations of the same analyzed structure.

8. **AI summary subsystem**
   `backend/app/services/ai_summary.py` sends only structured metadata, not raw source code, to Hugging Face Inference API models. The README indicates a primary model plus fallbacks, so the AI layer is an external dependency with graceful degradation rather than a local ML runtime. Its job is to produce a human-readable architecture explanation and improvement suggestions from the extracted repo facts.

9. **Persistence and caching**
   `backend/app/services/supabase_client.py` stores and retrieves analyses from Supabase. The persisted schema includes an `analyses` table for repo-level metadata and a `diagrams` table for generated graph artifacts. This creates a caching boundary: repeated analyses for the same repository can be served from storage instead of recloning and reprocessing.

10. **Configuration and operational concerns**
   `backend/app/config.py` centralizes environment-driven settings such as the Hugging Face key, Supabase credentials, debug mode, and clone directory. `backend/app/utils/helpers.py` likely holds shared utility logic used across services. The deployment shape is simple: FastAPI backend on Python 3.11+ and a separate Streamlit frontend, both configured through environment variables and communicating over HTTP.

Main entry points: [`backend/app/api/routes.py`](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/api/routes.py) (API routes), [`frontend/app.py`](https://github.com/rohityadav483/repo2arch/blob/main/frontend/app.py) (Streamlit app), [`backend/app/config.py`](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/config.py) (Config), [`backend/app/services/github_fetcher.py`](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/github_fetcher.py) (Repo fetcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["Streamlit app<br/>ui shell<br/>[app.py]"]
  node_frontend_api_client["API client<br/>http client<br/>[api_client.py]"]
  node_diagram_view["Diagram view<br/>renderer<br/>[diagram_view.py]"]
  node_graph_view["Graph view<br/>renderer<br/>[graph_view.py]"]
  node_summary_view["Summary view<br/>renderer<br/>[summary_view.py]"]
  node_tech_badges["Tech badges<br/>renderer<br/>[tech_badges.py]"]
end

subgraph group_backend["Backend"]
  node_backend_main["API app<br/>FastAPI bootstrap<br/>[main.py]"]
  node_backend_routes["API routes<br/>HTTP endpoints<br/>[routes.py]"]
  node_schemas["Schemas<br/>contracts<br/>[schemas.py]"]
  node_github_fetcher["Repo fetcher<br/>ingestion service<br/>[github_fetcher.py]"]
  node_code_analyzer["Code analyzer<br/>static analysis<br/>[code_analyzer.py]"]
  node_graph_builder["Graph builder<br/>dependency graph<br/>[graph_builder.py]"]
  node_mermaid_generator["Mermaid gen<br/>diagram generator"]
  node_ai_summary["AI summary<br/>llm service<br/>[ai_summary.py]"]
  node_supabase_client[("Supabase store<br/>persistence<br/>[supabase_client.py]")]
  node_config["Config<br/>settings<br/>[config.py]"]
  node_helpers["Helpers<br/>shared utils<br/>[helpers.py]"]
end

subgraph group_external["External services"]
  node_huggingface(("Hugging Face<br/>external ai api"))
end

subgraph group_workspace["Workspace"]
  node_temp_clones["Temp clones<br/>workspace"]
end

node_frontend_app -->|"submits URL"| node_frontend_api_client
node_frontend_app -->|"renders"| node_diagram_view
node_frontend_app -->|"renders"| node_graph_view
node_frontend_app -->|"renders"| node_summary_view
node_frontend_app -->|"renders"| node_tech_badges
node_frontend_api_client -->|"calls API"| node_backend_routes
node_backend_main -->|"mounts"| node_backend_routes
node_backend_routes -->|"uses contracts"| node_schemas
node_backend_routes -->|"fetches repo"| node_github_fetcher
node_backend_routes -->|"analyzes code"| node_code_analyzer
node_backend_routes -->|"builds graph"| node_graph_builder
node_backend_routes -->|"generates diagram"| node_mermaid_generator
node_backend_routes -->|"summarizes"| node_ai_summary
node_backend_routes -->|"persists"| node_supabase_client
node_code_analyzer -->|"uses"| node_helpers
node_graph_builder -->|"uses"| node_helpers
node_ai_summary -->|"calls"| node_huggingface
node_github_fetcher -->|"writes clones"| node_temp_clones
node_github_fetcher -->|"reads settings"| node_config
node_supabase_client -->|"reads settings"| node_config
node_backend_main -->|"loads config"| node_config
node_backend_routes -->|"uses"| node_helpers
node_frontend_app -->|"reads env"| node_config

click node_frontend_app "https://github.com/rohityadav483/repo2arch/blob/main/frontend/app.py"
click node_frontend_api_client "https://github.com/rohityadav483/repo2arch/blob/main/frontend/utils/api_client.py"
click node_diagram_view "https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/diagram_view.py"
click node_graph_view "https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/graph_view.py"
click node_summary_view "https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/summary_view.py"
click node_tech_badges "https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/tech_badges.py"
click node_backend_main "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/main.py"
click node_backend_routes "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/api/routes.py"
click node_schemas "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/models/schemas.py"
click node_github_fetcher "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/github_fetcher.py"
click node_code_analyzer "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/code_analyzer.py"
click node_graph_builder "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/graph_builder.py"
click node_mermaid_generator "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/mermaid_generator.py"
click node_ai_summary "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/ai_summary.py"
click node_supabase_client "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/supabase_client.py"
click node_config "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/config.py"
click node_helpers "https://github.com/rohityadav483/repo2arch/blob/main/backend/app/utils/helpers.py"
click node_temp_clones "https://github.com/rohityadav483/repo2arch/tree/main/temp_clones"

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_frontend_app,node_frontend_api_client,node_diagram_view,node_graph_view,node_summary_view,node_tech_badges toneBlue
class node_backend_main,node_backend_routes,node_schemas,node_github_fetcher,node_code_analyzer,node_graph_builder,node_mermaid_generator,node_ai_summary,node_supabase_client,node_config,node_helpers toneAmber
class node_huggingface toneMint
class node_temp_clones toneRose
```

## Components

### Frontend

Streamlit presentation layer

- [Streamlit app](https://github.com/rohityadav483/repo2arch/blob/main/frontend/app.py): ui shell · Main Streamlit entrypoint for collecting repo URLs and showing results · `frontend/app.py`
- [API client](https://github.com/rohityadav483/repo2arch/blob/main/frontend/utils/api_client.py): http client · Calls backend analysis endpoints from the UI · `frontend/utils/api_client.py`
- [Diagram view](https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/diagram_view.py): renderer · Renders architecture diagram output in the UI · `frontend/components/diagram_view.py`
- [Graph view](https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/graph_view.py): renderer · Shows interactive dependency graph results · `frontend/components/graph_view.py`
- [Summary view](https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/summary_view.py): renderer · Displays AI-generated architecture summary · `frontend/components/summary_view.py`
- [Tech badges](https://github.com/rohityadav483/repo2arch/blob/main/frontend/components/tech_badges.py): renderer · Shows detected languages and framework badges · `frontend/components/tech_badges.py`

### Backend

FastAPI analysis service

- [API app](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/main.py): FastAPI bootstrap · Wires the backend application and middleware · `backend/app/main.py`
- [API routes](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/api/routes.py): HTTP endpoints · Public versioned endpoints for health, analysis, history, and cached repos · `backend/app/api/routes.py`
- [Schemas](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/models/schemas.py): contracts · Request and response models shared by the frontend and backend · `backend/app/models/schemas.py`
- [Repo fetcher](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/github_fetcher.py): ingestion service · Clones public GitHub repositories into a temporary workspace · `backend/app/services/github_fetcher.py`
- [Code analyzer](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/code_analyzer.py): static analysis · Extracts repo signals with AST and heuristics · `backend/app/services/code_analyzer.py`
- [Graph builder](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/graph_builder.py): dependency graph · Builds file-level dependency graph structure · `backend/app/services/graph_builder.py`
- [Mermaid gen](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/mermaid_generator.py): diagram generator · Converts graph data into Mermaid syntax · `backend/app/services/mermaid_generator.py`
- [AI summary](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/ai_summary.py): llm service · Generates human-readable summary from structured repo metadata · `backend/app/services/ai_summary.py`
- [Supabase store](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/services/supabase_client.py): persistence · Stores analyses and generated diagrams for caching and history · `backend/app/services/supabase_client.py`
- [Config](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/config.py): settings · Environment-driven backend settings and secrets · `backend/app/config.py`
- [Helpers](https://github.com/rohityadav483/repo2arch/blob/main/backend/app/utils/helpers.py): shared utils · Common utility functions used across backend services · `backend/app/utils/helpers.py`

### External services

Third-party APIs and storage

- **Hugging Face**: external ai api · External inference API used for summaries

### Workspace

Transient cloned repositories

- [Temp clones](https://github.com/rohityadav483/repo2arch/tree/main/temp_clones): workspace · Transient local clone workspace for analyzed repositories · `temp_clones`

## Connections

- Streamlit app → API client: submits URL · UI sends repository URL and requests analysis
- Streamlit app → Diagram view: renders · Displays generated architecture diagram
- Streamlit app → Graph view: renders · Displays dependency graph visualization
- Streamlit app → Summary view: renders · Displays AI summary output
- Streamlit app → Tech badges: renders · Displays detected technology badges
- API client → API routes: calls API · Sends analysis and history requests over HTTP
- API app → API routes: mounts · Registers the versioned route handlers
- API routes → Schemas: uses contracts · Validates request and response payloads
- API routes → Repo fetcher: fetches repo · Starts repository ingestion for analysis
- API routes → Code analyzer: analyzes code · Extracts language, framework, and structural signals
- API routes → Graph builder: builds graph · Creates dependency graph artifacts
- API routes → Mermaid gen: generates diagram · Produces Mermaid representation for the frontend
- API routes → AI summary: summarizes · Creates a human-readable explanation from structured metadata
- API routes → Supabase store: persists · Stores and retrieves analysis results and diagrams
- Code analyzer → Helpers: uses · Shares utility logic for inspection and parsing
- Graph builder → Helpers: uses · Shares utility logic for graph construction
- AI summary → Hugging Face: calls · Uses external inference models with fallback behavior
- Repo fetcher → Temp clones: writes clones · Creates transient local workspaces for source repositories
- Repo fetcher → Config: reads settings · Uses clone directory and related environment configuration
- Supabase store → Config: reads settings · Uses credentials and database configuration
- API app → Config: loads config · Initializes service behavior from environment settings
- API routes → Helpers: uses · Shares common backend utility functions
- Streamlit app → Config: reads env · Frontend is configured through environment variables
