Skip to content

adarshswaminath/PR-Analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

122 Commits
 
 
 
 
 
 

Repository files navigation

VCS AI Pull Request Review Application

Overview

The AI VCS PR Review application helps users connect their VCS platforms such as GitHub and GitLab. Users can list their repositories and pull requests, and review PRs using AI. The application allows users to select different AI models, such as OpenAI and Gemini, for code reviews

Scope and Goals

This initial module implementation will deliver the following capabilities:

  • Connect GitHub and GitLab repositories
  • Sync pull requests for each repository
  • Generate AI-powered summaries for pull requests
  • Delete existing pull request reviews
  • Regenerate summaries using a different AI model
  • View complete review history
  • Receive email notifications for user actions such as:
  • Repository sync
  • Pull request sync
  • AI review generation

Architecture

Image

Dependencies

  • OpenAI API – Generates AI-based code reviews and summaries for pull requests.
  • Gemini API – Provides an alternative AI model for generating PR reviews and summaries.
  • Nango – Manages OAuth authentication and securely handles API integrations and token refresh.

Data Model

  1. AIReview
  • id
  • pull_request_id
  • review
  • status
  • model
  1. PullRequest
  • id
  • repository_id
  • provider_pr_id
  • title
  • state
  • url
  • author
  • number
  • last_synced_at
  • pullRequestCount
  1. Repository
  • id
  • vcs_connection_id
  • provider_repo_id
  • name
  • description
  • is_private
  • last_synced_at
  • owner
  1. User
  • id
  • email
  • password_hash
  • email_verified
  1. VCSConnection
  • id
  • user_id
  • provider
  • connection_id
  • metadata
  1. PasswordResetToken
  • id
  • user_id
  • token
  • expires_at
  • used
  1. EmailVerificationToken
  • id
  • user_id
  • token
  • expires_at
  • used

API Design

Auth Management

Method Endpoint
POST /api/internal/v1/auth/signup
POST /api/internal/v1/auth/login
POST /api/internal/v1/auth/verify-email
POST /api/internal/v1/auth/forgot-password
POST /api/internal/v1/auth/reset-password

VCS Management APIs

Method Endpoint
GET /api/internal/v1/vcs/integrations
POST /api/internal/v1/vcs/create-session
POST /api/internal/v1/vcs/repos
POST /api/internal/v1/vcs/sync

Pull Request APIs

Method Endpoint
GET /api/internal/v1/pull-requests
POST /api/internal/v1/pull-requests/sync
GET /api/internal/v1/pull-requests/ai-models
GET /api/internal/v1/pull-requests/:id/files
GET /api/internal/v1/pull-requests/ai-review/:prId
GET /api/internal/v1/pull-requests/ai-review/:prId/history
POST /api/internal/v1/pull-requests/ai-review
PATCH /api/internal/v1/pull-requests/ai-review
DELETE /api/internal/v1/pull-requests/ai-review/:id

Health

Method Endpoint
GET /api/internal/v1/health

Components

Controllers (src/controllers/)

Handles the request–response cycle. Extracts request parameters, performs high-level validation (often using Valibot), and delegates execution to the appropriate service layer.


Services (src/services/)

Acts as the core business logic layer of the application. Services interact with models and external APIs (such as Nango and VCS providers) and orchestrate complex workflows.


Routes (src/routes/)

Responsible for API route registration. Each module defines its endpoints using a RouteDefinition structure, centralizing:

  • Path naming
  • Authentication requirements
  • Schema validation

Constants (src/constants/)

Centralized repository for application-wide constants, including:

  • AI model identifiers
  • Status enums
  • Provider configurations

Workers & Queues (src/queues/)

Handles asynchronous background processing for long-running tasks such as:

  • Repository synchronization
  • AI review generation

This ensures the user-facing API remains responsive by offloading heavy workloads to BullMQ workers.


Front end

Next Pages

/

Root entry route. Automatically redirects users to the /login page. No UI is rendered on this route.


/login

  • Form validation
  • Login API integration
  • Post-login redirection

/signup

  • User registration form
  • Input validation
  • Signup API integration
  • Redirect after successful registration

/forgot-password

  • Email input form
  • Forgot-password API integration
  • Success and error feedback

/reset-password

  • New password form
  • Token validation
  • Reset-password API integration
  • Confirmation feedback

/verify-email/[token]

  • Token validation
  • Success or failure notification
  • Automatic redirection after verification

/dashboard

  • View connected VCS integrations (GitHub, GitLab, etc.)
  • List repositories from connected providers
  • Connect new VCS providers
  • Trigger manual repository synchronization
  • View repository cards and summaries

/repositories/[repositoryId]

  • View all pull requests for the selected repository
  • View pull request status and metadata
  • Browse pull request file diffs
  • Generate and view AI-powered code reviews
  • Interact with pull request workflows

Feature Structure

  • /models - All complex Interactions, routing, API calls
  • /ui – All UI components
  • /api – All API functions
  • /hooks – All custom hooks
  • /dtos – All DTO definitions
  • /queries – All query functions (React Query)

DataFlow

UI Component

  • Triggers actions (fetch, update, create)
  • Reads data via React Query hooks

Queries

  • Contains all React Query useQuery and useMutation hooks
  • Calls the api/ layer
  • Manages:
  • Loading states
  • Error states
  • Caching
  • Refetching logic

API

  • Contains actual API request functions (GET, POST, PUT, DELETE)
  • Only responsible for making HTTP calls

UI Components

  • Receive fully prepared data from React Query via props
  • Re-render automatically when data changes
  • Show updates without manual refresh

State management

No Global state is managed, all are managed through tanstack-query.

Security & Permissions

verified users can access the platform and API's

Error Handling

  • Error from the LLM model provider (OpenAI | Gemini),
  • Rate limit errors

Since the above errors occur in the workers, we will be able to retry the jobs at a later time.

Risks & Mitigation

  • Excessive AI Usage Cost
  • Slow AI Review Processing
  • Sensitive Code Exposure to AI Providers

Monitoring & Observability

Usual alerts are well enough

Rollout Plan

Usual deployment strategy is well enough for this module rollout.

About

The AI VCS PR Review application helps users connect their VCS platforms such as GitHub and GitLab. Users can list their repositories and pull requests, and review PRs using AI. The application allows users to select different AI models, such as OpenAI and Gemini, for code reviews

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors