SmartDoctor Self-Healing Engine
SmartDoctor is Autoflowly's automatic code repair system. It detects and fixes issues in generated MVPs — from Python syntax errors to broken JSX components — without manual intervention.
Overview
SmartDoctor runs automatically during MVP generation and is available on-demand via the Diagnose and Fix buttons in the editor.
How It Works
Detect → Fix → Verify → Repeat (up to 3 rounds)
- Detect — All 10 fixers scan the codebase for issues
- Fix — Each fixer applies targeted repairs to affected files
- Verify — Build validation confirms the fix worked
- Repeat — If issues remain, run another round (max 3 passes)
The 10 Fixers
SmartDoctor includes 10 pluggable fixers, each responsible for a specific category of issues:
| Priority | Fixer | What It Fixes |
|---|---|---|
| 10 | PythonSyntaxFixer | compile() errors, missing commas, syntax issues in .py files |
| 20 | DependencyFixer | Missing packages in requirements.txt and package.json |
| 30 | ConfigScaffoldFixer | Missing or broken next.config.js, tsconfig.json, tailwind.config |
| 40 | TSXSanitizer | Template placeholder markers ({{ var_name }}), malformed JSX attributes |
| 45 | JSXTagFixer | Unclosed HTML/JSX tags (<div> without </div>) — build-breaking |
| 50 | ImportResolutionFixer | Broken import paths, missing local modules |
| 60 | EntryPointFixer | Missing main.py, App.tsx, index.html, or layout.tsx |
| 70 | TailwindFixer | Broken Tailwind class syntax like "sm": "text"-5xl |
| 80 | TypeScriptAIFixer | Complex TypeScript errors that need AI-assisted repair |
| 90 | BuildErrorFixer | Catch-all for errors found during actual build validation |
Fixers run in priority order — critical issues (syntax, dependencies) are fixed first.
Using SmartDoctor
In the Editor
- Open your MVP in the editor
- Click "Diagnose" — SmartDoctor scans all files and reports issues
- Review the diagnostic report (severity, affected files, descriptions)
- Click "Fix All" — SmartDoctor applies all auto-fixable repairs
- The MVP is automatically redeployed with fixes applied
Diagnostic Report
The diagnose endpoint returns a structured report:
{
"health_score": 85,
"status": "needs_attention",
"issues": [
{
"id": "jsx_unclosed_tag_Dashboard.tsx",
"severity": "critical",
"category": "syntax",
"title": "Unclosed JSX Tag",
"description": "Dashboard.tsx has unclosed <div> tags that will break the build",
"affected_files": ["frontend/src/app/dashboard/page.tsx"],
"auto_fixable": true
}
],
"summary": "⚠️ Found 1 critical issue that can be fixed with one click."
}
Severity Levels
| Level | Meaning | Impact |
|---|---|---|
| critical | Build-breaking | MVP won't compile or start |
| error | Functional issue | Feature doesn't work correctly |
| warning | Quality issue | App works but has problems |
| info | Suggestion | Improvement opportunity |
Python Comma Fixer
A common AI-generation artifact is missing commas in Python dictionaries and lists:
# Before (broken)
config = {
"key1": "value1" # ← missing comma
"key2": "value2" # ← missing comma
"key3": "value3"
}
# After (fixed)
config = {
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
SmartDoctor's PythonSyntaxFixer detects "Perhaps you forgot a comma?" errors and iteratively adds missing commas until the file compiles clean.
JSX Tag Fixer
AI-generated React components sometimes have unclosed tags:
// Before (broken - missing closing tags)
<div className="container">
<h1>Dashboard</h1>
<div className="grid">
<Card title="Revenue" />
// After (fixed)
<div className="container">
<h1>Dashboard</h1>
<div className="grid">
<Card title="Revenue" />
</div>
</div>
The JSXTagFixer counts opening and closing tags and appends the missing ones.
API Endpoints
Diagnose
POST /api/conversational-mvp/editor/doctor/diagnose
Content-Type: application/json
{
"session_id": "your-session-id",
"mvp_id": "your-mvp-id"
}
Fix All
POST /api/conversational-mvp/editor/doctor/fix
Content-Type: application/json
{
"session_id": "your-session-id",
"mvp_id": "your-mvp-id",
"auto_redeploy": true,
"create_snapshot": true
}
The fix endpoint creates a snapshot before applying changes, so you can always roll back.
Automatic Healing
SmartDoctor also runs automatically:
- During generation — after AI produces files, before deployment
- On redeploy — when you push changes from the editor
- On demand — via the Diagnose/Fix buttons
This multi-layered approach ensures MVPs are always in a deployable state.