Created: (2026-03-21)
Latest update: (2026-07-22) — RefactorAI Gen-2 full-stack product metadata (FastAPI + React + Docker + Ollama/Groq)
AI-Powered Code Refactoring & Optimization Assistant (Python-first).
- Upload a Python
.pyfile (drag & drop or file picker, ~2MB max) - Analyze:
- Per-block explanations (module/function/class/main)
- Anti-patterns + suggestions
- Security issues (LLM + Bandit)
- Quality score (0–100)
- Generate optimized version:
- Cleaner, faster, PEP8-oriented refactor with type hints
- Beautiful dark-first UI:
- Side-by-side Monaco editors + highlighted diff
- Download + copy-to-clipboard
- Backend: FastAPI (async), Pydantic v2, Instructor, LiteLLM, ruff + bandit (subprocess),
astparsing - Frontend: Vite + React 19 + TypeScript (strict), Tailwind + shadcn-style UI primitives, Zustand, TanStack Query, Axios, Monaco editor, diff2html, Sonner toasts
- Production: backend serves
/frontend/distat/
Copy .env.example to .env and choose your mode:
- Local (offline, default): Ollama on your machine
- Cloud (Groq): Groq API key
-
Install Ollama: see the Ollama installation docs.
-
Start Ollama (defaults to
http://localhost:11434):
ollama serve- Pull the default model:
ollama pull qwen2.5-coder:7b- Set
.env:
REFACTORAI_MODE=localOLLAMA_BASE_URL=http://localhost:11434LOCAL_MODEL=ollama/qwen2.5-coder:7b
Recommended:
qwen2.5-coder:7bon 16GB RAM laptops. Use larger variants (e.g.qwen2.5-coder:14b) only on machines with more memory.
Set .env:
REFACTORAI_MODE=cloudGROQ_API_KEY=...CLOUD_MODEL=groq/llama-3.1-8b-instant
docker compose up --build backendOpen the app at http://localhost:8000.
Backend:
cd backend
python3.12 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000Frontend:
cd frontend
npm install
npm run devThe Vite dev server proxies API requests to http://localhost:8000.
POST /api/analyze(multipart form fieldfile) →AnalysisResponsePOST /api/refactor(multipart form fieldfile) →RefactoredResponse