Skip to content

musarrat950/windsurf-project

Repository files navigation

Karakoram 2 Mini

A lightweight, AI-powered code review tool inspired by CodeRabbit. This project provides automated code analysis, intelligent review comments, and seamless integration with popular Git platforms, now powered by Supabase.

Features

Core Features

  • AI-Powered Code Reviews: Leverages Groq's Kimi K2 model for intelligent code analysis and suggestions
  • Multi-Platform Support: Works with GitHub, GitLab, and Bitbucket repositories
  • Real-time Analysis: Automated reviews triggered by pull request events
  • Security Scanning: Identifies potential security vulnerabilities in code changes
  • Code Quality Metrics: Analyzes code complexity, maintainability, and best practices
  • Interactive Dashboard: Modern React-based UI for managing repositories and reviews

Technical Features

  • RESTful API: FastAPI-based backend with comprehensive API documentation
  • Supabase Integration: PostgreSQL database with real-time subscriptions and Row Level Security
  • Supabase Authentication: Built-in user authentication with email/password and social providers
  • Webhook Integration: Secure webhook handling for Git platform events
  • Background Processing: Celery-based task queue for asynchronous operations
  • Caching: Redis integration for improved performance
  • TypeScript: Type-safe JavaScript development
  • Material-UI: Professional React component library
  • React Router: Client-side routing
  • Axios: HTTP client for API communication

Tech Stack

Backend

  • FastAPI: High-performance Python web framework
  • Supabase: PostgreSQL database with real-time subscriptions and Row Level Security
  • Supabase Python Client: Direct database operations and authentication
  • Groq Kimi K2: AI-powered code analysis and review generation

Frontend

  • React 18: Modern UI library with hooks
  • TypeScript: Type-safe JavaScript development
  • Material-UI: Professional React component library
  • React Router: Client-side routing
  • Axios: HTTP client for API communication

Project Structure

karakoram-2-mini/
├── app/                    # Backend FastAPI application
│   ├── api/               # API route handlers
│   │   ├── auth.py        # Authentication endpoints
│   │   ├── repositories.py # Repository management
│   │   ├── reviews.py     # Review management
│   │   └── webhooks.py    # Webhook handlers
│   ├── services/          # Business logic services
│   │   ├── groq_service.py      # Groq integration
│   │   ├── github_service.py    # GitHub API client
│   │   ├── code_analyzer.py     # Static code analysis
│   │   └── review_service.py    # Review orchestration
│   ├── models.py          # Database models
│   ├── schemas.py         # Pydantic schemas
│   ├── auth.py           # Authentication utilities
│   ├── config.py         # Application configuration
│   ├── database.py       # Database setup
│   └── main.py           # FastAPI application entry point
├── frontend/              # React frontend application
│   ├── src/
│   │   ├── components/    # Reusable UI components
│   │   ├── pages/        # Page components
│   │   ├── contexts/     # React contexts
│   │   └── App.tsx       # Main application component
│   └── package.json      # Frontend dependencies
├── alembic/              # Database migrations
├── requirements.txt      # Python dependencies
├── supabase_schema.sql   # Supabase database schema
└── README.md            # This file

Installation

Prerequisites

  • Python 3.8+
  • Node.js 16+
  • Supabase account
  • Redis 6+ (optional, for caching)

Supabase Setup

  1. Create a Supabase project

    • Go to supabase.com
    • Create a new project
    • Note your project URL and anon key
  2. Set up the database schema

    • Go to your Supabase dashboard
    • Navigate to SQL Editor
    • Copy and paste the contents of supabase_schema.sql
    • Run the SQL commands to create tables and policies

Backend Setup

  1. Clone the repository

    git clone <repository-url>
    cd karakoram-2-mini
  2. Create virtual environment

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Environment configuration

    cp .env.example .env
    # Edit .env with your Supabase configuration:
    # SUPABASE_URL=https://your-project-ref.supabase.co
    # SUPABASE_ANON_KEY=your-supabase-anon-key
    # SUPABASE_SERVICE_ROLE_KEY=your-supabase-service-role-key
  5. Start the backend server

    uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Frontend Setup

  1. Navigate to frontend directory

    cd frontend
  2. Environment configuration

    cp .env.example .env
    # Edit .env with your Supabase configuration:
    # REACT_APP_SUPABASE_URL=https://your-project-ref.supabase.co
    # REACT_APP_SUPABASE_ANON_KEY=your-supabase-anon-key
  3. Install dependencies

    npm install
  4. Start the development server

    npm start

The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs

## Configuration

### Environment Variables

Create a `.env` file based on `.env.example`:

```env
# Database
DATABASE_URL=postgresql://user:password@localhost:5432/karakoram_db

# Redis (optional)
REDIS_URL=redis://localhost:6379

# Groq API
GROQ_API_KEY=your-groq-api-key-here

# GitHub Integration
GITHUB_APP_ID=your-github-app-id
GITHUB_PRIVATE_KEY=your-github-private-key
GITHUB_WEBHOOK_SECRET=your-webhook-secret

# Application
DEBUG=True
CORS_ORIGINS=["http://localhost:3000"]

GitHub Webhook Setup

  1. Create a GitHub App or use webhooks
  2. Set the webhook URL to: https://your-domain.com/webhooks/github
  3. Subscribe to pull_request and push events
  4. Add the webhook secret to your environment variables

API Endpoints

Authentication

  • POST /auth/register - Register new user
  • POST /auth/login - User login
  • GET /auth/me - Get current user

Repositories

  • GET /repositories/ - List repositories
  • POST /repositories/ - Add repository
  • GET /repositories/{id} - Get repository details
  • PUT /repositories/{id}/settings - Update settings
  • DELETE /repositories/{id} - Deactivate repository

Reviews

  • GET /reviews/ - List reviews
  • POST /reviews/ - Create new review
  • GET /reviews/{id} - Get review details
  • GET /reviews/pull-requests/{pr_id}/reviews - Get PR reviews

Webhooks

  • POST /webhooks/github - GitHub webhook handler
  • POST /webhooks/gitlab - GitLab webhook handler
  • POST /webhooks/bitbucket - Bitbucket webhook handler

Features in Detail

AI-Powered Code Analysis

  • Uses Groq Kimi K2 model for intelligent code review
  • Analyzes code diffs for quality, security, and performance issues
  • Generates human-readable suggestions and improvements
  • Provides overall code quality scores

Static Code Analysis

  • Pattern-based security vulnerability detection
  • Code quality checks (complexity, style, best practices)
  • Language-specific analysis for Python, JavaScript, and more
  • Configurable rules and severity levels

GitHub Integration

  • Automatic PR monitoring via webhooks
  • Real-time review triggering on PR events
  • Support for multiple repositories
  • Secure webhook signature verification

Modern Web Interface

  • Responsive Material-UI design
  • Real-time review status updates
  • Detailed review reports with syntax highlighting
  • Repository management dashboard

Development

Running Tests

# Backend tests
pytest

# Frontend tests
cd frontend && npm test

Database Migrations

# Create new migration
alembic revision --autogenerate -m "Description"

# Apply migrations
alembic upgrade head

# Rollback migration
alembic downgrade -1

Code Formatting

# Python
black app/
isort app/

# TypeScript/React
cd frontend && npm run format

Deployment

Docker Deployment

# Build and run with docker-compose
docker-compose up -d

Manual Deployment

  1. Set up production environment variables
  2. Configure reverse proxy (nginx)
  3. Set up SSL certificates
  4. Configure database and Redis
  5. Deploy backend and frontend separately

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions, please open an issue on GitHub or contact the development team.


Karakoram 2 Mini - Bringing AI-powered code review to your development workflow.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors