AI-Powered Code Review and Developer Portfolio Builder - REST API
Live API: https://codesage-ai-backend-oke3.onrender.com
- AI Code Analysis: Integration with OpenAI and Gemini for intelligent code review
- Code Quality Metrics: Pylint, Radon, and Bandit integration
- User Authentication: JWT-based secure authentication
- GitHub Integration: Fetch and analyze repositories
- RESTful API: Clean and documented API endpoints
- Database: PostgreSQL with SQLAlchemy ORM
- Rate Limiting: Redis-based API rate limiting
- Security: CORS, encryption, and secure password hashing
- Flask 3.0 - Web framework
- SQLAlchemy - ORM
- PostgreSQL - Database
- Redis - Caching and rate limiting
- JWT - Authentication
- OpenAI & Gemini - AI code analysis
- PyGithub - GitHub API integration
- Gunicorn - Production server
- Python 3.11+
- PostgreSQL 13+
- Redis 6+ (optional)
- OpenAI or Gemini API key
- GitHub Personal Access Token
- Clone the repository:
git clone https://github.com/Hillary90/codesage_ai_backend.git
cd codesage_ai_backend- Create virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
cp .env.example .env- Configure environment variables in
.env:
FLASK_APP=app.py
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
DATABASE_URL=postgresql://user:password@localhost:5432/codesage_db
JWT_SECRET_KEY=your-jwt-secret-key
GEMINI_API_KEY=your-gemini-api-key
AI_MODEL=gemini-1.5-flash
CORS_ORIGINS=http://localhost:5173- Initialize database:
flask db init
flask db migrate -m "Initial migration"
flask db upgradeflask runAPI available at http://localhost:5000
gunicorn wsgi:appcodesage_ai_backend/
├── models/ # Database models
├── routes/ # API endpoints
├── services/ # Business logic
├── utils/ # Helper functions
├── migrations/ # Database migrations
├── app.py # Application factory
├── wsgi.py # WSGI entry point
├── config.py # Configuration
├── database.py # Database setup
└── requirements.txt # Dependencies
GET /health- Check API status
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user
POST /api/reviews/analyze- Analyze codeGET /api/reviews/history- Get review historyGET /api/reviews/:id- Get specific reviewDELETE /api/reviews/:id- Delete review
GET /api/portfolio- Get user portfolioPOST /api/portfolio/project- Add projectPUT /api/portfolio/project/:id- Update projectDELETE /api/portfolio/project/:id- Delete project
GET /api/notifications- Get user notificationsPUT /api/notifications/:id/read- Mark as read
pytest
pytest --cov=. --cov-report=html- Password hashing with bcrypt
- JWT token authentication
- Rate limiting per IP/user
- CORS protection
- SQL injection prevention
- XSS protection
- Input validation and sanitization
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
Hillary
- GitHub: @Hillary90
- Flask community
- OpenAI and Google Gemini for AI capabilities
- PostgreSQL and Redis teams
- Render for hosting