# alisadeghi-dev/ai-code-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/alisadeghi-dev/ai-code-analyzer
- Repository: https://github.com/alisadeghi-dev/ai-code-analyzer

## Overview

AI Codebase Auditor lets users connect a GitHub repository or upload a ZIP, builds an indexed knowledge base, and produces health reports, prioritized issues, grounded chat, and file-level explanations. The graph preserves these distinct product capabilities and the documented ingestion stages. Arrows are limited to README statements and SOURCE INDEX references or shown calls; several UI and billing subsystems are documented but their internal wiring was not sampled.

Main entry points: [`src/lib/actions/github.ts`](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/actions/github.ts) (Repository / ZIP intake), [`src/lib/analysis/vector-store.ts`](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/vector-store.ts) (Vector index), [`src/lib/analysis/pipline.ts`](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/pipline.ts) (Analysis pipeline), [`src/lib/files/storage.ts`](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/storage.ts) (Project file storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access &amp; Projects"]
  node_authui["Sign-in screens<br/>[page.tsx]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_dashboard["Project dashboard<br/>[page.tsx]"]
  node_create["New project<br/>[page.tsx]"]
end

subgraph group_ingest["Repository Ingestion"]
  node_ingestui["Repository / ZIP intake<br/>[github.ts]"]
  node_github["GitHub access<br/>[github.ts]"]
  node_extract["Filter &amp; extract<br/>[extract.ts]"]
  node_framework["Framework detection<br/>[framework.ts]"]
  node_storage[("Project file storage<br/>[storage.ts]")]
end

subgraph group_analysis["Analysis &amp; Reports"]
  node_pipeline["Analysis pipeline<br/>[pipline.ts]"]
  node_chunk["Code parsing &amp; chunking<br/>[chunking.ts]"]
  node_embedding["Local embeddings<br/>[embeddings.ts]"]
  node_vectors[("Vector index<br/>[vector-store.ts]")]
  node_report["Health report<br/>[report.ts]"]
  node_issues["Issues &amp; roadmap<br/>[page.tsx]"]
end

subgraph group_explore["Chat &amp; Explorer"]
  node_chatapi["Grounded chat API<br/>[route.ts]"]
  node_rag["Chat retrieval<br/>[chat-rag.ts]"]
  node_explorer["Code explorer<br/>[explorer.ts]"]
  node_explain["File explanations<br/>[route.ts]"]
  node_llm["Groq language model<br/>[llm.ts]"]
end

subgraph group_account["Account &amp; Billing"]
  node_settings["Account settings<br/>[page.tsx]"]
  node_entitlements["Plans &amp; entitlements<br/>[entitlements.ts]"]
  node_billing["Stripe billing<br/>[stripe.ts]"]
end

node_user(("Developer"))
node_postgres[("PostgreSQL / pgvector")]
node_githubsvc["GitHub"]
node_stripe["Stripe"]

node_user -->|"signs in"| node_authui
node_authui -.->|"authenticates"| node_auth
node_auth -->|"reads / writes"| node_postgres
node_user -->|"manages projects"| node_dashboard
node_dashboard -->|"reads projects"| node_postgres
node_user -->|"starts analysis"| node_create
node_create -.->|"submits source"| node_ingestui
node_ingestui -->|"fetches repository"| node_github
node_github -.->|"reads repository"| node_githubsvc
node_ingestui -->|"extracts files"| node_extract
node_ingestui -->|"detects framework"| node_framework
node_ingestui -->|"persists files"| node_storage
node_extract -->|"stores extracted files"| node_storage
node_storage -.->|"stores files"| node_postgres
node_user -->|"requests analysis"| node_pipeline
node_pipeline -->|"chunks source"| node_chunk
node_pipeline -->|"indexes chunks"| node_vectors
node_vectors -->|"uses chunking"| node_chunk
node_vectors -->|"embeds content"| node_embedding
node_vectors -->|"stores vectors"| node_postgres
node_pipeline -->|"generates report"| node_report
node_report -->|"requests analysis"| node_llm
node_report -.->|"persists findings"| node_postgres
node_user -->|"reviews findings"| node_issues
node_user -->|"asks question"| node_chatapi
node_chatapi -->|"retrieves context"| node_rag
node_rag -->|"embeds query"| node_embedding
node_rag -->|"searches chunks"| node_vectors
node_chatapi -->|"streams answer"| node_llm
node_user -->|"browses files"| node_explorer
node_explorer -->|"reads project files"| node_storage
node_user -->|"asks about file"| node_explain
node_explain -->|"reads selected file"| node_explorer
node_explain -->|"generates explanation"| node_llm
node_user -->|"manages account"| node_settings
node_settings -->|"loads plan limits"| node_entitlements
node_entitlements -->|"reads account state"| node_postgres
node_settings -.->|"manages subscription"| node_billing
node_billing -.->|"synchronizes billing"| node_stripe

click node_authui "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(auth)/login/page.tsx"
click node_auth "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/auth.ts"
click node_dashboard "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/dashboard/page.tsx"
click node_create "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/projects/new/page.tsx"
click node_ingestui "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/actions/github.ts"
click node_github "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/github.ts"
click node_extract "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/extract.ts"
click node_framework "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/framework.ts"
click node_storage "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/storage.ts"
click node_pipeline "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/pipline.ts"
click node_chunk "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/chunking.ts"
click node_embedding "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/embeddings.ts"
click node_vectors "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/vector-store.ts"
click node_report "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/report.ts"
click node_issues "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/projects/%5Bid%5D/issues/page.tsx"
click node_chatapi "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/api/chat/route.ts"
click node_rag "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/chat-rag.ts"
click node_explorer "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/explorer.ts"
click node_explain "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/api/explorer/explain/route.ts"
click node_llm "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/ai/llm.ts"
click node_settings "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/settings/page.tsx"
click node_entitlements "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/billing/entitlements.ts"
click node_billing "https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/billing/stripe.ts"

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_authui,node_auth,node_dashboard,node_create toneBlue
class node_ingestui,node_github,node_extract,node_framework,node_storage,node_postgres toneAmber
class node_pipeline,node_chunk,node_embedding,node_vectors,node_report,node_issues toneMint
class node_chatapi,node_rag,node_explorer,node_explain,node_llm toneRose
class node_settings,node_entitlements,node_billing,node_user,node_githubsvc,node_stripe toneIndigo
```

## Components

### Access & Projects

- [Sign-in screens](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Authentication](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Project dashboard](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`
- [New project](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/projects/new/page.tsx): `src/app/(app)/projects/new/page.tsx`

### Repository Ingestion

- [Repository / ZIP intake](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/actions/github.ts): `src/lib/actions/github.ts`
- [GitHub access](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/github.ts): `src/lib/github.ts`
- [Filter & extract](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/extract.ts): `src/lib/files/extract.ts`
- [Framework detection](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/framework.ts): `src/lib/files/framework.ts`
- [Project file storage](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/storage.ts): `src/lib/files/storage.ts`

### Analysis & Reports

- [Analysis pipeline](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/pipline.ts): `src/lib/analysis/pipline.ts`
- [Code parsing & chunking](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/chunking.ts): `src/lib/analysis/chunking.ts`
- [Local embeddings](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/embeddings.ts): `src/lib/analysis/embeddings.ts`
- [Vector index](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/vector-store.ts): `src/lib/analysis/vector-store.ts`
- [Health report](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/report.ts): `src/lib/analysis/report.ts`
- [Issues & roadmap](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/projects/%5Bid%5D/issues/page.tsx): `src/app/(app)/projects/[id]/issues/page.tsx`

### Chat & Explorer

- [Grounded chat API](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/api/chat/route.ts): `src/app/api/chat/route.ts`
- [Chat retrieval](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/analysis/chat-rag.ts): `src/lib/analysis/chat-rag.ts`
- [Code explorer](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/files/explorer.ts): `src/lib/files/explorer.ts`
- [File explanations](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/api/explorer/explain/route.ts): `src/app/api/explorer/explain/route.ts`
- [Groq language model](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/ai/llm.ts): `src/lib/ai/llm.ts`

### Account & Billing

- [Account settings](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/app/(app)/settings/page.tsx): `src/app/(app)/settings/page.tsx`
- [Plans & entitlements](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/billing/entitlements.ts): `src/lib/billing/entitlements.ts`
- [Stripe billing](https://github.com/alisadeghi-dev/ai-code-analyzer/blob/main/src/lib/billing/stripe.ts): `src/lib/billing/stripe.ts`

### Other components

- **Developer**
- **PostgreSQL / pgvector**
- **GitHub**
- **Stripe**

## Connections

- Developer → Sign-in screens: signs in
- Sign-in screens → Authentication: authenticates
- Authentication → PostgreSQL / pgvector: reads / writes (evidence: `src/lib/auth.ts`)
- Developer → Project dashboard: manages projects
- Project dashboard → PostgreSQL / pgvector: reads projects (evidence: `src/app/(app)/dashboard/page.tsx`)
- Developer → New project: starts analysis
- New project → Repository / ZIP intake: submits source
- Repository / ZIP intake → GitHub access: fetches repository (evidence: `src/lib/actions/github.ts`)
- GitHub access → GitHub: reads repository
- Repository / ZIP intake → Filter & extract: extracts files (evidence: `src/lib/actions/github.ts`)
- Repository / ZIP intake → Framework detection: detects framework (evidence: `src/lib/actions/github.ts`)
- Repository / ZIP intake → Project file storage: persists files (evidence: `src/lib/actions/github.ts`)
- Filter & extract → Project file storage: stores extracted files (evidence: `src/lib/files/storage.ts`)
- Project file storage → PostgreSQL / pgvector: stores files
- Developer → Analysis pipeline: requests analysis
- Analysis pipeline → Code parsing & chunking: chunks source (evidence: `src/lib/analysis/pipline.ts`)
- Analysis pipeline → Vector index: indexes chunks (evidence: `src/lib/analysis/pipline.ts`)
- Vector index → Code parsing & chunking: uses chunking (evidence: `src/lib/analysis/vector-store.ts`)
- Vector index → Local embeddings: embeds content (evidence: `src/lib/analysis/vector-store.ts`)
- Vector index → PostgreSQL / pgvector: stores vectors (evidence: `src/lib/analysis/vector-store.ts`)
- Analysis pipeline → Health report: generates report (evidence: `src/lib/analysis/pipline.ts`)
- Health report → Groq language model: requests analysis
- Health report → PostgreSQL / pgvector: persists findings
- Developer → Issues & roadmap: reviews findings
- Developer → Grounded chat API: asks question
- Grounded chat API → Chat retrieval: retrieves context (evidence: `src/app/api/chat/route.ts`)
- Chat retrieval → Local embeddings: embeds query (evidence: `src/lib/analysis/chat-rag.ts`)
- Chat retrieval → Vector index: searches chunks (evidence: `src/lib/analysis/chat-rag.ts`)
- Grounded chat API → Groq language model: streams answer (evidence: `src/app/api/chat/route.ts`)
- Developer → Code explorer: browses files
- Code explorer → Project file storage: reads project files (evidence: `src/lib/files/explorer.ts`)
- Developer → File explanations: asks about file
- File explanations → Code explorer: reads selected file (evidence: `src/app/api/explorer/explain/route.ts`)
- File explanations → Groq language model: generates explanation (evidence: `src/app/api/explorer/explain/route.ts`)
- Developer → Account settings: manages account
- Account settings → Plans & entitlements: loads plan limits (evidence: `src/app/(app)/settings/page.tsx`)
- Plans & entitlements → PostgreSQL / pgvector: reads account state (evidence: `src/lib/billing/entitlements.ts`)
- Account settings → Stripe billing: manages subscription
- Stripe billing → Stripe: synchronizes billing
