Skip to content

Repository files navigation

Software Generation Compiler

A multi-stage pipeline that converts natural language into structured, validated, executable application configurations.

Architecture Overview

User Input (Natural Language)
         │
         ▼
┌─────────────────────────────────────────────────────────────┐
│                    PIPELINE STAGES                           │
├─────────────────────────────────────────────────────────────┤
│  1. INTENT EXTRACTION                                       │
│     - Parse entities, roles, features from text             │
│     - Handle vague/underspecified inputs                    │
│     - Make assumptions and document them                    │
│     └─────────────────┬───────────────────────────────────┘
│                       ▼                                      │
│  2. SYSTEM DESIGN                                           │
│     - Determine app type (CRM, CMS, Ecommerce, etc)        │
│     - Design entity relationships                           │
│     - Plan security architecture                             │
│     - Detect third-party integrations                       │
│     └─────────────────┬───────────────────────────────────┘
│                       ▼                                      │
│  3. SCHEMA GENERATION                                       │
│     - Generate UI schema (pages, components)               │
│     - Generate API schema (endpoints, methods)              │
│     - Generate DB schema (tables, columns, relations)        │
│     - Generate Auth rules (roles, permissions)             │
│     └─────────────────┬───────────────────────────────────┘
│                       ▼                                      │
│  4. VALIDATION + REPAIR ENGINE                              │
│     - Cross-layer consistency checks                        │
│     - Schema validation against contracts                   │
│     - Automatic repair of missing/invalid parts           │
│     └─────────────────┬───────────────────────────────────┘
│                       ▼                                      │
│  5. EXECUTION RUNTIME                                       │
│     - Execute generated schemas                             │
│     - Validate API-DB-UI consistency                         │
│     - Simulate API calls to verify correctness              │
└─────────────────────────────────────────────────────────────┘

Pipeline Components

1. Intent Extractor (pipeline/intent_extractor.py)

  • Input: Natural language prompt
  • Output: Structured intent with entities, roles, features, flows
  • Handles: Vague prompts by making assumptions
  • Key Methods:
    • _extract_entities() - Find business objects (contacts, users, etc)
    • _extract_roles() - Identify user types (admin, user, guest)
    • _extract_features() - Determine required functionality

2. System Designer (pipeline/system_designer.py)

  • Input: Intent dictionary
  • Output: Architecture design with stack, relations, security
  • Key Methods:
    • _detect_app_type() - CRM, CMS, Ecommerce, SaaS
    • _design_entities() - Add relations, indexes
    • _detect_integrations() - Stripe, SendGrid, Auth0

3. Schema Generator (pipeline/schema_generator.py)

  • Input: Intent + Design
  • Output: UI, API, DB, Auth schemas
  • Key Methods:
    • _generate_ui() - Pages, routes, components
    • _generate_api() - REST endpoints with validation
    • _generate_db() - SQL tables with proper types

4. Validator + Refinement Engine (pipeline/validator.py)

  • Purpose: Ensure consistency across all layers
  • Validation Checks:
    • All entities have required fields
    • API endpoints reference existing DB tables
    • UI components map to defined entities
    • No circular dependencies
  • Repair: Auto-fills missing defaults (e.g., timestamps, access rules)

5. Minimal Runtime (runtime/minimal_runtime.py)

  • Purpose: Execute/validate generated schemas
  • Methods:
    • execute_schema() - Simulate schema creation
    • validate_endpoints() - Check API-DB consistency
    • simulate_api_call() - Test endpoint behavior

Key Design Decisions

1. Deterministic Behavior

  • Uses structured keyword matching, not LLM generation
  • Same input → consistent output
  • Trades flexibility for reliability

2. Validation-First Approach

  • Every schema validated against JSON Schema contracts
  • Cross-layer checks prevent inconsistencies
  • Repair engine fixes issues automatically

3. Assumption Documentation

  • All assumptions explicitly tracked in intent.assumptions
  • User can review what was assumed
  • Enables informed debugging

4. Failure Handling

  • Vague prompts → add default entities/features
  • Missing data → use sensible defaults
  • Invalid combinations → repair to valid state

Evaluation Metrics

Metric Value
Success Rate 100% (20/20 prompts)
Avg Latency < 10ms
Avg Entities Generated 1.4
Avg Pages Generated 4.9
Avg Endpoints Generated 10.2

Example Prompts

Real Product Prompts

  1. "Build a CRM with login, contacts, dashboard, role-based access, and premium plan with payments. Admins can see analytics."
  2. "Create an ecommerce store with products, cart, checkout, and order management"
  3. "Build a blog with articles, categories, comments, and user authentication"

Edge Cases

  1. "Build something"
  2. "Create an application"
  3. "Full featured app with everything"

Cost vs Quality Tradeoff

Approach Cost Quality Latency
Single LLM Call Low Variable ~1-2s
Our Pipeline Low Consistent <10ms
Multi-Agent High High >5s

Tradeoff: We sacrifice flexibility for deterministic, fast output with guaranteed validity.

Running the System

cd /home/acer_/compiler-gen

# Install dependencies
pip install flask jsonschema

# Run evaluation
python3 evaluator.py

# Start API server
python3 api.py

# Test single prompt
python3 -c "
from pipeline.main import Pipeline
p = Pipeline()
output, valid = p.run('Build a CRM with login, contacts')
print('Valid:', valid)
"

File Structure

compiler-gen/
├── pipeline/
│   ├── __init__.py
│   ├── intent_extractor.py    # Stage 1
│   ├── system_designer.py     # Stage 2
│   ├── schema_generator.py    # Stage 3
│   ├── validator.py           # Stage 4 (validation + repair)
│   └── main.py                # Orchestrator
├── runtime/
│   ├── __init__.py
│   └── minimal_runtime.py     # Stage 5 (execution)
├── schemas/
│   ├── intent_schema.json
│   ├── ui_schema.json
│   ├── api_schema.json
│   └── db_schema.json
├── evaluator.py               # Evaluation framework
├── api.py                      # Flask API
├── index.html                  # Demo UI
└── requirements.txt

Limitations & Future Work

  1. No LLM Integration: Could enhance intent extraction and schema generation
  2. Limited Entity Types: Only 17 predefined entity types
  3. No Visual Builder: Could generate actual UI code
  4. Single Tenant: Doesn't support multi-tenant architectures

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages