An intelligent code review tool that automatically analyzes pull requests using AI and provides detailed feedback directly on GitHub, similar to CodeRabbit.
- π€ AI-Powered Reviews: Automatic code analysis using OpenAI, Ollama, or Hugging Face
- π GitHub Integration: Seamless OAuth connection and webhook setup
- π Repository Management: Select which repositories to enable AI reviews for
- π¬ Direct Comments: AI reviews posted directly on GitHub PRs
- π Dashboard Analytics: Track review history and performance
- π§ Multiple AI Providers: Support for OpenAI, local Ollama models, and Hugging Face
- Frontend: Next.js 14, TypeScript, Tailwind CSS
- Backend: Next.js API Routes
- Database: MongoDB Atlas
- AI: OpenAI GPT-4, Ollama (local), Hugging Face
- Authentication: GitHub OAuth
- Deployment: Vercel-ready
-
Clone and install dependencies:
git clone <repository-url> cd mega-miyya npm install
-
Set up environment variables:
cp .env.example .env.local # Edit .env.local with your configuration -
Set up GitHub OAuth App:
- Create a GitHub OAuth App at GitHub Settings > Developer settings > OAuth Apps
- Set Homepage URL to
http://localhost:3004 - Set Authorization callback URL to
http://localhost:3004/api/auth/callback - Copy Client ID and Client Secret to
.env.local
-
Set up GitHub App (Optional - for bot comments):
- Follow the GitHub App Setup Guide to enable bot comments
- This makes AI reviews appear under the bot's name instead of your personal account
-
Set up AI provider:
- Choose your preferred AI provider (OpenAI, Ollama, or Hugging Face)
- Follow the setup instructions in the AI Provider Configuration section
-
Start the development server:
npm run dev
-
Connect your GitHub account:
- Visit
http://localhost:3004 - Click "Connect GitHub" and authorize the application
- Select repositories for AI review
- Visit
-
Set up webhooks:
- Go to your GitHub App settings
- The webhook URL is already configured:
http://localhost:3004/api/webhooks/github - Webhook secret should match
GITHUB_WEBHOOK_SECRET - The app will automatically receive events for all installed repositories
- Click "Connect GitHub" on the dashboard
- Authorize the application
- You'll be redirected back with your GitHub account connected
- Click "Select Repositories" in the user info section
- Choose which repositories to enable AI reviews for
- Only repositories where you have admin access will be shown
- Use the GitHub App installation UI to install the app on your repositories
- This enables bot comments instead of personal comments
- Webhooks are automatically configured at the app level
- Create a new PR in any enabled repository
- The AI will automatically analyze the code and post a review comment
- Check the dashboard to see review history and analytics
- Webhook Trigger: When a PR is created/updated, GitHub sends a webhook to
/api/webhooks/github - Repository Check: The system verifies the repository is enabled for AI reviews
- Code Analysis: Fetches PR files and generates an AI review using the configured provider
- GitHub Comment: Posts the AI review as a comment on the PR
- Dashboard Update: Stores review data for analytics and history
GET /api/auth/me- Get current user sessionPOST /api/auth/logout- Logout userGET /api/repositories- Fetch user's GitHub repositoriesPOST /api/repositories- Update selected repositoriesPOST /api/webhooks/github- GitHub webhook handlerGET /api/reviews- Get review historyPOST /api/github-app/installation-status- Check GitHub App installation statusGET /api/github-app/cache-stats- Get installation ID cache statisticsDELETE /api/github-app/cache-stats- Clear all installation ID cache
| Variable | Description | Required |
|---|---|---|
MONGODB_URI |
MongoDB connection string | Yes |
GITHUB_CLIENT_ID |
GitHub OAuth App client ID | Yes |
GITHUB_CLIENT_SECRET |
GitHub OAuth App client secret | Yes |
NEXTAUTH_SECRET |
NextAuth.js secret key | Yes |
NEXTAUTH_URL |
Application URL | Yes |
GITHUB_WEBHOOK_SECRET |
Webhook secret for verification | Yes |
GITHUB_APP_ID |
GitHub App ID (for bot comments) | No |
GITHUB_APP_PRIVATE_KEY |
GitHub App private key (for bot comments) | No |
GITHUB_APP_NAME |
GitHub App name for installation URLs (e.g., 'mega-miyya') | No |
AI_PROVIDER |
AI provider (openai/ollama/huggingface) | Yes |
OPENAI_API_KEY |
OpenAI API key | If using OpenAI |
OPENAI_MODEL |
OpenAI model name | If using OpenAI |
OLLAMA_URL |
Ollama server URL | If using Ollama |
OLLAMA_MODEL |
Ollama model name | If using Ollama |
HUGGINGFACE_API_KEY |
Hugging Face API key | If using Hugging Face |
HUGGINGFACE_PROVIDER |
Hugging Face provider | If using Hugging Face |
HUGGINGFACE_MODEL |
Hugging Face model name | If using Hugging Face |
DEFAULT_AI_PROVIDER |
Default AI provider for new users | No |
Note: Installation IDs are now detected automatically for each repository. No need to configure
GITHUB_APP_INSTALLATION_ID!
src/
βββ app/ # Next.js app directory
β βββ api/ # API routes
β β βββ auth/ # Authentication endpoints
β β βββ repositories/ # Repository management
β β βββ reviews/ # Review data
β β βββ webhooks/ # GitHub webhooks
β βββ globals.css # Global styles
β βββ page.tsx # Dashboard page
βββ components/ # React components
βββ lib/ # Utility libraries
β βββ ai-review.ts # AI review generation
β βββ database.ts # Database connection
βββ models/ # MongoDB models
- Add the provider case in
src/lib/ai-review.ts - Implement the review generation function
- Add environment variables for the provider
- Update the README with setup instructions
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy!
- Update
NEXTAUTH_URLto your production domain - Ensure all API keys and secrets are properly set
- Use a production MongoDB cluster
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
GNU Affero General Public License v3.0 (AGPL-3.0)
This project is licensed under the GNU Affero General Public License v3.0. This ensures that:
- Any derivative work must also be licensed under AGPL-3.0
- If you run this software on a server accessible to others, you must provide them access to the source code
- The software and its derivatives remain open source
For the complete license text, see LICENSE file or visit: https://www.gnu.org/licenses/agpl-3.0.txt
For issues and questions:
- Create an issue on GitHub
- Check the documentation
- Review the code examples
Follow the GitHub App Setup Guide to enable bot comments on pull requests.
The system automatically caches GitHub App installation IDs to improve performance:
- Cache Strategy: Per owner/organization (not per repository)
- Cache Duration: 24 hours
- Automatic Invalidation: When GitHub App is uninstalled
- Manual Clear: Use
DELETE /api/github-app/cache-stats - Cache Stats: Use
GET /api/github-app/cache-stats
Why per owner? Installation IDs are the same for all repositories under the same GitHub account/organization where the app is installed. This reduces API calls and improves performance.
Built with β€οΈ using Next.js, TypeScript, and AI