# lingu17/codeforage-ai architecture

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

- Interactive diagram: https://gitdiagram.com/lingu17/codeforage-ai
- Repository: https://github.com/lingu17/codeforage-ai

## Overview

CodeForge AI analyzes GitHub repositories, persists scan artifacts, and exposes reports, security findings, pull-request reviews, and cited repository chat through a Next.js dashboard and FastAPI API. The principal flow is authenticated repository import, clone and parse, embedding/indexing, analysis, then retrieval or report access. The README documents major capabilities and limitations; source excerpts show portions of the API, scanner, embedding, and retrieval layers, but not all call sites, so some documented links are cited to the README.

Main entry points: [`backend/main.py`](https://github.com/lingu17/codeforage-ai/blob/main/backend/main.py) (FastAPI endpoints), [`backend/scanner.py`](https://github.com/lingu17/codeforage-ai/blob/main/backend/scanner.py) (Clone and scan), [`backend/rag.py`](https://github.com/lingu17/codeforage-ai/blob/main/backend/rag.py) (Hybrid retrieval), [`backend/database.py`](https://github.com/lingu17/codeforage-ai/blob/main/backend/database.py) (Supabase access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Dashboard"]
  node_dashboard["Analysis dashboard<br/>[page.tsx]"]
  node_chat_ui["Repository chat<br/>[page.tsx]"]
  node_pr_ui["PR reviews<br/>[page.tsx]"]
  node_security_ui["Security findings<br/>[page.tsx]"]
  node_architecture_ui["Architecture view<br/>[page.tsx]"]
end

subgraph group_api["API and orchestration"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_github["GitHub identity checks<br/>[github_client.py]"]
  node_validation["Input validation<br/>[validation.py]"]
end

subgraph group_analysis["Repository analysis"]
  node_scanner["Clone and scan<br/>[scanner.py]"]
  node_quality["Quality analysis<br/>[quality.py]"]
  node_pr_review["Review validation<br/>[pr_review.py]"]
  node_recovery["Scan recovery<br/>[scan_recovery.py]"]
  node_reporting["Report shaping<br/>[reporting.py]"]
  node_rag["Hybrid retrieval<br/>[rag.py]"]
end

subgraph group_data["Persistence and AI"]
  node_embedding["Embedding batches<br/>[embedding.py]"]
  node_groq["Groq generation<br/>[ai_groq.py]"]
  node_database["Supabase access<br/>[database.py]"]
end

node_user(("Repository owner"))
node_supabase[("Supabase store")]
node_github_service["GitHub"]
node_gemini["Gemini"]
node_groq_service["Groq API"]

node_user -->|"uses"| node_dashboard
node_dashboard -.->|"requests analysis"| node_api
node_chat_ui -.->|"requests chat"| node_api
node_pr_ui -.->|"requests review"| node_api
node_security_ui -.->|"reads findings"| node_api
node_architecture_ui -.->|"reads graph"| node_api
node_api -->|"validates input"| node_validation
node_api -->|"checks GitHub"| node_github
node_api -->|"starts scan"| node_scanner
node_api -->|"recovers jobs"| node_recovery
node_api -->|"shapes reports"| node_reporting
node_api -->|"validates review"| node_pr_review
node_api -->|"retrieves context"| node_rag
node_scanner -->|"analyzes code"| node_quality
node_scanner -->|"embeds chunks"| node_embedding
node_scanner -->|"persists scan"| node_database
node_rag -.->|"searches chunks"| node_database
node_api -.->|"generates answers"| node_groq
node_database -->|"reads and writes"| node_supabase
node_github -->|"checks responses"| node_github_service
node_embedding -->|"creates vectors"| node_gemini
node_groq -.->|"generates text"| node_groq_service
node_rag -->|"retrieves chunks"| node_supabase

click node_dashboard "https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/page.tsx"
click node_chat_ui "https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/chat/page.tsx"
click node_pr_ui "https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/pr-reviews/page.tsx"
click node_security_ui "https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/security/page.tsx"
click node_architecture_ui "https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/architecture/page.tsx"
click node_api "https://github.com/lingu17/codeforage-ai/blob/main/backend/main.py"
click node_github "https://github.com/lingu17/codeforage-ai/blob/main/backend/github_client.py"
click node_validation "https://github.com/lingu17/codeforage-ai/blob/main/backend/validation.py"
click node_scanner "https://github.com/lingu17/codeforage-ai/blob/main/backend/scanner.py"
click node_quality "https://github.com/lingu17/codeforage-ai/blob/main/backend/quality.py"
click node_pr_review "https://github.com/lingu17/codeforage-ai/blob/main/backend/pr_review.py"
click node_recovery "https://github.com/lingu17/codeforage-ai/blob/main/backend/scan_recovery.py"
click node_reporting "https://github.com/lingu17/codeforage-ai/blob/main/backend/reporting.py"
click node_rag "https://github.com/lingu17/codeforage-ai/blob/main/backend/rag.py"
click node_embedding "https://github.com/lingu17/codeforage-ai/blob/main/backend/embedding.py"
click node_groq "https://github.com/lingu17/codeforage-ai/blob/main/backend/ai_groq.py"
click node_database "https://github.com/lingu17/codeforage-ai/blob/main/backend/database.py"

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_dashboard,node_chat_ui,node_pr_ui,node_security_ui,node_architecture_ui toneBlue
class node_api,node_github,node_validation,node_supabase toneAmber
class node_scanner,node_quality,node_pr_review,node_recovery,node_reporting,node_rag,node_groq_service toneMint
class node_embedding,node_groq,node_database toneRose
class node_user,node_github_service,node_gemini toneIndigo
```

## Components

### Dashboard

- [Analysis dashboard](https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/page.tsx): `frontend/src/app/dashboard/page.tsx`
- [Repository chat](https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/chat/page.tsx): `frontend/src/app/dashboard/chat/page.tsx`
- [PR reviews](https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/pr-reviews/page.tsx): `frontend/src/app/dashboard/pr-reviews/page.tsx`
- [Security findings](https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/security/page.tsx): `frontend/src/app/dashboard/security/page.tsx`
- [Architecture view](https://github.com/lingu17/codeforage-ai/blob/main/frontend/src/app/dashboard/architecture/page.tsx): `frontend/src/app/dashboard/architecture/page.tsx`

### API and orchestration

- [FastAPI endpoints](https://github.com/lingu17/codeforage-ai/blob/main/backend/main.py): `backend/main.py`
- [GitHub identity checks](https://github.com/lingu17/codeforage-ai/blob/main/backend/github_client.py): `backend/github_client.py`
- [Input validation](https://github.com/lingu17/codeforage-ai/blob/main/backend/validation.py): `backend/validation.py`

### Repository analysis

- [Clone and scan](https://github.com/lingu17/codeforage-ai/blob/main/backend/scanner.py): `backend/scanner.py`
- [Quality analysis](https://github.com/lingu17/codeforage-ai/blob/main/backend/quality.py): `backend/quality.py`
- [Review validation](https://github.com/lingu17/codeforage-ai/blob/main/backend/pr_review.py): `backend/pr_review.py`
- [Scan recovery](https://github.com/lingu17/codeforage-ai/blob/main/backend/scan_recovery.py): `backend/scan_recovery.py`
- [Report shaping](https://github.com/lingu17/codeforage-ai/blob/main/backend/reporting.py): `backend/reporting.py`
- [Hybrid retrieval](https://github.com/lingu17/codeforage-ai/blob/main/backend/rag.py): `backend/rag.py`

### Persistence and AI

- [Embedding batches](https://github.com/lingu17/codeforage-ai/blob/main/backend/embedding.py): `backend/embedding.py`
- [Groq generation](https://github.com/lingu17/codeforage-ai/blob/main/backend/ai_groq.py): `backend/ai_groq.py`
- [Supabase access](https://github.com/lingu17/codeforage-ai/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Repository owner**
- **Supabase store**
- **GitHub**
- **Gemini**
- **Groq API**

## Connections

- Repository owner → Analysis dashboard: uses (evidence: `README.md`)
- Analysis dashboard → FastAPI endpoints: requests analysis
- Repository chat → FastAPI endpoints: requests chat
- PR reviews → FastAPI endpoints: requests review
- Security findings → FastAPI endpoints: reads findings
- Architecture view → FastAPI endpoints: reads graph
- FastAPI endpoints → Input validation: validates input (evidence: `backend/main.py`)
- FastAPI endpoints → GitHub identity checks: checks GitHub (evidence: `backend/main.py`)
- FastAPI endpoints → Clone and scan: starts scan (evidence: `backend/main.py`)
- FastAPI endpoints → Scan recovery: recovers jobs (evidence: `backend/main.py`)
- FastAPI endpoints → Report shaping: shapes reports (evidence: `backend/main.py`)
- FastAPI endpoints → Review validation: validates review (evidence: `backend/main.py`)
- FastAPI endpoints → Hybrid retrieval: retrieves context (evidence: `backend/main.py`)
- Clone and scan → Quality analysis: analyzes code (evidence: `backend/scanner.py`)
- Clone and scan → Embedding batches: embeds chunks (evidence: `backend/scanner.py`)
- Clone and scan → Supabase access: persists scan (evidence: `backend/scanner.py`)
- Hybrid retrieval → Supabase access: searches chunks
- FastAPI endpoints → Groq generation: generates answers (evidence: `README.md`)
- Supabase access → Supabase store: reads and writes (evidence: `backend/database.py`)
- GitHub identity checks → GitHub: checks responses (evidence: `backend/github_client.py`)
- Embedding batches → Gemini: creates vectors (evidence: `README.md`)
- Groq generation → Groq API: generates text (evidence: `README.md`)
- Hybrid retrieval → Supabase store: retrieves chunks (evidence: `backend/rag.py`)
