AI-powered codebase analyzer using Groq (Llama 3.3 70B) and GitHub API with FastAPI. No Redis required - completely stateless service.
- Multiple Analysis Types: General, Security, Architecture, Code Quality, Performance
- GitHub Integration: Webhook support for automated analysis on push
- Stateless Design: No database or Redis needed
- FastAPI: High-performance async API with automatic OpenAPI docs
- Groq LLM: Lightning-fast inference with Llama 3.3 70B
- PR Review Agent - https://github.com/Rakshit-gen/agent-prm
- Codebase Review Agent - https://github.com/Rakshit-gen/agent-code-manage
Create a .env file in the project root:
GROQ_API_KEY=gsk_your_actual_groq_api_key_here
GITHUB_TOKEN=ghp_your_actual_github_token_here
PORT=8000Get API Keys:
- Groq API: https://console.groq.com/keys (Sign up for free)
- GitHub Token: https://github.com/settings/tokens (Create personal access token with
reposcope)
pip install -r requirements.txtpython main.py- Create new Web Service on Render
- Connect your GitHub repository
- Set environment variables in Render dashboard:
GROQ_API_KEYGITHUB_TOKENPORT=8000
- Build command:
pip install -r requirements.txt - Start command:
uvicorn main:app --host 0.0.0.0 --port $PORT
FastAPI provides automatic interactive documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
POST /analyze
Content-Type: application/json
{
"repository": "owner/repo-name",
"type": "general"
}Repository formats supported:
owner/repo(e.g.,facebook/react)https://github.com/owner/repohttps://www.github.com/owner/repo
Analysis Types:
general- Comprehensive overviewsecurity- Security vulnerabilities and best practicesarchitecture- Design patterns and structurequality- Code quality and maintainabilityperformance- Performance bottlenecks and optimization
Example:
curl -X POST http://localhost:8000/analyze \
-H "Content-Type: application/json" \
-d '{
"repository": "facebook/react",
"type": "architecture"
}'Or use the interactive docs at /docs for easy testing!
GET /healthPOST /webhookSet up webhook in GitHub repository settings:
- Payload URL:
https://your-service.onrender.com/webhook - Content type:
application/json - Events: Push events
{
"success": true,
"repository": "owner/repo",
"analysis_type": "general",
"analysis": "Detailed analysis text...",
"files_analyzed": 10,
"stars": 12500,
"language": "Python"
}- Fast Analysis: Groq provides blazing-fast inference speeds
- Multiple Model Fallbacks: Automatically tries alternative models if rate limited
- Primary: Llama 3.3 70B Versatile (best quality, latest model)
- Fallback 1: Qwen3 32B (large 32K context window)
- Fallback 2: Gemma2 9B IT (Google's efficient model)
- Fallback 3: Llama 3.1 8B Instant (fastest, lower token usage)
- Deep Directory Exploration: Recursively analyzes all folders including:
app/folders (Next.js)src/directoriescomponents/folderspages/,api/,lib/, etc.
- README Priority: Always includes README.md as the first file analyzed
- Smart File Prioritization: Focuses on important files first (main, index, routes, components)
- Flexible Repository Input: Accepts both
owner/repoformat and full GitHub URLs - Async Operations: FastAPI's async support for better performance
- Auto Documentation: Interactive API docs at
/docsand/redoc - Analyzes up to 10 key source files across all directories (README + 9 other files)
- Reads repository structure up to 3 levels deep (50 items max)
- Includes README content (first 1000 chars)
- Each file limited to 1000 characters in analysis
- Files over 50KB are skipped to avoid token limits
- Supports 12+ programming languages
- Automatic webhook-based analysis
All errors return appropriate HTTP status codes with error messages:
{
"success": false,
"error": "Error description"
}- Deep Folder Analysis: The service recursively explores ALL directories including:
- Next.js:
app/,pages/,components/,lib/,public/ - React:
src/,components/,hooks/,utils/ - Backend:
api/,routes/,controllers/,models/,services/ - Any nested structure is automatically explored
- Next.js:
- Smart Prioritization: Files are analyzed in order of importance:
- Main entry points (main., app., index.*)
- API routes and controllers
- Components and pages
- Configuration files
- Other source files
- Rate Limits: The service automatically falls back to faster models if you hit Groq's rate limits
- Token Optimization: Request size optimized to stay within free tier limits (6000 TPM)
- Free Tier: Groq offers generous free tier - upgrade for more at https://console.groq.com/settings/billing
- Files over 50KB are skipped to avoid token limits
- Maximum 10 files analyzed per request
- Each file limited to 1000 characters in analysis
- README limited to 1000 characters
- Repository structure limited to 50 items
- Works with public repositories (private repos need appropriate GitHub token permissions)