# Example Regeneration Plan - Dogfooding ggen

## Goal
Demonstrate ggen's capabilities by using ggen itself to generate all examples.

## Current State
- ✅ Directory structure created
- ❌ Examples manually scaffolded (NOT dogfooding)
- ❌ Not using ggen's AI commands
- ❌ Not using ggen's template system
- ❌ Not using ggen's marketplace

## Dogfooding Strategy

### Step 1: Clean Slate
```bash
# Remove manually created examples
rm -rf examples/advanced-cli-tool
rm -rf examples/perf-library
rm -rf examples/async-web-service
rm -rf examples/wasm-crypto
rm -rf examples/embedded-iot

# Keep only the workspace orchestrator
```

### Step 2: Regenerate Using ggen AI Commands

#### 2.1 CLI Tool (Use ggen ai project)
```bash
ggen ai project \
  --description "Advanced CLI tool for file processing with async I/O, multiple subcommands, and comprehensive error handling" \
  --name "advanced-cli-tool" \
  --language rust \
  --output examples/advanced-cli-tool \
  --tests \
  --docs \
  --ci

# Then add lifecycle
cd examples/advanced-cli-tool
ggen lifecycle init
ggen lifecycle add-phase build "cargo build --release"
ggen lifecycle add-phase test "cargo test --all-features"
ggen lifecycle add-hook before-build "cargo fmt -- --check"
```

#### 2.2 Performance Library (Use ggen ai generate)
```bash
# Generate library structure
ggen ai generate \
  --description "High-performance Rust library with custom hash table, concurrent data structures, and comprehensive benchmarks" \
  --examples "ahash for fast hashing" "rayon for parallelism" "criterion for benchmarks" \
  --output examples/perf-library/src/lib.rs \
  --validate

# Generate benchmark configuration
ggen ai generate \
  --description "Criterion benchmark suite comparing custom implementations against stdlib" \
  --output examples/perf-library/benches/performance.rs
```

#### 2.3 Web Service (Use ggen ai project + graph)
```bash
# Generate from architecture graph
cat > architecture.ttl <<EOF
@prefix api: <http://example.org/api#> .

<#WebService> a api:RestAPI ;
    api:hasEndpoint <#Users>, <#Auth> ;
    api:framework "actix-web" .
EOF

ggen ai graph \
  --input architecture.ttl \
  --output examples/async-web-service/src/main.rs \
  --format rust

# Add lifecycle with database migrations
ggen lifecycle init --template web-service
```

#### 2.4 WASM Module (Use ggen ai project)
```bash
ggen ai project \
  --description "WebAssembly cryptographic module with password hashing, AES encryption, and digital signatures" \
  --name "wasm-crypto" \
  --language rust \
  --framework "wasm-bindgen" \
  --output examples/wasm-crypto

# Add WASM-specific lifecycle
cd examples/wasm-crypto
ggen lifecycle init --template wasm
ggen lifecycle add-phase wasm-build "wasm-pack build --target web"
ggen lifecycle add-phase wasm-optimize "wasm-opt -Oz pkg/*.wasm -o pkg/*.wasm"
```

#### 2.5 Embedded Firmware (Use ggen ai generate)
```bash
# Generate no-std template
ggen ai generate \
  --description "Embedded IoT firmware for ARM Cortex-M with sensor abstractions and power management (no-std)" \
  --examples "cortex-m-rt" "embedded-hal" "no heap allocation" \
  --output examples/embedded-iot/src/main.rs

# Add cross-compilation lifecycle
cd examples/embedded-iot
ggen lifecycle init --template embedded
ggen lifecycle add-phase build-arm "cargo build --target thumbv7em-none-eabihf --release"
```

### Step 3: Publish to Marketplace

```bash
# Publish each example as a template
cd examples/advanced-cli-tool
ggen marketplace publish \
  --name "advanced-cli-tool-template" \
  --description "Production-ready CLI tool with full lifecycle" \
  --category "templates" \
  --tags "cli,async,tokio,production"

cd ../perf-library
ggen marketplace publish \
  --name "perf-library-template" \
  --description "High-performance Rust library with benchmarks" \
  --category "libraries" \
  --tags "performance,benchmarks,datastructures"

# ... repeat for other examples
```

### Step 4: Demonstrate Consumption from Marketplace

```bash
# Someone else can now use these templates
ggen marketplace search "cli-tool"
ggen marketplace install advanced-cli-tool-template
ggen project new my-cli --template advanced-cli-tool-template

# Or with AI customization
ggen ai project \
  --from-template advanced-cli-tool-template \
  --customize "Add CSV processing support" \
  --output my-custom-cli
```

## Verification Checklist

- [ ] All examples generated using ggen commands (not manual code)
- [ ] Each example uses ggen lifecycle system
- [ ] All examples published to marketplace
- [ ] Documentation shows ggen commands used
- [ ] Examples can be regenerated from commands
- [ ] Examples can be consumed from marketplace
- [ ] Full lifecycle works for each example

## Expected Output

Each example directory should contain:
- **SOURCE GENERATED BY**: Comment showing ggen command used
- **.ggen/generation.log**: Log of generation process
- **make.toml**: Lifecycle configuration (auto-generated)
- **README.md**: Shows how it was created with ggen
- **.ggen/marketplace.json**: Marketplace metadata

## Benefits of This Approach

1. **Demonstrates ggen capabilities**: Shows users what ggen can do
2. **Self-validating**: If ggen can generate good examples, it works
3. **Up-to-date**: Regenerate examples with `ggen ai project` as ggen improves
4. **Marketplace testing**: Validates marketplace publish/install flow
5. **Documentation**: Generated examples are living documentation

## Next Steps

1. Clean existing manual examples
2. Run generation commands from Step 2
3. Add lifecycle configurations
4. Publish to marketplace
5. Test consumption flow
6. Document the process

---

**Key Insight**: The examples themselves are the best advertisement for ggen. If ggen can't generate good examples of itself, why would users trust it for their projects?
