How wrathemperor/superdesign-app-compiler works
Purpose and Entry Points
Superdesign is a compiler-style backend that converts a natural-language app request into a validated application blueprint: intent, architecture, database/API/UI/auth schemas, and repairs. The FastAPI service starts at app/main.py; orchestration is centralized in app/pipeline.py. A separate Vite/React viewer renders generated architecture output from frontend/src/main.jsx and frontend/src/App.jsx.
Request and Pipeline Boundary
The backend accepts a generation request, converts it into typed Pydantic contracts, and returns a complete executable configuration. Shared intermediate and final blueprint types define the stage boundary in app/models/schemas.py. app/pipeline.py owns ordered execution, parallel schema generation, validation, and retry/repair convergence rather than exposing stages as independent services.
1. Intent Extraction
app/stages/intent.py transforms free-form requirements into a structured intermediate representation: inferred product scope, actors, capabilities, and constraints. This is the first LLM-facing normalization boundary; downstream stages consume typed intent rather than raw user text. Its output is enforced through app/models/schemas.py.
2. System Design
app/stages/design.py converts intent into the high-level application design: domain entities, user flows, and role/permission concepts. This stage bridges business requirements and implementation schemas, giving subsequent generators a common architectural source of truth. It exchanges validated objects defined in app/models/schemas.py.
3. Parallel Schema Compilation
app/stages/schema.py compiles the design into coordinated DB, API, UI, and authentication configurations. These schemas are intended as generation-ready targets for SQL migrations, OpenAPI-like APIs, frontend component/routing trees, and authorization middleware. The pipeline in app/pipeline.py can run schema work concurrently to reduce latency while preserving a single assembled blueprint.
4. Cross-Layer Validation
app/stages/validate.py checks structural Pydantic validity and semantic consistency across layers—for example, API fields and endpoints against data entities, or authorization rules against roles and UI pages. This is the primary quality gate between probabilistic LLM output and the externally returned configuration. Validation contracts and error representations reside in app/models/schemas.py.
5. Targeted Repair Loop
app/stages/repair.py receives validation failures and fixes only the affected configuration segment rather than regenerating the entire blueprint. app/pipeline.py revalidates repaired output until it converges or reaches its control limit. This isolates LLM nondeterminism and token cost to invalid artifacts while retaining valid earlier-stage output.
LLM and Runtime Infrastructure
The Python 3.10+ backend uses FastAPI/Uvicorn (app/main.py) and Pydantic models (app/models/schemas.py). LLM invocation, JSON cleanup, constrained structured-output handling, and local mock behavior are encapsulated in app/utils/llm.py. Production generation targets Gemini 2.0 Flash via GEMINI_API_KEY; MOCK_LLM=true provides local, quota-free deterministic demonstration behavior. Container deployment is supported by Dockerfile and Google Cloud-oriented ignore rules.
Presentation and Evaluation
The React/Vite frontend is a visualization client, not the compiler runtime; its architecture preview is implemented in frontend/src/components/ArchitecturePreview.jsx. Evaluation executes the same pipeline over a benchmark suite through app/eval/evaluate.py and app/eval/suite.py, with persisted results in data/eval_results.json.
Main entry points: schema.py Schema compilation · pipeline.py Blueprint pipeline · validate.py Cross-layer validation · llm.py LLM runtime
Components 19
Compiler Backend
FastAPI service and blueprint compiler pipeline.
- FastAPI service
app/main.py - Blueprint pipeline · Coordinates generation, parallel compilation, validation, and repair retries.
app/pipeline.py - Blueprint contracts · Typed intermediate, final, validation, and error contracts.
app/models/schemas.py - LLM runtime · Handles structured output, cleanup, and deterministic mock behavior.
app/utils/llm.py
Compilation Stages
Ordered LLM-assisted transformation and quality stages.
- Intent extraction · Converts free-form requests into typed scope, actors, capabilities, and constraints.
app/stages/intent.py - System design · Produces entities, flows, and roles from validated intent.
app/stages/design.py - Schema compilation · Builds coordinated database, API, UI, and auth configurations.
app/stages/schema.py - Database schema
- API schema
- UI schema
- Auth schema
- Cross-layer validation · Checks structural validity and consistency across compiled layers.
app/stages/validate.py - Targeted repair · Fixes only configuration segments identified by validation failures.
app/stages/repair.py
Viewer and Evaluation
Separate visualization client and benchmark runner.
- Viewer entry
frontend/src/main.jsx - Architecture viewer · Renders generated architecture output; not part of compiler runtime.
frontend/src/App.jsx - Architecture preview
frontend/src/components/ArchitecturePreview.jsx - Benchmark evaluation · Runs the same pipeline over the benchmark suite.
app/eval/evaluate.py - Benchmark suite
app/eval/suite.py - Evaluation results
data/eval_results.json
Connections 22
- FastAPI service → Blueprint pipeline: generation request
- Blueprint pipeline → Intent extraction: raw request
- Intent extraction → System design: typed intent
- System design → Schema compilation: application design
- Schema compilation → Database schema: compile
- Schema compilation → API schema: compile
- Schema compilation → UI schema: compile
- Schema compilation → Auth schema: compile
- Schema compilation → Cross-layer validation: assembled blueprint
- Cross-layer validation → Blueprint pipeline: validated blueprint
- Cross-layer validation → Targeted repair: validation failures
- Targeted repair → Cross-layer validation: patched segment
- Blueprint pipeline → Blueprint contracts: validates stage boundaries
- Intent extraction → LLM runtime: structured generation
- System design → LLM runtime: structured generation
- Schema compilation → LLM runtime: parallel generation
- Targeted repair → LLM runtime: targeted correction
- Viewer entry → Architecture viewer: mounts
- Architecture viewer → Architecture preview: renders
- Benchmark evaluation → Benchmark suite: loads cases
- Benchmark evaluation → Blueprint pipeline: executes
- Benchmark evaluation → Evaluation results: persists