Skip to content

RusEu/diffusion

Repository files navigation

AI Code Review

An AI-powered code generation and review platform. Connect your GitHub repository, describe what you want to build, and let AI generate the code. Review changes like a pull request, comment on specific lines, and iterate until it's perfect.

image

Features

  • GitHub Integration: Connect any GitHub repository via OAuth
  • AI Chat Planning: Discuss your requirements with Claude AI
  • Code Generation: AI generates production-ready code changes
  • Diff Review: View changes in a familiar PR-style diff viewer
  • Inline Comments: Comment on specific lines and get AI responses
  • Iterative Refinement: AI modifies code based on your feedback
  • Apply Changes: Create branches and pull requests directly

Tech Stack

  • Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS
  • Backend: Next.js API Routes
  • Database: SQLite with Knex.js
  • AI: Anthropic Claude API
  • GitHub: Octokit for GitHub integration
  • State Management: Zustand

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm
  • GitHub OAuth App
  • Anthropic API Key

Setup

  1. Install dependencies
pnpm install
  1. Create a GitHub OAuth App

    • Go to GitHub Settings > Developer settings > OAuth Apps > New OAuth App
    • Application name: AI Code Review (or any name)
    • Homepage URL: http://localhost:3000
    • Authorization callback URL: http://localhost:3000/api/auth/github/callback
    • Copy the Client ID and generate a Client Secret
  2. Configure environment variables

cp .env.example .env

Edit .env with your credentials:

GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
ANTHROPIC_API_KEY=your_anthropic_api_key
NEXT_PUBLIC_URL=http://localhost:3000
  1. Run database migrations
pnpm migrate
  1. Start the development server
pnpm dev
  1. Open the app

Visit http://localhost:3000

Usage

  1. Sign in with GitHub - Click the sign in button to connect your GitHub account
  2. Create a Project - Select a repository to work with
  3. Start a Conversation - Describe what you want to build
  4. Select Context Files - Choose relevant files for the AI to understand
  5. Generate Code - Click "Generate Code" to create changes
  6. Review Diffs - See the changes in diff format
  7. Comment & Iterate - Add comments to request modifications
  8. Apply Changes - Create a branch and PR when satisfied

Project Structure

src/
├── app/                  # Next.js app router
│   ├── api/              # API routes
│   │   ├── auth/         # GitHub OAuth
│   │   ├── projects/     # Project CRUD
│   │   ├── conversations/# Conversation management
│   │   ├── chunks/       # Code chunk management
│   │   └── github/       # GitHub API proxy
│   ├── dashboard/        # Main dashboard
│   └── page.tsx          # Landing page
├── components/           # React components
│   ├── ChatInterface.tsx
│   ├── DiffViewer.tsx
│   ├── FileSelector.tsx
│   ├── ProjectModal.tsx
│   ├── Sidebar.tsx
│   └── ApplyChangesModal.tsx
├── lib/                  # Utility libraries
│   ├── anthropic.ts      # Claude AI integration
│   ├── auth.ts           # Authentication helpers
│   ├── db.ts             # Database connection
│   ├── diff.ts           # Diff computation
│   ├── github.ts         # GitHub API helpers
│   └── types.ts          # TypeScript types
└── stores/               # Zustand stores
    └── appStore.ts

Database Schema

  • users: GitHub user information
  • projects: Connected repositories
  • conversations: Chat sessions with AI
  • messages: Chat messages
  • chunks: Generated code changes
  • chunk_comments: User comments on code
  • comment_responses: AI responses to comments

API Endpoints

Authentication

  • GET /api/auth/github - Start GitHub OAuth
  • GET /api/auth/github/callback - OAuth callback
  • GET /api/auth/me - Get current user
  • POST /api/auth/logout - Logout

Projects

  • GET /api/projects - List projects
  • POST /api/projects - Create project
  • GET /api/projects/:id - Get project
  • PATCH /api/projects/:id - Update project
  • DELETE /api/projects/:id - Delete project

Conversations

  • GET /api/conversations - List conversations
  • POST /api/conversations - Create conversation
  • GET /api/conversations/:id - Get conversation with messages and chunks
  • POST /api/conversations/:id/messages - Send message (streaming)
  • POST /api/conversations/:id/generate - Generate code changes

Chunks

  • GET /api/chunks/:id - Get chunk with comments
  • PATCH /api/chunks/:id - Update chunk status
  • POST /api/chunks/:id/comments - Add comment

GitHub

  • GET /api/github/repos - List user repos
  • GET /api/github/tree - Get repo file tree

Apply Changes

  • POST /api/apply - Create branch and commit changes

License

MIT

About

Ai code assistent

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published