A monorepo for automated code review using AI.
sequenceDiagram
participant User
participant GitHub
participant Web as apps/web
participant WS as services/webhook-service
participant DB as packages/db
participant RI as services/repo-indexer
User->>Web: User initiates GitHub App installation
Web->>GitHub: Redirect to GitHub OAuth
GitHub->>Web: OAuth callback with installation token
Note over Web,GitHub: User selects repositories to install
GitHub->>WS: Webhook: installation created
WS->>DB: Create installation record
DB-->>WS: Installation created
loop For each repository
WS->>DB: Upsert repository
WS->>DB: Upsert RepositoryBranch (default branch)
WS->>DB: Create RepoIndexingJob (status: pending)
end
WS->>RI: Add job to repo-index queue (with branchId, jobId)
RI->>DB: Update job status to "processing"
RI->>DB: Update branch indexingStatus to "indexing"
RI->>GitHub: Fetch repository files
RI->>RI: Filter excluded files (package.json, images, binaries, etc.)
RI->>RI: Compute file hash (SHA-256)
RI->>RI: Chunk large files (500 lines, 50 overlap)
RI->>DB: Create/update IndexedFile records
RI->>DB: Create FileChunk records with embeddings
RI->>RI: Store vectors in Pinecone
RI->>DB: Update job status to "completed"
RI->>DB: Update branch indexingStatus to "indexed"
flowchart TD
A[Start Indexing Job] --> B{Job already processing?}
B -->|Yes| C[Skip - avoid duplicates]
B -->|No| D[Update job status: processing]
D --> E[Update branch indexingStatus: indexing]
E --> F[Fetch files from GitHub]
F --> G[Filter excluded files]
G --> H{For each file}
H --> I{File exists in DB?}
I -->|Yes| J{Hash changed?}
J -->|No| K[Skip - file unchanged]
J -->|Yes| L[Delete old chunks, re-index]
I -->|No| M[Create new IndexedFile]
M --> N[Chunk file content]
N --> O[Generate embeddings]
O --> P[Create FileChunk records]
P --> Q[Upsert vectors to Pinecone]
Q --> R{More files?}
R -->|Yes| H
R -->|No| S{Any failures?}
S -->|Yes| T[Update job status: pending, schedule retry]
S -->|No| U[Update job status: completed]
U --> V[Update branch indexingStatus: indexed]
sequenceDiagram
participant User
participant GitHub
participant WS as services/webhook-service
participant DB as packages/db
participant PP as services/pr-processor
participant RI as services/repo-indexer
participant AIR as services/ai-review-worker
User->>GitHub: Creates/opens PR
GitHub->>WS: Webhook: pull_request opened
WS->>DB: Find repository
DB-->>WS: Repository found
WS->>PP: Add job to pr-review queue
PP->>GitHub: Get PR details & diff
PP->>DB: Create review record (status: pending)
PP->>RI: Add job to pr-context queue
PP->>PP: Add job to pr-comment (initial comment)
PP->>GitHub: Post "processing" comment
RI->>RI: Fetch similar code from vector store
RI->>AIR: Add job to pr-ai-review queue
AIR->>AIR: Generate AI code review
AIR->>DB: Update review record (status: completed)
AIR->>PP: Add job to pr-issues queue
AIR->>PP: Add job to pr-comment (summary)
PP->>GitHub: Post inline comments for each issue
PP->>GitHub: Post summary comment
The repo-indexer automatically excludes:
package.json, package-lock.json, yarn.lock, pnpm-lock.yaml.png, .jpg, .gif, .svg, .webp), Videos, PDFsnode_modules, dist, build, .next, .nuxt.min.js, .min.css, .map.DS_Store, Thumbs.dbFileChunk tablepending and retried automaticallyThe system uses intelligent diff-based indexing to avoid full re-indexing:
Branch Create Event:
Push Event:
before (old commit SHA) vs after (new commit SHA)Worker Logic:
GET /repos/{owner}/{repo}/compare/{base}...{head}Edge Cases Handled:
apps/web: a Next.js appapps/server: a Node.js API serverpackages/ai: AI utilities shared across servicespackages/config: shared configurationpackages/db: Prisma database clientpackages/kafka: Kafka utilitiespackages/logger: logging utility shared across servicespackages/redis: Redis clientpackages/types: shared TypeScript typesservices/ai-review-worker: AI review worker serviceservices/pr-processor: PR processor and GitHub comment serviceservices/repo-indexer: Repository indexing serviceservices/webhook-service: Webhook serviceEach package/app is 100% TypeScript.
To build all apps and packages, run the following command:
pnpm build
To develop all apps and packages, run the following command:
pnpm dev
You can develop a specific package by using a filter:
pnpm dev --filter=web
pnpm dev --filter=ai-review-worker
$ claude mcp add ai-code-review-system \
-- python -m otcore.mcp_server <graph>