Skip to content

vinayboggula/CodeInsights-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

29 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ CodeInsights AI โ€“ Detailed Project Documentation

๐Ÿง  1. Project Overview

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

๐ŸŽฏ 2. Problem Statement

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

๐Ÿ’ก 3. Solution

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.


๐Ÿ—๏ธ 4. System Architecture

Frontend (React)
   โ†“
Node.js Backend (API layer)
   โ†“
Python AI Service (Analysis engine)
   โ†“
PostgreSQL Database

๐Ÿ”น 5. Frontend (React)

Responsibilities:

  • Code editor input
  • Display optimized code
  • Show metrics and charts
  • User authentication (JWT)
  • Dashboard (accuracy tracking)

Key Features:

  • Monaco Editor for code input
  • Recharts for visualization
  • Axios with interceptors for API calls
  • Context API for global state (user, token)

๐Ÿ”น 6. Backend (Node.js + Express)

Responsibilities:

  • API handling
  • Authentication (JWT)
  • Database interaction
  • Communication with Python service

Key Modules:

1. Review System

  • Accepts user code
  • Sends to Python service
  • Stores results in DB

2. Authentication

  • Signup/Login using bcrypt + JWT
  • Middleware for route protection

3. Dashboard System

  • Calculates:

    • average accuracy
    • best score
    • review history

๐Ÿ”น 7. Python AI Service

This is the core intelligence layer.

Components:

1. LLM Optimization

  • Uses Groq API

  • Generates:

    • optimized code
    • explanation
    • improvement points

2. Metrics Engine

  • LOC
  • Cyclomatic complexity (Radon)
  • Nesting depth (AST)
  • Maintainability score
  • Time & space complexity (heuristics)

3. Comparison Engine

  • Compares original vs optimized code

  • Generates:

    • summary
    • verdict
    • accuracy score

๐Ÿ“Š 8. Accuracy Scoring System (Key Innovation)

Purpose:

To quantify how much the code improved.

Logic:

  • Base score = 50

  • Add points for:

    • improved maintainability
    • reduced complexity
    • reduced nesting
    • reduced code smells
  • Penalize regressions

Special Cases:

  • Same code โ†’ 100
  • Same logic โ†’ ~90
  • Syntax fix โ†’ ~95

๐Ÿ‘‰ This makes the system interactive and gamified


๐Ÿ—„๏ธ 9. Database Design (PostgreSQL)

Reviews Table:

  • original_code
  • optimized_code
  • original_metrics (JSON)
  • optimized_metrics (JSON)
  • improvement_summary (JSON)
  • accuracy_score (INTEGER)

Users Table:

  • id
  • name
  • email
  • password (hashed)
  • provider

๐Ÿ” 10. Authentication System

Manual Auth:

  • Password hashing using bcrypt
  • JWT token generation
  • Middleware for protected routes

Flow:

  1. User logs in
  2. Token stored in frontend
  3. Axios interceptor attaches token
  4. Backend verifies token

๐Ÿ“ˆ 11. Dashboard System

Displays:

  • Average accuracy
  • Best score
  • History of reviews

๐Ÿ‘‰ Helps users track improvement over time


โš™๏ธ 12. API Flow

User submits code
   โ†“
Frontend โ†’ /code/analyze
   โ†“
Backend โ†’ Python service
   โ†“
AI + Metrics + Comparison
   โ†“
Backend stores result
   โ†“
Response sent to frontend

๐Ÿงช 13. Example Use Case

Input:

print("hello")

Output:

  • Optimized code (structured version)
  • Metrics comparison
  • Summary
  • Accuracy score (~90 if same logic)

๐Ÿš€ 14. Key Features Summary

  • AI-powered code improvement
  • Real-time metrics analysis
  • Visual comparison dashboard
  • Accuracy scoring system
  • JWT authentication
  • Full-stack architecture

๐Ÿง  15. Challenges Faced

  1. Comparing code correctness

    • Solved using metric-based logic instead of strict AST
  2. Handling invalid code

    • Used AST parsing with fallback logic
  3. LLM JSON parsing issues

    • Implemented safe JSON extraction
  4. Token-based authentication issues

    • Solved using Axios interceptors

๐ŸŒŸ 16. Unique Selling Points

  • Combines AI + static analysis
  • Accuracy scoring system (gamification)
  • Full-stack + microservice architecture
  • Real-world engineering practices

๐Ÿ”ฎ 17. Future Improvements

  • Multi-language support
  • Better complexity detection
  • Code execution sandbox
  • Team collaboration
  • Leaderboards & streaks

๐ŸŽค 18. Conclusion

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.


About

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.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors