# aryan22n/novamerge architecture

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

- Interactive diagram: https://gitdiagram.com/aryan22n/novamerge
- Repository: https://github.com/aryan22n/novamerge

## Overview

NovaMerge is a GitHub-integrated AI pull-request reviewer. A GitHub PR webhook records the pending review and dispatches background work; the review function processes diff chunks, retrieves optional repository context, generates an AI review, posts it to the PR, and updates status. Users authenticate with GitHub, connect the GitHub App, sync repositories, and inspect review history and detail in the dashboard. The graph includes documented but unsampled webhook and integration behavior; uncertain implementation links are omitted.

Main entry points: [`features/reviews/server/review-pr-function.ts`](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/review-pr-function.ts) (Review job), [`lib/db.ts`](https://github.com/aryan22n/novamerge/blob/main/lib/db.ts) (Application database), [`features/repo-sync/server/repo-sync.ts`](https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/server/repo-sync.ts) (Repository indexing), [`features/github/server/webhook-handler.ts`](https://github.com/aryan22n/novamerge/blob/main/features/github/server/webhook-handler.ts) (Webhook handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and GitHub"]
  node_signin["GitHub sign-in"]
  node_auth["Auth actions<br/>[index.ts]"]
  node_authservice["Auth service<br/>[auth.ts]"]
  node_installation["App installation<br/>[installation.ts]"]
  node_webhook["PR webhook<br/>[route.ts]"]
  node_webhookhandler["Webhook handling<br/>[webhook-handler.ts]"]
end

subgraph group_dashboard["Dashboard and review history"]
  node_overview["Overview dashboard<br/>[get-overview.ts]"]
  node_repoapi["Repository listing API<br/>[route.ts]"]
  node_repoquery["Repository query<br/>[repos-query.ts]"]
  node_repolist["Repository list UI<br/>[repo-list.tsx]"]
  node_prlist["PR history"]
  node_prdetail["PR detail<br/>[page.tsx]"]
end

subgraph group_sync["Repository indexing"]
  node_syncui["Sync controls"]
  node_syncaction["Sync action<br/>[repo-sync.ts]"]
  node_syncfunction["Sync job"]
  node_syncservice["Repository indexing<br/>[repo-sync.ts]"]
end

subgraph group_review["AI review processing"]
  node_reviewfunction["Review job"]
  node_chunks["Diff chunking<br/>[chunk-code.ts]"]
  node_prfiles["PR file retrieval<br/>[pr-files.ts]"]
  node_vector["Review vector search<br/>[vector.ts]"]
  node_generation["AI review generation<br/>[generate-review.ts]"]
  node_comment["PR comment posting<br/>[post-pr-comment.ts]"]
end

subgraph group_runtime["Persistence and jobs"]
  node_db[("Application database<br/>[db.ts]")]
  node_inngest["Inngest client<br/>[client.ts]"]
  node_jobroutes["Job registration<br/>[route.ts]"]
end

node_user(("User"))
node_github{{"GitHub"}}
node_ai{{"OpenRouter AI<br/>[index.ts]"}}
node_pinecone[("Pinecone<br/>[client.ts]")]

node_user -->|"starts sign-in"| node_signin
node_signin -->|"submits to"| node_auth
node_auth -->|"authenticates with"| node_authservice
node_authservice -->|"stores sessions"| node_db
node_github -->|"returns install callback"| node_installation
node_installation -->|"stores installation"| node_db
node_github -->|"sends PR event"| node_webhook
node_webhook -.->|"delegates handling"| node_webhookhandler
node_webhookhandler -->|"saves PR"| node_db
node_webhookhandler -->|"dispatches review event"| node_inngest
node_user -->|"views dashboard"| node_overview
node_overview -->|"reads activity"| node_db
node_user -->|"browses repositories"| node_repoquery
node_repoquery -->|"fetches pages"| node_repoapi
node_repoapi -->|"gets installation"| node_installation
node_repoapi -->|"reads sync status"| node_db
node_repoquery -->|"provides pages"| node_repolist
node_user -->|"browses reviews"| node_prlist
node_prlist -->|"reads PR records"| node_db
node_user -->|"opens review detail"| node_prdetail
node_prdetail -.->|"loads review"| node_db
node_user -.->|"requests code sync"| node_syncui
node_syncui -.->|"invokes sync"| node_syncaction
node_syncaction -.->|"dispatches sync"| node_inngest
node_jobroutes -->|"registers job"| node_syncfunction
node_syncfunction -.->|"runs indexing"| node_syncservice
node_syncservice -->|"records sync state"| node_db
node_syncservice -->|"upserts code vectors"| node_pinecone
node_jobroutes -->|"registers job"| node_reviewfunction
node_reviewfunction -->|"updates review status"| node_db
node_reviewfunction -->|"retrieves changed files"| node_prfiles
node_reviewfunction -->|"chunks diffs"| node_chunks
node_reviewfunction -->|"saves and searches vectors"| node_vector
node_reviewfunction -->|"builds repo namespace"| node_syncservice
node_reviewfunction -->|"requests review"| node_generation
node_generation -->|"generates review"| node_ai
node_reviewfunction -->|"posts review"| node_comment
node_comment -.->|"comments on PR"| node_github
node_vector -.->|"searches vectors"| node_pinecone

click node_signin "https://github.com/aryan22n/novamerge/blob/main/features/auth/components/github-sign-in-form.tsx"
click node_auth "https://github.com/aryan22n/novamerge/blob/main/features/auth/actions/index.ts"
click node_authservice "https://github.com/aryan22n/novamerge/blob/main/lib/auth.ts"
click node_installation "https://github.com/aryan22n/novamerge/blob/main/features/github/server/installation.ts"
click node_webhook "https://github.com/aryan22n/novamerge/blob/main/app/api/github/webhook/route.ts"
click node_webhookhandler "https://github.com/aryan22n/novamerge/blob/main/features/github/server/webhook-handler.ts"
click node_overview "https://github.com/aryan22n/novamerge/blob/main/features/overview/server/get-overview.ts"
click node_repoapi "https://github.com/aryan22n/novamerge/blob/main/app/api/github/repos/route.ts"
click node_repoquery "https://github.com/aryan22n/novamerge/blob/main/features/github/lib/repos-query.ts"
click node_repolist "https://github.com/aryan22n/novamerge/blob/main/features/dashboard/components/repo-list.tsx"
click node_prlist "https://github.com/aryan22n/novamerge/blob/main/features/pull-requests/server/get-pull-requests.ts"
click node_prdetail "https://github.com/aryan22n/novamerge/blob/main/app/(protected)/dashboard/pull-requests/%5Bid%5D/page.tsx"
click node_syncui "https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/components/sync-repo-button.tsx"
click node_syncaction "https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/actions/repo-sync.ts"
click node_syncfunction "https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/server/repo-sync-function.ts"
click node_syncservice "https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/server/repo-sync.ts"
click node_reviewfunction "https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/review-pr-function.ts"
click node_chunks "https://github.com/aryan22n/novamerge/blob/main/features/reviews/utils/chunk-code.ts"
click node_prfiles "https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/pr-files.ts"
click node_vector "https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/vector.ts"
click node_generation "https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/generate-review.ts"
click node_comment "https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/post-pr-comment.ts"
click node_ai "https://github.com/aryan22n/novamerge/blob/main/features/ai/index.ts"
click node_pinecone "https://github.com/aryan22n/novamerge/blob/main/features/pinecone/client.ts"
click node_db "https://github.com/aryan22n/novamerge/blob/main/lib/db.ts"
click node_inngest "https://github.com/aryan22n/novamerge/blob/main/features/inngest/client.ts"
click node_jobroutes "https://github.com/aryan22n/novamerge/blob/main/app/api/inngest/route.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_signin,node_auth,node_authservice,node_installation,node_webhook,node_webhookhandler,node_user toneBlue
class node_overview,node_repoapi,node_repoquery,node_repolist,node_prlist,node_prdetail,node_pinecone toneAmber
class node_syncui,node_syncaction,node_syncfunction,node_syncservice,node_ai toneMint
class node_reviewfunction,node_chunks,node_prfiles,node_vector,node_generation,node_comment toneRose
class node_db,node_inngest,node_jobroutes,node_github toneIndigo
```

## Components

### Identity and GitHub

- [GitHub sign-in](https://github.com/aryan22n/novamerge/blob/main/features/auth/components/github-sign-in-form.tsx): `features/auth/components/github-sign-in-form.tsx`
- [Auth actions](https://github.com/aryan22n/novamerge/blob/main/features/auth/actions/index.ts): `features/auth/actions/index.ts`
- [Auth service](https://github.com/aryan22n/novamerge/blob/main/lib/auth.ts): `lib/auth.ts`
- [App installation](https://github.com/aryan22n/novamerge/blob/main/features/github/server/installation.ts): `features/github/server/installation.ts`
- [PR webhook](https://github.com/aryan22n/novamerge/blob/main/app/api/github/webhook/route.ts): `app/api/github/webhook/route.ts`
- [Webhook handling](https://github.com/aryan22n/novamerge/blob/main/features/github/server/webhook-handler.ts): `features/github/server/webhook-handler.ts`

### Dashboard and review history

- [Overview dashboard](https://github.com/aryan22n/novamerge/blob/main/features/overview/server/get-overview.ts): `features/overview/server/get-overview.ts`
- [Repository listing API](https://github.com/aryan22n/novamerge/blob/main/app/api/github/repos/route.ts): `app/api/github/repos/route.ts`
- [Repository query](https://github.com/aryan22n/novamerge/blob/main/features/github/lib/repos-query.ts): `features/github/lib/repos-query.ts`
- [Repository list UI](https://github.com/aryan22n/novamerge/blob/main/features/dashboard/components/repo-list.tsx): `features/dashboard/components/repo-list.tsx`
- [PR history](https://github.com/aryan22n/novamerge/blob/main/features/pull-requests/server/get-pull-requests.ts): `features/pull-requests/server/get-pull-requests.ts`
- [PR detail](https://github.com/aryan22n/novamerge/blob/main/app/(protected)/dashboard/pull-requests/%5Bid%5D/page.tsx): `app/(protected)/dashboard/pull-requests/[id]/page.tsx`

### Repository indexing

- [Sync controls](https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/components/sync-repo-button.tsx): `features/repo-sync/components/sync-repo-button.tsx`
- [Sync action](https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/actions/repo-sync.ts): `features/repo-sync/actions/repo-sync.ts`
- [Sync job](https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/server/repo-sync-function.ts): `features/repo-sync/server/repo-sync-function.ts`
- [Repository indexing](https://github.com/aryan22n/novamerge/blob/main/features/repo-sync/server/repo-sync.ts): `features/repo-sync/server/repo-sync.ts`

### AI review processing

- [Review job](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/review-pr-function.ts): `features/reviews/server/review-pr-function.ts`
- [Diff chunking](https://github.com/aryan22n/novamerge/blob/main/features/reviews/utils/chunk-code.ts): `features/reviews/utils/chunk-code.ts`
- [PR file retrieval](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/pr-files.ts): `features/reviews/server/pr-files.ts`
- [Review vector search](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/vector.ts): `features/reviews/server/vector.ts`
- [AI review generation](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/generate-review.ts): `features/reviews/server/generate-review.ts`
- [PR comment posting](https://github.com/aryan22n/novamerge/blob/main/features/reviews/server/post-pr-comment.ts): `features/reviews/server/post-pr-comment.ts`

### Persistence and jobs

- [Application database](https://github.com/aryan22n/novamerge/blob/main/lib/db.ts): `lib/db.ts`
- [Inngest client](https://github.com/aryan22n/novamerge/blob/main/features/inngest/client.ts): `features/inngest/client.ts`
- [Job registration](https://github.com/aryan22n/novamerge/blob/main/app/api/inngest/route.ts): `app/api/inngest/route.ts`

### Other components

- **User**
- **GitHub**
- [OpenRouter AI](https://github.com/aryan22n/novamerge/blob/main/features/ai/index.ts): `features/ai/index.ts`
- [Pinecone](https://github.com/aryan22n/novamerge/blob/main/features/pinecone/client.ts): `features/pinecone/client.ts`

## Connections

- User → GitHub sign-in: starts sign-in
- GitHub sign-in → Auth actions: submits to (evidence: `features/auth/actions/index.ts`)
- Auth actions → Auth service: authenticates with (evidence: `features/auth/actions/index.ts`)
- Auth service → Application database: stores sessions (evidence: `lib/auth.ts`)
- GitHub → App installation: returns install callback
- App installation → Application database: stores installation (evidence: `features/github/server/installation.ts`)
- GitHub → PR webhook: sends PR event
- PR webhook → Webhook handling: delegates handling
- Webhook handling → Application database: saves PR (evidence: `features/github/server/webhook-handler.ts`)
- Webhook handling → Inngest client: dispatches review event (evidence: `features/github/server/webhook-handler.ts`)
- User → Overview dashboard: views dashboard
- Overview dashboard → Application database: reads activity (evidence: `features/overview/server/get-overview.ts`)
- User → Repository query: browses repositories
- Repository query → Repository listing API: fetches pages (evidence: `features/github/lib/repos-query.ts`)
- Repository listing API → App installation: gets installation (evidence: `app/api/github/repos/route.ts`)
- Repository listing API → Application database: reads sync status (evidence: `app/api/github/repos/route.ts`)
- Repository query → Repository list UI: provides pages (evidence: `features/dashboard/components/repo-list.tsx`)
- User → PR history: browses reviews
- PR history → Application database: reads PR records (evidence: `features/pull-requests/server/get-pull-requests.ts`)
- User → PR detail: opens review detail (evidence: `app/(protected)/dashboard/pull-requests/[id]/page.tsx`)
- PR detail → Application database: loads review
- User → Sync controls: requests code sync
- Sync controls → Sync action: invokes sync
- Sync action → Inngest client: dispatches sync
- Job registration → Sync job: registers job (evidence: `app/api/inngest/route.ts`)
- Sync job → Repository indexing: runs indexing
- Repository indexing → Application database: records sync state (evidence: `features/repo-sync/server/repo-sync.ts`)
- Repository indexing → Pinecone: upserts code vectors (evidence: `features/repo-sync/server/repo-sync.ts`)
- Job registration → Review job: registers job (evidence: `app/api/inngest/route.ts`)
- Review job → Application database: updates review status (evidence: `features/reviews/server/review-pr-function.ts`)
- Review job → PR file retrieval: retrieves changed files (evidence: `features/reviews/server/review-pr-function.ts`)
- Review job → Diff chunking: chunks diffs (evidence: `features/reviews/server/review-pr-function.ts`)
- Review job → Review vector search: saves and searches vectors (evidence: `features/reviews/server/review-pr-function.ts`)
- Review job → Repository indexing: builds repo namespace (evidence: `features/reviews/server/review-pr-function.ts`)
- Review job → AI review generation: requests review (evidence: `features/reviews/server/review-pr-function.ts`)
- AI review generation → OpenRouter AI: generates review (evidence: `features/reviews/server/generate-review.ts`)
- Review job → PR comment posting: posts review (evidence: `features/reviews/server/review-pr-function.ts`)
- PR comment posting → GitHub: comments on PR
- Review vector search → Pinecone: searches vectors
