AI-Powered Code Analysis & Auto-Fix Tool
Analyze code quality, detect bugs, and automatically fix issues using advanced AI technology.
Code_Review_AI.mp4
- Overview
- Architecture
- Why Two Backends?
- Features
- Tech Stack
- Getting Started
- Deployment
- API Documentation
- Future Roadmap
- Contributing
- License
CodeReviewAI is a comprehensive code analysis platform that helps developers:
- π Analyze code for bugs, security issues, and code smells
- π§ Auto-fix common coding errors and anti-patterns
- π Get detailed insights into code quality metrics
- π Learn best practices through AI-powered recommendations
The platform uses a three-tier architecture with separate Python AI backend, Java middleware, and React frontend to provide scalable, maintainable, and enterprise-ready code analysis.
βββββββββββββββββββ
β React Frontend β (Vite + React)
β (Vercel) β
ββββββββββ¬βββββββββ
β HTTPS
βΌ
βββββββββββββββββββ
β Java Backend β (Spring Boot)
β (Railway) β - API Gateway
β β - Business Logic
β β - Caching (Future)
ββββββββββ¬βββββββββ
β HTTPS
βΌ
βββββββββββββββββββ
β Python Backend β (FastAPI)
β (Railway) β - AI/ML Processing
β β - Code Analysis
β β - LLM Integration
βββββββββββββββββββ
- User submits code via React frontend
- React β sends request to Java backend
- Java β validates, processes, routes to Python backend
- Python β performs AI analysis using LLM
- Python β returns results to Java
- Java β enhances response, adds metadata
- Java β returns to React
- React β displays results to user
While a single backend could handle basic functionality, our two-backend approach provides significant advantages for scalability, maintainability, and enterprise readiness:
-
Python Backend: Specializes in AI/ML operations
- Natural choice for AI libraries (Anthropic, OpenAI, TensorFlow)
- Rapid prototyping of ML models
- Easy integration with data science tools
-
Java Backend: Handles enterprise features
- Business logic and validation
- Authentication & authorization (future)
- Database operations (future)
- Complex transaction management
- Python: CPU-intensive AI operations run on optimized infrastructure
- Java: Fast request routing, caching, and I/O operations
- Independent Scaling: Scale each backend based on specific load
- AI processing bottleneck? Scale Python instances
- High user traffic? Scale Java instances
- Right Tool for the Right Job
- Python excels at AI/ML with rich ecosystem
- Java excels at enterprise features with robust frameworks
- API Key Protection: Sensitive AI API keys isolated in Python backend
- Fail-Safe: If AI service fails, Java can return cached results (future feature)
- Parallel Development: Frontend, Java, and Python teams work independently
- Technology Expertise: Developers work in their strongest languages
- Easier Onboarding: New developers focus on one service at a time
The Java middleware enables planned features:
- User authentication & profiles
- Usage analytics & monitoring
- Result caching for faster responses
- Multiple AI provider support (OpenAI, Claude, local models)
- WebSocket support for real-time analysis
- Subscription & payment processing
Current (MVP):
React β Java (simple proxy) β Python (AI processing)
Future (Full Platform):
React β Java β β¬β Python (AI)
ββ PostgreSQL (user data)
ββ Redis (caching)
ββ Elasticsearch (code search)
ββ Kafka (async processing)
Note: Yes, currently Java acts primarily as a proxy, but this foundation enables rapid addition of enterprise features without refactoring the entire architecture.
- β Multi-Language Support: Python, JavaScript, Java, C++, and more
- β AI-Powered Analysis: Detects bugs, security issues, code smells
- β Auto-Fix: Automatically corrects common coding errors
- β Real-time Processing: Fast response times with optimized backends
- β Clean UI: Modern, responsive interface built with React
- β CORS Configured: Secure cross-origin resource sharing
Coming Soon (See Future Roadmap)
- π User authentication & profiles
- π Analysis history & comparison
- π Team collaboration features
- π Custom rule configuration
- π IDE plugins (VS Code, IntelliJ)
- Framework: React 18 with Vite
- Styling: Tailwind CSS
- HTTP Client: Fetch API
- Deployment: Vercel
- Framework: Spring Boot 3.2
- Language: Java 17
- Build Tool: Maven
- Key Dependencies:
- Spring Web (REST APIs)
- Spring Actuator (Health monitoring)
- Lombok (Boilerplate reduction)
- Deployment: Railway
- Framework: FastAPI
- Language: Python 3.11
- Key Dependencies:
openai(LLM integration)pydantic(Data validation)uvicorn(ASGI server)
- Deployment: Railway
- Version Control: Git & GitHub
- CI/CD: Automatic deployment via Railway & Vercel
- Monitoring: Railway logs, Vercel analytics
- Environment Management: Railway/Vercel environment variables
- Node.js 18+ and npm
- Python 3.11+
- Java 17+
- Maven 3.8+
- Git
git clone https://github.com/yourusername/codereviewai.git
cd codereviewaicd python-backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set environment variables
export OPEN_API_KEY=your_api_key_here
# Run the server
uvicorn main:app --reload --port 8000Test Python backend:
curl http://localhost:8000/
# Expected: {"status": "running"}cd java-backend
# Set environment variables (Linux/Mac)
export PYTHON_API_URL=http://localhost:8000
# Or create application-local.properties
cat > src/main/resources/application-local.properties << EOF
python.api.url=http://localhost:8000
cors.allowed.origins=http://localhost:3000
EOF
# Build and run
mvn clean install
mvn spring-boot:runTest Java backend:
curl http://localhost:8080/actuator/health
# Expected: {"status":"UP"}cd react-frontend
# Install dependencies
npm install
# Create environment file
cat > .env.local << EOF
VITE_API_URL=http://localhost:8080
EOF
# Run development server
npm run devAccess the app:
Open browser to http://localhost:5173
- Push to GitHub
- Connect Railway to repository
- Set environment variables:
OPEN_API_KEY=your_key PYTHON_ENV=production - Railway auto-deploys on push
- Push to GitHub
- Connect Railway to repository
- Set environment variables:
PYTHON_API_URL=https://your-python-backend.up.railway.app CORS_ALLOWED_ORIGINS=https://your-frontend.vercel.app JAVA_OPTS=-Xmx512m - Railway auto-deploys on push
- Push to GitHub
- Import project to Vercel
- Set environment variables:
VITE_API_URL=https://your-java-backend.up.railway.app - Vercel auto-deploys on push
Live URLs:
- Frontend:
https://your-app.vercel.app - Java API:
https://java-backend.up.railway.app - Python API:
https://python-backend.up.railway.app
Analyzes code for issues and provides recommendations.
Request:
{
"language": "python",
"code": "print('hello world')!"
}Response:
{
"analysis": "The provided code snippet has a few issues that need to be addressed. Let's analyze it step by step:\n\n### Issues:\n1. **Syntax Error**: The code ends with an exclamation mark (`!`), which is not valid in Python syntax. The correct line should simply be:\n ```python\n print('hello world')\n ```\n\n### Improvements:\n1. **Code Formatting**: While the code is simple, it's always a good practice to follow consistent formatting. For example, if this were part of a larger script, you might want to ensure that the indentation and spacing are consistent throughout the file.\n\n2. **Functionality**: If the intention is to print \"hello world\" to the console, the code does that correctly (minus the syntax error). However, if this is meant to be part of a larger application, consider wrapping it in a function for better reusability:\n ```python\n def greet():\n print('hello world')\n\n greet()\n ```\n\n3. **Documentation**: If this code is part of a larger project, consider adding comments or documentation to explain its purpose, especially if it will be maintained or used by others.\n\n### Design Suggestions:\n1. **Modularity**: If this is part of a larger application, think about how this greeting function could be expanded. For example, you could allow it to accept a name as an argument:\n ```python\n def greet(name='world'):\n print(f'hello {name}')\n\n greet() # Outputs: hello world\n greet('Alice') # Outputs: hello Alice\n ```\n\n2. **Testing**: If this code is part of a larger system, consider writing unit tests to ensure that the `greet` function behaves as expected.\n\n3. **Internationalization**: If you plan to expand this application, consider how you might handle different languages. You could use a library like `gettext` for translations.\n\n### Summary:\nThe primary issue with the provided code is the syntax error due to the extraneous exclamation mark. After fixing that, consider enhancing the code's structure and functionality for better reusability and maintainability."
}Automatically fixes code issues.
Request:
{
"language": "python",
"code": "print('hello world')!"
}
Response:
{
"fixed_code": "```python\nprint('hello world')\n```"
}Core AI analysis endpoint (called by Java backend).
Core AI fix endpoint (called by Java backend).
Health check.
-
User Authentication
- JWT-based authentication
- OAuth2 integration (Google, GitHub)
- User profile management
-
Database Integration
- PostgreSQL for user data
- Analysis history storage
- User preferences
-
Caching Layer
- Redis for frequently analyzed code
- Reduce AI API calls by 60%
- Faster response times
-
Rate Limiting
- Per-user API limits
- Prevent abuse
- Fair usage policies
-
Code Comparison
- Before/after analysis
- Track improvements over time
- Generate reports
-
Multi-Provider Support
- OpenAI GPT-4
- Anthropic Claude
- Local models (CodeLlama)
- Cost optimization by choosing providers
-
Batch Processing
- Analyze entire repositories
- Async processing with Kafka
- Email notifications on completion
-
Custom Rules
- User-defined analysis rules
- Team-specific coding standards
- Rule marketplace
-
Team Collaboration
- Shared analysis workspaces
- Code review workflows
- Team analytics dashboard
-
IDE Integrations
- VS Code extension
- IntelliJ IDEA plugin
- Real-time analysis as you type
-
CI/CD Integration
- GitHub Actions
- GitLab CI
- Jenkins plugin
- Pre-commit hooks
-
Advanced Analytics
- Code quality trends
- Team performance metrics
- Technical debt tracking
- Elasticsearch for code search
-
Context-Aware Analysis
- Multi-file analysis
- Project-wide refactoring suggestions
- Dependency analysis
-
Learning System
- Learn from user feedback
- Improve suggestions over time
- Custom model fine-tuning
-
Security Scanning
- Vulnerability detection
- Dependency security audit
- OWASP compliance checking
-
Subscription Tiers
- Free: 100 analyses/month
- Pro: Unlimited, priority support
- Enterprise: On-premise deployment
-
API Marketplace
- Public API access
- Usage-based pricing
- Developer documentation portal
We welcome contributions! Here's how you can help:
- π Bug fixes
- β¨ New features
- π Documentation improvements
- π¨ UI/UX enhancements
- π§ͺ Test coverage
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Make your changes
- Test thoroughly
# Python tests pytest # Java tests mvn test # Frontend tests npm test
- Commit with conventional commits
git commit -m "feat: add code comparison feature" - Push and create Pull Request
- Python: Follow PEP 8, use
blackformatter - Java: Follow Google Java Style Guide
- JavaScript: Use ESLint + Prettier
- Commits: Follow Conventional Commits
This project is licensed under the MIT License - see the LICENSE file for details.
- Ruwini Tharanga - Initial work - @ruwini01
- Anthropic for Claude AI API
- OpenAI for GPT models
- Railway for seamless backend hosting
- Vercel for lightning-fast frontend deployment
- Spring Boot and FastAPI communities
- Website: https://ruwini-tharanga.vercel.app
- Issues: GitHub Issues
- Email: 12345tharanga12345@gmail.com
If you find this project useful, please consider giving it a star! β
Made with β€οΈ by developers, for developers
Live Demo β’ Report Bug β’ Request Feature