Transform messy code into production-ready masterpieces with context-aware AI refactoring
Try Live Demo • Install VS Code Extension • API Docs • Architecture
Install Synapse directly in your editor:
# Search "Synapse" in VS Code Extensions
# OR visit: https://marketplace.visualstudio.com/items?itemName=synapseai.synapse-refactor- Download synapse-refactor-0.1.0.vsix
- In VS Code:
Ctrl+Shift+X→...menu → "Install from VSIX..." - Select the downloaded file
- Use: Select code → Press
Ctrl+Shift+R
Features:
- ⚡ Instant refactoring (
Ctrl+Shift+R) - 🔍 Real-time smell detection
- 📊 Complexity metrics
- 🎨 Side-by-side diff preview
⚠️ Risk scoring- 🌐 Powered by the same API as our web app
Synapse is an intelligent code refactoring engine that learns from your repository's patterns and coding style to provide context-aware, production-safe refactoring suggestions. Unlike generic AI tools, Synapse understands your codebase's unique DNA.
- Pattern Learning: Analyzes your existing codebase to understand coding conventions
- Style Enforcement: Automatically matches indentation, naming, and structure
- Context Understanding: Adapts suggestions based on file type and project architecture
- 40+ Rule-Based Detections: Fast, deterministic smell detection
- AI-Powered Deep Analysis: Context-aware refactoring powered by OpenRouter/Gemini
- Hybrid Approach: Combines rule-based and AI analysis for maximum accuracy
- Code Health Score: Visual before/after quality metrics (A-D grading)
- Risk-Aware Refactoring: Every change tagged with risk level (Low/Medium/High)
- GitHub-Style Diffs: Side-by-side comparison with syntax highlighting
- One-Click Safe Apply: Automatically filters and applies low-risk changes
- Why It Changed: Each refactor includes detailed explanations
- Smell Identification: Clear description of detected anti-patterns
- Impact Metrics: Shows complexity reduction, time savings, code lines saved
- User Feedback: Thumbs up/down on suggestions
- Pattern Memory: Remembers rejected/accepted patterns
- Adaptive Suggestions: Continuously improves based on preferences
Try it now: synapserefactor.vercel.app
Sample Workflow:
- Paste code or GitHub URL
- Select optimization mode (Clean Code, Performance, Security, Readability)
- Choose language (Auto-detect, JavaScript, React, Python, Java)
- Click "ANALYZE & REFACTOR"
- View stunning results with metrics & diff
| Feature | Synapse | ChatGPT | SonarQube |
|---|---|---|---|
| Context-Aware | ✅ Learns from your repo | ❌ Generic | |
| Multi-Language | ✅ JS, React, Python, Java | ✅ Yes | |
| Risk Assessment | ✅ Low/Medium/High tags | ❌ No | ❌ No |
| Explainability | ✅ Detailed "why" | ❌ No | |
| GitHub Integration | ✅ Direct repo analysis | ❌ No | ✅ Plugin |
| Real-Time Diff | ✅ Side-by-side | ❌ No | |
| Feedback Loop | ✅ Learning from usage | ❌ No | ❌ No |
- React 18 + Vite - Lightning-fast development
- Monaco Editor - Professional code editing
- Lucide React - Beautiful icons
- Custom CSS - Premium dark mode UI
- Node.js + Express - Robust API server
- Modular Pipeline - Extensible architecture
- OpenRouter/Gemini - Multi-model AI support
- PostgreSQL + SQLite - Dual persistence strategy
- Frontend: Vercel (CDN, auto-deploy)
- Backend: Render (auto-scale, always-on)
- Database: Supabase (managed PostgreSQL)
┌─────────────────────────────────────────────────────────────┐
│ User Request │
│ (Code/URL + Language + Preferences) │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Language Adapter Factory │
│ ┌──────────┬──────────┬──────────┬──────────┐ │
│ │ JS/React │ Python │ Java │ Auto │ │
│ └──────────┴──────────┴──────────┴──────────┘ │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Static Smell Analyzer (Fast) │
│ • 40+ Rule-Based Checks │
│ • Language-Agnostic + Language-Specific │
│ • O(n) Complexity │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Prompt Builder │
│ • Dynamic JSON Schema │
│ • Language Constraints │
│ • Context Injection │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ AI Client │
│ • OpenRouter (multi-model) │
│ • Gemini (fast, free tier) │
│ • Fallback to Simulation Mode │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Post Processor & Validator │
│ • JSON Parsing │
│ • Safety Validation │
│ • Error Recovery │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Refactor Repository │
│ • SQLite (anonymous users) │
│ • PostgreSQL (authenticated users) │
│ • Dual Persistence │
└────────────────────┬────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Frontend Display │
│ • Code Health Score │
│ • Metrics Dashboard │
│ • Diff Viewer │
│ • Feedback Loop │
└─────────────────────────────────────────────────────────────┘
- Node.js 18+
- Git
- (Optional) PostgreSQL database
git clone https://github.com/ramanuj077/Synapse.git
cd Synapse# Frontend
npm install
# Backend
cd backend
npm installCreate backend/.env:
# AI API (Choose one)
OPENROUTER_API_KEY=sk-or-v1-xxxxx
# OR
GEMINI_API_KEY=xxxxx
# Database (Optional - SQLite used by default)
DATABASE_URL=postgresql://user:pass@host:5432/db
# Security
JWT_SECRET=your-secret-key
NODE_ENV=development# Terminal 1: Frontend
npm run dev
# Terminal 2: Backend
cd backend
npm run devhttp://localhost:5173
POST /api/analyze
Content-Type: application/json
{
"code": "function calculateTotal(items) { ... }",
"language": "javascript",
"refactorType": "clean-code"
}Response:
{
"id": "1735123456789",
"refactored_code": "const calculateTotal = (items) => { ... }",
"smell_detected": "var usage detected (ES6+ uses const/let)",
"explanation": "Refactored to modern ES6+ syntax...",
"metrics": {
"complexity_before": 5,
"complexity_after": 2,
"time_complexity_before": "O(n²)",
"time_complexity_after": "O(n)",
"risk_score": 2,
"lines_saved": 3
}
}POST /api/repo/analyze
Content-Type: application/json
{
"repoUrl": "https://github.com/facebook/react"
}- Modular pipeline architecture
- Language adapters (JS, React, Python, Java)
- Rule-based smell detection
- AI integration (OpenRouter/Gemini)
- Dual persistence (PostgreSQL + SQLite)
- GitHub repository analysis
- Interactive diff viewer
- Code health scoring
- Risk-aware refactoring
- Feedback loop UI
- VS Code extension
- IntelliJ plugin
- Pre-commit hooks
- Team dashboards
- Custom rule definitions
- Natural language refactoring ("make this safer")
- Multi-file dependency analysis
- Performance benchmarking
- Auto-generated documentation
We welcome contributions! See CONTRIBUTING.md for guidelines.
MIT License - see LICENSE for details.
If Synapse helps you write better code, give us a star! ⭐
Built with ❤️ for developers who care about code quality