AutoPR-AI is a backend REST API that enables automated code review for files. It leverages Github OAuth, OpenAI GPT-4, and MongoDB Atlas to analyze code and leave intelligent review comments directly on pull requests.
- GitHub OAuth Login
- GPT-4 Powered Code Review
- MongoDB Atlas for Data Persistence
- JWT Authentication
- RESTful API Design using FastAPI
- 📁 Upload a file via
/review/upload - 🤖 Generate a GPT-based review via
/review/analyze - 🔀 Create GitHub Pull Requests via
/github/pr - 💬 Add automated review comments via
/github/comment - 🔐 Authenticate users via GitHub OAuth via
/oauth/login - 👉 Issue JWT tokens and manage user sessions
- FastAPI – High-performance Python API framework
- MongoDB Atlas + Motor – Asynchronous database access
- GitHub OAuth + PyGithub – GitHub authentication & PR actions
- OpenAI GPT-4 API – AI-powered code analysis and comment generation
- JWT (pyjwt) – Secure user session management
- Swagger (OpenAPI) – Auto-generated documentation at /docs
- Visit
/oauth/loginto authenticate via GitHub - Receive a
jwt_tokenon successful login - Pass the token in headers for protected endpoints:
Authorization: Bearer <jwt_token>
Environment variables are required. See docs/api-usage.md for full setup.
- Clone the repository
git clone https://github.com/yourusername/AutoPR-AI.git
cd AutoPR-AI
- Set up the virtual environment
python -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Configure environment variables
- Create a
.envfile with the following keys:
- Create a
GITHUB_TOKEN=your_github_pat
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
OPENAI_API_KEY=your_openai_api_key
- Run the server
uvicorn app.main:app --reload
Detailed endpoint descriptions and request/response examples are available in API_DOC.md.
(or) Auto-generated Swagger UI is available at: http://localhost:8000/docs
- Optional cloud deployment via GCP or Azure
- Smarter GPT-4 prompt engineering
- GitHub webhook support for automatic reviews
- Frontend dashboard (React/Next.js) as a future extension
This project is licensed under the MIT License.