# shakilurrehman21/repolens architecture

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

- Interactive diagram: https://gitdiagram.com/shakilurrehman21/repolens
- Repository: https://github.com/shakilurrehman21/repolens

## Overview

RepoLens is a GitHub repository intelligence SaaS. A signed-in user imports a repository, starts a scan, and views scored findings and file-level reviews; the API starts the pipeline, which fetches repository data, runs AI analyses, aggregates scores, and persists results. Separate branches provide interactive file analysis, pull-request reviews and webhook automation, dashboards, exports, and administration. The README documents these capabilities; where route or UI implementations were not sampled, paths and wiring below reflect only the file tree and documented behavior.

Main entry points: [`app/(dashboard)`](https://github.com/shakilurrehman21/repolens/tree/master/app/(dashboard)) (Dashboard views), [`db/index.ts`](https://github.com/shakilurrehman21/repolens/blob/master/db/index.ts) (Application database), [`lib/ai/pipeline.ts`](https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/pipeline.ts) (Scan orchestrator), [`app/api/pr-reviews`](https://github.com/shakilurrehman21/repolens/tree/master/app/api/pr-reviews) (Manual PR reviews)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_dashboard["Dashboard views"]
  node_auth_pages["Sign-in and account"]
end

subgraph group_repo_scan["Repository and scans"]
  node_user_api["User profile API<br/>[route.ts]"]
  node_import_api["Repository import<br/>[route.ts]"]
  node_repo_api["Repository listing<br/>[route.ts]"]
  node_github_repos_api["GitHub repository list<br/>[route.ts]"]
  node_scan_start["Start scan API<br/>[route.ts]"]
  node_scan_read["Scan history and results"]
end

subgraph group_analysis["AI analysis"]
  node_file_api["Interactive file analysis<br/>[route.ts]"]
  node_pipeline["Scan orchestrator<br/>[pipeline.ts]"]
  node_ai_prompts["Analysis stages and prompts<br/>[prompts.ts]"]
  node_gemini["Structured AI client<br/>[gemini-client.ts]"]
  node_scoring["Weighted scoring<br/>[scoring.ts]"]
end

subgraph group_pr["Pull request reviews"]
  node_pr_api["Manual PR reviews"]
  node_webhook["GitHub PR webhook<br/>[route.ts]"]
end

subgraph group_data_output["Data and reporting"]
  node_exports["Reports and sharing"]
  node_admin["Administration"]
  node_database[("Application database<br/>[index.ts]")]
end

node_user(("User"))
node_github["GitHub API"]
node_clerk["Clerk identity and OAuth"]
node_gemini_service["Google Gemini"]

node_user -->|"signs in"| node_auth_pages
node_user -->|"uses"| node_dashboard
node_dashboard -->|"loads profile"| node_user_api
node_user_api -->|"gets OAuth token"| node_clerk
node_user_api -->|"reads and writes"| node_database
node_dashboard -->|"browses GitHub repos"| node_github_repos_api
node_github_repos_api -->|"reads token"| node_database
node_github_repos_api -->|"lists repositories"| node_github
node_dashboard -->|"imports repository"| node_import_api
node_import_api -->|"fetches repository"| node_github
node_import_api -->|"stores repository"| node_database
node_dashboard -->|"loads saved repositories"| node_repo_api
node_repo_api -->|"reads repositories"| node_database
node_dashboard -->|"starts scan"| node_scan_start
node_scan_start -->|"checks and creates scan"| node_database
node_scan_start -->|"dispatches analysis"| node_pipeline
node_pipeline -->|"fetches tree and files"| node_github
node_pipeline -->|"builds stage prompts"| node_ai_prompts
node_pipeline -->|"requests structured analyses"| node_gemini
node_gemini -->|"generates JSON"| node_gemini_service
node_pipeline -->|"calculates overall score"| node_scoring
node_pipeline -->|"stores progress and results"| node_database
node_dashboard -->|"loads scan results"| node_scan_read
node_scan_read -->|"reads scans and reviews"| node_database
node_dashboard -->|"requests file review"| node_file_api
node_file_api -->|"fetches file content"| node_github
node_file_api -->|"requests line analysis"| node_gemini
node_dashboard -->|"requests PR review"| node_pr_api
node_pr_api -->|"fetches PR diff"| node_github
node_pr_api -->|"analyzes diff"| node_gemini
node_pr_api -->|"stores review"| node_database
node_pr_api -.->|"posts optional comment"| node_github
node_github -->|"sends PR event"| node_webhook
node_webhook -->|"looks up and stores review"| node_database
node_webhook -->|"fetches diff and comments"| node_github
node_webhook -->|"analyzes diff"| node_gemini
node_dashboard -->|"requests report or share link"| node_exports
node_exports -->|"reads scan results"| node_database
node_user -->|"uses admin dashboard"| node_admin
node_admin -->|"reads and updates records"| node_database

click node_dashboard "https://github.com/shakilurrehman21/repolens/tree/master/app/(dashboard)"
click node_user_api "https://github.com/shakilurrehman21/repolens/blob/master/app/api/user/route.ts"
click node_import_api "https://github.com/shakilurrehman21/repolens/blob/master/app/api/github/import-url/route.ts"
click node_repo_api "https://github.com/shakilurrehman21/repolens/blob/master/app/api/repos/route.ts"
click node_github_repos_api "https://github.com/shakilurrehman21/repolens/blob/master/app/api/github/repos/route.ts"
click node_scan_start "https://github.com/shakilurrehman21/repolens/blob/master/app/api/scans/start/route.ts"
click node_scan_read "https://github.com/shakilurrehman21/repolens/tree/master/app/api/scans"
click node_file_api "https://github.com/shakilurrehman21/repolens/blob/master/app/api/analyze/file/route.ts"
click node_pipeline "https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/pipeline.ts"
click node_ai_prompts "https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/prompts.ts"
click node_gemini "https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/gemini-client.ts"
click node_scoring "https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/scoring.ts"
click node_pr_api "https://github.com/shakilurrehman21/repolens/tree/master/app/api/pr-reviews"
click node_webhook "https://github.com/shakilurrehman21/repolens/blob/master/app/api/webhooks/github/route.ts"
click node_exports "https://github.com/shakilurrehman21/repolens/tree/master/app/api/export"
click node_admin "https://github.com/shakilurrehman21/repolens/tree/master/app/api/admin"
click node_database "https://github.com/shakilurrehman21/repolens/blob/master/db/index.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_dashboard,node_auth_pages,node_user toneBlue
class node_user_api,node_import_api,node_repo_api,node_github_repos_api,node_scan_start,node_scan_read toneAmber
class node_file_api,node_pipeline,node_ai_prompts,node_gemini,node_scoring,node_github toneMint
class node_pr_api,node_webhook toneRose
class node_exports,node_admin,node_database,node_clerk,node_gemini_service toneIndigo
```

## Components

### User interface

- [Dashboard views](https://github.com/shakilurrehman21/repolens/tree/master/app/(dashboard)): `app/(dashboard)`
- **Sign-in and account**

### Repository and scans

- [User profile API](https://github.com/shakilurrehman21/repolens/blob/master/app/api/user/route.ts): `app/api/user/route.ts`
- [Repository import](https://github.com/shakilurrehman21/repolens/blob/master/app/api/github/import-url/route.ts): `app/api/github/import-url/route.ts`
- [Repository listing](https://github.com/shakilurrehman21/repolens/blob/master/app/api/repos/route.ts): `app/api/repos/route.ts`
- [GitHub repository list](https://github.com/shakilurrehman21/repolens/blob/master/app/api/github/repos/route.ts): `app/api/github/repos/route.ts`
- [Start scan API](https://github.com/shakilurrehman21/repolens/blob/master/app/api/scans/start/route.ts): `app/api/scans/start/route.ts`
- [Scan history and results](https://github.com/shakilurrehman21/repolens/tree/master/app/api/scans): `app/api/scans`

### AI analysis

- [Interactive file analysis](https://github.com/shakilurrehman21/repolens/blob/master/app/api/analyze/file/route.ts): `app/api/analyze/file/route.ts`
- [Scan orchestrator](https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/pipeline.ts): `lib/ai/pipeline.ts`
- [Analysis stages and prompts](https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/prompts.ts): `lib/ai/prompts.ts`
- [Structured AI client](https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/gemini-client.ts): `lib/ai/gemini-client.ts`
- [Weighted scoring](https://github.com/shakilurrehman21/repolens/blob/master/lib/ai/scoring.ts): `lib/ai/scoring.ts`

### Pull request reviews

- [Manual PR reviews](https://github.com/shakilurrehman21/repolens/tree/master/app/api/pr-reviews): `app/api/pr-reviews`
- [GitHub PR webhook](https://github.com/shakilurrehman21/repolens/blob/master/app/api/webhooks/github/route.ts): `app/api/webhooks/github/route.ts`

### Data and reporting

- [Reports and sharing](https://github.com/shakilurrehman21/repolens/tree/master/app/api/export): `app/api/export`
- [Administration](https://github.com/shakilurrehman21/repolens/tree/master/app/api/admin): `app/api/admin`
- [Application database](https://github.com/shakilurrehman21/repolens/blob/master/db/index.ts): `db/index.ts`

### Other components

- **User**
- **GitHub API**
- **Clerk identity and OAuth**
- **Google Gemini**

## Connections

- User → Sign-in and account: signs in
- User → Dashboard views: uses
- Dashboard views → User profile API: loads profile
- User profile API → Clerk identity and OAuth: gets OAuth token
- User profile API → Application database: reads and writes
- Dashboard views → GitHub repository list: browses GitHub repos
- GitHub repository list → Application database: reads token
- GitHub repository list → GitHub API: lists repositories
- Dashboard views → Repository import: imports repository
- Repository import → GitHub API: fetches repository
- Repository import → Application database: stores repository
- Dashboard views → Repository listing: loads saved repositories
- Repository listing → Application database: reads repositories
- Dashboard views → Start scan API: starts scan
- Start scan API → Application database: checks and creates scan
- Start scan API → Scan orchestrator: dispatches analysis
- Scan orchestrator → GitHub API: fetches tree and files
- Scan orchestrator → Analysis stages and prompts: builds stage prompts
- Scan orchestrator → Structured AI client: requests structured analyses
- Structured AI client → Google Gemini: generates JSON
- Scan orchestrator → Weighted scoring: calculates overall score
- Scan orchestrator → Application database: stores progress and results
- Dashboard views → Scan history and results: loads scan results
- Scan history and results → Application database: reads scans and reviews
- Dashboard views → Interactive file analysis: requests file review
- Interactive file analysis → GitHub API: fetches file content
- Interactive file analysis → Structured AI client: requests line analysis
- Dashboard views → Manual PR reviews: requests PR review
- Manual PR reviews → GitHub API: fetches PR diff
- Manual PR reviews → Structured AI client: analyzes diff
- Manual PR reviews → Application database: stores review
- Manual PR reviews → GitHub API: posts optional comment
- GitHub API → GitHub PR webhook: sends PR event
- GitHub PR webhook → Application database: looks up and stores review
- GitHub PR webhook → GitHub API: fetches diff and comments
- GitHub PR webhook → Structured AI client: analyzes diff
- Dashboard views → Reports and sharing: requests report or share link
- Reports and sharing → Application database: reads scan results
- User → Administration: uses admin dashboard
- Administration → Application database: reads and updates records
