Skip to content

Meenbudha/code-complexity-reviewer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

55 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 CodeMind AI β€” Code Complexity Reviewer

Live Demo GitHub Repo

Python React Node.js MongoDB

Frontend CI Backend CI ML Service CI Deploy to Render Keep Alive

AI-powered code analysis with multi-tier intelligence β€” Gemini β†’ AWS Bedrock β†’ Offline fallback.


🌐 Live Demo

Tip

The app auto-warms all backend services on first load β€” no manual steps needed. Just click and wait ~30s on first visit (Render free tier cold start).


✨ Features

Feature Description
πŸ€– Multi-Tier AI Router Gemini β†’ AWS Bedrock β†’ Offline fallback for 100% uptime
⚑ Request Caching SHA-256 hash lookup in MongoDB β€” cache hits respond in ~5ms
πŸ“Š Complexity Analysis Big-O time & space complexity, warnings, and improvement tips
πŸ’¬ AI Chat Assistant Ask follow-up questions about your code in real time
πŸ”₯ Warmup Screen Auto-pings all services on load β€” no more cold start failures
🦴 Skeleton Loaders Shimmer placeholders while AI analysis runs
πŸ›‘οΈ Robust Error Handling Standardized error responses with graceful degradation
πŸ§ͺ Unit Test Coverage 12 Pytest cases covering all offline analysis branches
πŸ”„ Full CI/CD Pipeline GitHub Actions: test β†’ build β†’ deploy to Render automatically
πŸ“ Keep-Alive Cron Pings all 3 Render services every 10 min β€” prevents cold starts

πŸ—οΈ Architecture

CodeMind AI/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       β”œβ”€β”€ frontend.yml      ← CI: React build check
β”‚       β”œβ”€β”€ backend.yml       ← CI: Node.js syntax check
β”‚       β”œβ”€β”€ ml-service.yml    ← CI: Pytest suite (12 tests)
β”‚       β”œβ”€β”€ deploy.yml        ← CD: Auto-deploy all 3 to Render
β”‚       └── keep-alive.yml    ← Cron: ping services every 10 min
β”œβ”€β”€ frontend/                 ← React 19 + Vanilla CSS dark theme
β”‚   └── src/
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ WarmupScreen.js     # Cold-start handler
β”‚       β”‚   β”œβ”€β”€ CodeEditor.js       # Code input area
β”‚       β”‚   β”œβ”€β”€ ResultPanel.js      # Analysis report
β”‚       β”‚   β”œβ”€β”€ SkeletonLoader.js   # Shimmer placeholders
β”‚       β”‚   β”œβ”€β”€ AiAssistant.js      # Chat interface
β”‚       β”‚   β”œβ”€β”€ ComplexityGraph.js  # Big-O visualizer
β”‚       β”‚   β”œβ”€β”€ Header.js
β”‚       β”‚   └── Sidebar.js          # History panel
β”‚       └── index.css
β”œβ”€β”€ backend/                  ← Node.js/Express β€” API gateway + cache
β”‚   └── server.js             # MD5 cache, MongoDB, proxy to ML service
β”œβ”€β”€ ml-service/               ← Python Flask β€” AI orchestration
β”‚   β”œβ”€β”€ app.py                # 3-tier router + offline engine
β”‚   β”œβ”€β”€ pytest.ini
β”‚   └── tests/
β”‚       └── test_analyze_offline.py
└── README.md

Intelligence Router Flow

User Request
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    βœ… success    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Google     │──────────────►  β”‚   Response   β”‚
β”‚  Gemini     β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚ ❌ timeout / 429
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    βœ… success    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    AWS      │──────────────►  β”‚   Response   β”‚
β”‚  Bedrock    β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
     β”‚ ❌ error
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Offline   │──────────────►  Static heuristic analysis
β”‚  Analyzer   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start (Local)

Prerequisites

  • Node.js v18+
  • Python 3.10+
  • MongoDB (local or Atlas)
  • Git

1. Clone the Repository

git clone https://github.com/Meenbudha/code-complexity-reviewer.git
cd code-complexity-reviewer

2. Set Up the Backend (Node.js)

cd backend
npm install

Create backend/.env:

PORT=5000
MONGO_URL=mongodb://localhost:27017/codemind
ML_SERVICE_URL=http://localhost:8000
node server.js

3. Set Up the ML Service (Python Flask)

cd ml-service
python -m venv venv

# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate

pip install -r requirements.txt

Create ml-service/.env:

GEMINI_API_KEY=your_gemini_api_key_here
AWS_ACCESS_KEY_ID=your_aws_access_key
AWS_SECRET_ACCESS_KEY=your_aws_secret_key
AWS_REGION=us-east-1
python app.py

4. Set Up the Frontend (React)

cd frontend
npm install --legacy-peer-deps

Create frontend/.env:

REACT_APP_BACKEND_URL=http://localhost:5000
REACT_APP_ML_URL=http://localhost:8000
npm start

Open http://localhost:3000 in your browser.


πŸ§ͺ Running Tests

cd ml-service
python -m pytest tests/ -v

Expected output: 12 passed covering O(1), O(n), O(nΒ²), O(log n), O(n log n), O(2^n), recursion, hashmap, string concat, deep nesting, Java syntax.


☁️ Deployment on Render

All 3 services are deployed on Render free tier.

Service Render Config
Frontend Root: frontend Β· Build: npm install --legacy-peer-deps && npm run build Β· Publish: build/
Backend Root: backend Β· Build: npm install Β· Start: node server.js
ML Service Root: ml-service Β· Build: pip install -r requirements.txt Β· Start: gunicorn app:app --workers 2 --timeout 60 --bind 0.0.0.0:$PORT

Environment Variables on Render

Frontend service:

REACT_APP_BACKEND_URL = https://your-backend.onrender.com
REACT_APP_ML_URL      = https://your-ml-service.onrender.com

Important

REACT_APP_* variables must be set in Render before building. React bakes them into the static bundle at build time β€” they are not runtime variables.

Backend service:

MONGO_URL       = mongodb+srv://... (MongoDB Atlas)
ML_SERVICE_URL  = https://your-ml-service.onrender.com
PORT            = 5000

ML service:

GEMINI_API_KEY       = ...
AWS_ACCESS_KEY_ID    = ...
AWS_SECRET_ACCESS_KEY= ...
AWS_REGION           = us-east-1
FLASK_ENV            = production

πŸ”„ CI/CD Pipeline

Every git push to main triggers a full automated pipeline:

Push to main
     β”‚
     β”œβ”€β”€ βš›οΈ Frontend CI   (npm build)
     β”œβ”€β”€ 🟑 Backend CI    (node --check)
     └── 🐍 ML Service CI (pytest 12 tests)
           β”‚ all pass βœ…
           β–Ό
     β”œβ”€β”€ 🌐 Deploy Frontend β†’ Render
     β”œβ”€β”€ 🟑 Deploy Backend  β†’ Render
     └── πŸ€– Deploy ML       β†’ Render
           β”‚
           β–Ό
     βœ… Deployment Summary printed

Keep-Alive: A separate cron workflow pings all 3 services every 10 minutes to prevent Render free-tier spin-down.

GitHub Secrets Required

Important

All sensitive values must go in the Secrets tab β€” NOT the Variables tab.

Secret Purpose
GEMINI_API_KEY Gemini AI provider
AWS_ACCESS_KEY_ID AWS Bedrock fallback
AWS_SECRET_ACCESS_KEY AWS Bedrock fallback
RENDER_DEPLOY_HOOK_FRONTEND Auto-deploy frontend
RENDER_DEPLOY_HOOK_BACKEND Auto-deploy backend
RENDER_DEPLOY_HOOK_ML Auto-deploy ML service
RENDER_BACKEND_URL Keep-alive ping
RENDER_ML_URL Keep-alive ping

πŸ› οΈ Tech Stack

Layer Technology
Frontend React 19, Vanilla CSS, Custom Dark Theme
Backend Node.js 18, Express 5, Mongoose
ML Service Python 3.10, Flask, Gunicorn
AI β€” Primary Google Gemini 2.0 Flash
AI β€” Fallback AWS Bedrock (Amazon Nova Micro)
AI β€” Offline Custom heuristic regex engine
Database MongoDB Atlas (cache + history)
Testing Pytest (12 offline unit tests)
CI/CD GitHub Actions (4 workflows)
Hosting Render (all 3 services)

πŸ—ΊοΈ Roadmap

  • Deploy all 3 services to Render
  • Full CI/CD pipeline with GitHub Actions
  • Cold start WarmupScreen
  • Keep-alive cron job
  • Unit tests (12 Pytest cases)
  • Add input validation + rate limiting
  • Support more languages (JavaScript, Go, Rust)
  • Dark/Light mode persistence (localStorage)
  • VS Code extension

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Built with ❀️ by Meenbudha

⭐ Star this repo if you find it useful!

πŸ“– Full Architecture Docs β†’

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages