# arnab-iitkgp/codelens architecture

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

- Interactive diagram: https://gitdiagram.com/arnab-iitkgp/codelens
- Repository: https://github.com/arnab-iitkgp/codelens

## Overview

CodeLens automates GitHub pull-request review: GitHub events reach the webhook, which queues review or indexing work; background workers fetch repository data, build code intelligence, generate and verify findings, and publish review results. Users connect repositories, inspect reviews and agent traces, manage settings, and handle subscriptions in the dashboard. The graph includes the documented AST/RAG, multi-agent verification, and auto-fix capabilities; unsampled implementation details are represented only where README or source-index evidence supports them.

Main entry points: [`inngest/functions/index.ts`](https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/index.ts) (Repository indexing), [`module/github/lib/github.ts`](https://github.com/arnab-iitkgp/codelens/blob/main/module/github/lib/github.ts) (GitHub API), [`app/dashboard`](https://github.com/arnab-iitkgp/codelens/tree/main/app/dashboard) (Dashboard), [`app/api/webhooks/github/route.ts`](https://github.com/arnab-iitkgp/codelens/blob/main/app/api/webhooks/github/route.ts) (GitHub webhook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Dashboard"]
  node_review_views["Reviews and traces"]
  node_repo_connect["Repository management"]
end

subgraph group_integration["GitHub integration"]
  node_webhook["GitHub webhook<br/>[route.ts]"]
  node_github_api["GitHub API<br/>[github.ts]"]
end

subgraph group_processing["Background processing"]
  node_inngest_api["Inngest endpoint<br/>[route.ts]"]
  node_inngest["Job client<br/>[client.ts]"]
  node_review_job["PR review job<br/>[review.ts]"]
  node_index_job["Repository indexing<br/>[index.ts]"]
  node_autofix_job["Auto-fix job<br/>[auto-fix.ts]"]
end

subgraph group_intelligence["Review intelligence"]
  node_review_engine["Review engine<br/>[engine.ts]"]
  node_investigator["Context investigator<br/>[investigator.ts]"]
  node_models["Model routing<br/>[models.ts]"]
  node_rag["RAG and embeddings<br/>[rag.ts]"]
  node_ast["AST extraction"]
  node_resolver["Graph resolver<br/>[resolver.ts]"]
  node_fixer["Fix agent<br/>[agent-fixer.ts]"]
end

subgraph group_platform["Identity and billing"]
  node_postgres[("PostgreSQL<br/>[db.ts]")]
  node_auth["Authentication<br/>[auth.ts]"]
  node_subscription["Subscription services<br/>[subscription.ts]"]
end

node_user(("User"))
node_github["GitHub"]
node_pinecone[("Pinecone")]
node_polar["Polar"]

node_user -->|"uses"| node_dashboard
node_dashboard -->|"opens"| node_review_views
node_dashboard -->|"manages"| node_repo_connect
node_github -->|"sends events"| node_webhook
node_webhook -->|"queues review"| node_inngest
node_webhook -->|"queues auto-fix"| node_inngest
node_webhook -->|"requests reindex"| node_index_job
node_inngest_api -->|"registers"| node_review_job
node_inngest_api -->|"registers"| node_index_job
node_inngest_api -->|"registers"| node_autofix_job
node_review_job -->|"fetches PR data"| node_github_api
node_review_job -->|"generates review"| node_review_engine
node_review_job -.->|"publishes findings"| node_github_api
node_index_job -->|"fetches files"| node_github_api
node_index_job -->|"parses symbols"| node_ast
node_index_job -->|"resolves edges"| node_resolver
node_index_job -->|"indexes content"| node_rag
node_index_job -->|"stores graph"| node_postgres
node_review_engine -->|"gathers context"| node_investigator
node_review_engine -->|"generates and verifies"| node_models
node_investigator -.->|"retrieves context"| node_rag
node_rag -->|"creates embeddings"| node_models
node_rag -.->|"stores vectors"| node_pinecone
node_autofix_job -.->|"runs agent"| node_fixer
node_fixer -.->|"posts suggestions"| node_github_api
node_github_api -->|"reads and writes"| node_github
node_user -->|"authenticates"| node_auth
node_auth -->|"persists identity"| node_postgres
node_auth -->|"configures billing"| node_polar
node_auth -->|"updates tiers"| node_subscription
node_dashboard -->|"manages plan"| node_subscription
node_subscription -.->|"handles subscriptions"| node_polar

click node_dashboard "https://github.com/arnab-iitkgp/codelens/tree/main/app/dashboard"
click node_review_views "https://github.com/arnab-iitkgp/codelens/tree/main/app/dashboard/reviews"
click node_repo_connect "https://github.com/arnab-iitkgp/codelens/tree/main/module/repository"
click node_webhook "https://github.com/arnab-iitkgp/codelens/blob/main/app/api/webhooks/github/route.ts"
click node_github_api "https://github.com/arnab-iitkgp/codelens/blob/main/module/github/lib/github.ts"
click node_inngest_api "https://github.com/arnab-iitkgp/codelens/blob/main/app/api/inngest/route.ts"
click node_inngest "https://github.com/arnab-iitkgp/codelens/blob/main/inngest/client.ts"
click node_review_job "https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/review.ts"
click node_index_job "https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/index.ts"
click node_autofix_job "https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/auto-fix.ts"
click node_review_engine "https://github.com/arnab-iitkgp/codelens/blob/main/module/review/lib/engine.ts"
click node_investigator "https://github.com/arnab-iitkgp/codelens/blob/main/module/review/lib/investigator.ts"
click node_models "https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/models.ts"
click node_rag "https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/rag.ts"
click node_ast "https://github.com/arnab-iitkgp/codelens/tree/main/module/ast/lib/adapters"
click node_resolver "https://github.com/arnab-iitkgp/codelens/blob/main/module/ast/lib/resolver.ts"
click node_fixer "https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/agent-fixer.ts"
click node_postgres "https://github.com/arnab-iitkgp/codelens/blob/main/lib/db.ts"
click node_auth "https://github.com/arnab-iitkgp/codelens/blob/main/lib/auth.ts"
click node_subscription "https://github.com/arnab-iitkgp/codelens/blob/main/module/payment/lib/subscription.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_review_views,node_repo_connect,node_user toneBlue
class node_webhook,node_github_api,node_pinecone toneAmber
class node_inngest_api,node_inngest,node_review_job,node_index_job,node_autofix_job toneMint
class node_review_engine,node_investigator,node_models,node_rag,node_ast,node_resolver,node_fixer toneRose
class node_postgres,node_auth,node_subscription,node_github,node_polar toneIndigo
```

## Components

### User experience

- [Dashboard](https://github.com/arnab-iitkgp/codelens/tree/main/app/dashboard): `app/dashboard`
- [Reviews and traces](https://github.com/arnab-iitkgp/codelens/tree/main/app/dashboard/reviews): `app/dashboard/reviews`
- [Repository management](https://github.com/arnab-iitkgp/codelens/tree/main/module/repository): `module/repository`

### GitHub integration

- [GitHub webhook](https://github.com/arnab-iitkgp/codelens/blob/main/app/api/webhooks/github/route.ts): `app/api/webhooks/github/route.ts`
- [GitHub API](https://github.com/arnab-iitkgp/codelens/blob/main/module/github/lib/github.ts): `module/github/lib/github.ts`

### Background processing

- [Inngest endpoint](https://github.com/arnab-iitkgp/codelens/blob/main/app/api/inngest/route.ts): `app/api/inngest/route.ts`
- [Job client](https://github.com/arnab-iitkgp/codelens/blob/main/inngest/client.ts): `inngest/client.ts`
- [PR review job](https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/review.ts): `inngest/functions/review.ts`
- [Repository indexing](https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/index.ts): `inngest/functions/index.ts`
- [Auto-fix job](https://github.com/arnab-iitkgp/codelens/blob/main/inngest/functions/auto-fix.ts): `inngest/functions/auto-fix.ts`

### Review intelligence

- [Review engine](https://github.com/arnab-iitkgp/codelens/blob/main/module/review/lib/engine.ts): `module/review/lib/engine.ts`
- [Context investigator](https://github.com/arnab-iitkgp/codelens/blob/main/module/review/lib/investigator.ts): `module/review/lib/investigator.ts`
- [Model routing](https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/models.ts): `module/ai/lib/models.ts`
- [RAG and embeddings](https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/rag.ts): `module/ai/lib/rag.ts`
- [AST extraction](https://github.com/arnab-iitkgp/codelens/tree/main/module/ast/lib/adapters): `module/ast/lib/adapters`
- [Graph resolver](https://github.com/arnab-iitkgp/codelens/blob/main/module/ast/lib/resolver.ts): `module/ast/lib/resolver.ts`
- [Fix agent](https://github.com/arnab-iitkgp/codelens/blob/main/module/ai/lib/agent-fixer.ts): `module/ai/lib/agent-fixer.ts`

### Identity and billing

- [PostgreSQL](https://github.com/arnab-iitkgp/codelens/blob/main/lib/db.ts): `lib/db.ts`
- [Authentication](https://github.com/arnab-iitkgp/codelens/blob/main/lib/auth.ts): `lib/auth.ts`
- [Subscription services](https://github.com/arnab-iitkgp/codelens/blob/main/module/payment/lib/subscription.ts): `module/payment/lib/subscription.ts`

### Other components

- **User**
- **GitHub**
- **Pinecone**
- **Polar**

## Connections

- User → Dashboard: uses (evidence: `README.md`)
- Dashboard → Reviews and traces: opens (evidence: `README.md`)
- Dashboard → Repository management: manages (evidence: `README.md`)
- GitHub → GitHub webhook: sends events (evidence: `app/api/webhooks/github/route.ts`)
- GitHub webhook → Job client: queues review (evidence: `app/api/webhooks/github/route.ts`)
- GitHub webhook → Job client: queues auto-fix (evidence: `app/api/webhooks/github/route.ts`)
- GitHub webhook → Repository indexing: requests reindex (evidence: `app/api/webhooks/github/route.ts`)
- Inngest endpoint → PR review job: registers (evidence: `app/api/inngest/route.ts`)
- Inngest endpoint → Repository indexing: registers (evidence: `app/api/inngest/route.ts`)
- Inngest endpoint → Auto-fix job: registers (evidence: `app/api/inngest/route.ts`)
- PR review job → GitHub API: fetches PR data (evidence: `inngest/functions/review.ts`)
- PR review job → Review engine: generates review (evidence: `inngest/functions/review.ts`)
- PR review job → GitHub API: publishes findings (evidence: `inngest/functions/review.ts`)
- Repository indexing → GitHub API: fetches files (evidence: `inngest/functions/index.ts`)
- Repository indexing → AST extraction: parses symbols (evidence: `inngest/functions/index.ts`)
- Repository indexing → Graph resolver: resolves edges (evidence: `inngest/functions/index.ts`)
- Repository indexing → RAG and embeddings: indexes content (evidence: `inngest/functions/index.ts`)
- Repository indexing → PostgreSQL: stores graph (evidence: `inngest/functions/index.ts`)
- Review engine → Context investigator: gathers context (evidence: `module/review/lib/engine.ts`)
- Review engine → Model routing: generates and verifies (evidence: `module/review/lib/engine.ts`)
- Context investigator → RAG and embeddings: retrieves context
- RAG and embeddings → Model routing: creates embeddings (evidence: `module/ai/lib/rag.ts`)
- RAG and embeddings → Pinecone: stores vectors
- Auto-fix job → Fix agent: runs agent
- Fix agent → GitHub API: posts suggestions (evidence: `README.md`)
- GitHub API → GitHub: reads and writes (evidence: `module/github/lib/github.ts`)
- User → Authentication: authenticates (evidence: `README.md`)
- Authentication → PostgreSQL: persists identity (evidence: `lib/auth.ts`)
- Authentication → Polar: configures billing (evidence: `lib/auth.ts`)
- Authentication → Subscription services: updates tiers (evidence: `lib/auth.ts`)
- Dashboard → Subscription services: manages plan (evidence: `app/dashboard/subscription/page.tsx`)
- Subscription services → Polar: handles subscriptions (evidence: `README.md`)
