CodeInsights AI is a full-stack web application that analyzes user-submitted code and provides AI-powered optimization suggestions along with detailed code quality metrics and performance insights.
The goal of this project is to help developers:
- Improve code quality
- Understand performance implications
- Learn best coding practices interactively
Most beginners write code that works but is:
- inefficient
- hard to maintain
- poorly structured
Existing tools:
- focus only on syntax errors OR
- provide static analysis without explanation
๐ There is no unified system that:
- explains improvements
- compares before vs after
- tracks user progress
I built CodeInsights AI, which combines:
- AI-based code optimization
- Static code analysis
- Performance metrics
- User accuracy tracking
This creates a learning + evaluation system, not just a tool.
Frontend (React)
โ
Node.js Backend (API layer)
โ
Python AI Service (Analysis engine)
โ
PostgreSQL Database
- Code editor input
- Display optimized code
- Show metrics and charts
- User authentication (JWT)
- Dashboard (accuracy tracking)
- Monaco Editor for code input
- Recharts for visualization
- Axios with interceptors for API calls
- Context API for global state (user, token)
- API handling
- Authentication (JWT)
- Database interaction
- Communication with Python service
- Accepts user code
- Sends to Python service
- Stores results in DB
- Signup/Login using bcrypt + JWT
- Middleware for route protection
-
Calculates:
- average accuracy
- best score
- review history
This is the core intelligence layer.
-
Uses Groq API
-
Generates:
- optimized code
- explanation
- improvement points
- LOC
- Cyclomatic complexity (Radon)
- Nesting depth (AST)
- Maintainability score
- Time & space complexity (heuristics)
-
Compares original vs optimized code
-
Generates:
- summary
- verdict
- accuracy score
To quantify how much the code improved.
-
Base score = 50
-
Add points for:
- improved maintainability
- reduced complexity
- reduced nesting
- reduced code smells
-
Penalize regressions
- Same code โ 100
- Same logic โ ~90
- Syntax fix โ ~95
๐ This makes the system interactive and gamified
- original_code
- optimized_code
- original_metrics (JSON)
- optimized_metrics (JSON)
- improvement_summary (JSON)
- accuracy_score (INTEGER)
- id
- name
- password (hashed)
- provider
- Password hashing using bcrypt
- JWT token generation
- Middleware for protected routes
- User logs in
- Token stored in frontend
- Axios interceptor attaches token
- Backend verifies token
Displays:
- Average accuracy
- Best score
- History of reviews
๐ Helps users track improvement over time
User submits code
โ
Frontend โ /code/analyze
โ
Backend โ Python service
โ
AI + Metrics + Comparison
โ
Backend stores result
โ
Response sent to frontend
Input:
print("hello")Output:
- Optimized code (structured version)
- Metrics comparison
- Summary
- Accuracy score (~90 if same logic)
- AI-powered code improvement
- Real-time metrics analysis
- Visual comparison dashboard
- Accuracy scoring system
- JWT authentication
- Full-stack architecture
-
Comparing code correctness
- Solved using metric-based logic instead of strict AST
-
Handling invalid code
- Used AST parsing with fallback logic
-
LLM JSON parsing issues
- Implemented safe JSON extraction
-
Token-based authentication issues
- Solved using Axios interceptors
- Combines AI + static analysis
- Accuracy scoring system (gamification)
- Full-stack + microservice architecture
- Real-world engineering practices
- Multi-language support
- Better complexity detection
- Code execution sandbox
- Team collaboration
- Leaderboards & streaks
CodeInsights AI is not just a code optimizer but a learning platform that helps developers understand and improve their coding practices using AI and data-driven insights.