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