**Table of Contents**
- [ggen - Graph-Aware Code Generation Framework](#ggen---graph-aware-code-generation-framework)
- [Why ggen?](#why-ggen)
- [Quick Start (2 Minutes)](#quick-start-2-minutes)
- [Core Workflow](#core-workflow)
- [Key Features](#key-features)
- [Architecture](#architecture)
- [Examples](#examples)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)
# ggen - Graph-Aware Code Generation Framework
[](https://seanchatmangpt.github.io/ggen/)
[](https://www.rust-lang.org/)
[](LICENSE)
[](https://crates.io/crates/ggen)
[](#)
[](#performance-slos)
[](#features)
[](https://seanchatmangpt.github.io/ggen/)
**ggen** is a production-ready, language-agnostic code generation framework that treats software artifacts as projections of RDF knowledge graphs. Generate reproducible, multi-language code from semantic ontologies using template-based generation with SPARQL queries and AI-powered enhancements.
## Why ggen?
**Generate code faster, smarter, and more consistently:**
- ๐ค **AI-Powered Generation** - GPT-4o, Claude 3.5, and local Ollama models
- ๐ **Language-Agnostic** - Generate Rust, TypeScript, Python, Go from one source
- ๐ **Knowledge Graph-Driven** - Embed semantic metadata with SPARQL queries
- ๐ฏ **Deterministic Output** - Byte-identical, reproducible builds every time
- โก **Production-Ready** - 88/100 readiness score, comprehensive testing
- ๐งช **Hermetic Testing** - Cleanroom framework for isolated, deterministic tests
- ๐ **Post-Quantum Security** - ML-DSA (Dilithium3) cryptographic signatures
## โก Quick Start (2 Minutes)
### Installation
```bash
# Install via Homebrew (macOS/Linux)
brew tap seanchatmangpt/tap
brew install ggen
# Or install from source
git clone https://github.com/seanchatmangpt/ggen
cd ggen
cargo install --path cli
```
### Your First Generation
```bash
# 1. Check your environment
ggen doctor
# 2. Generate a template-based project
ggen gen templates/rust-module.tmpl --vars name=my_module
# 3. Or use AI to generate an entire project
ggen ai project "REST API with authentication" --name my-api --rust
# 4. Search marketplace for packages
ggen search "rust web"
```
**๐ That's it!** You've generated your first ggen project.
---
## ๐ฏ Core Workflow
ggen follows a simple, powerful workflow for all projects:
```bash
# 1. Search & Discover - Find existing packages
ggen search "rust web service"
ggen categories
# 2. Install & Setup - Add packages to your project
ggen add io.ggen.rust.cli-subcommand
ggen add io.ggen.postgres.schema
# 3. Generate - Create code from templates
ggen gen rust-service.tmpl --vars name=auth_service
ggen ai project "User management API" --rust
# 4. Test & Validate - Ensure quality
cargo test
ggen doctor
# 5. Deploy - Ship to production
ggen github pages-status
cargo build --release
```
**Key Commands:**
| `ggen search <query>` | Find packages | `ggen search "rust web"` |
| `ggen add <package>` | Install package | `ggen add io.ggen.rust.cli` |
| `ggen gen <template>` | Generate code | `ggen gen service.tmpl --vars name=api` |
| `ggen ai project <desc>` | AI scaffolding | `ggen ai project "REST API" --rust` |
| `ggen doctor` | Health check | `ggen doctor` |
| `ggen list` | Show templates | `ggen list` |
---
## โจ Key Features
### ๐ค AI-Powered Generation
Generate templates, projects, and ontologies using advanced LLMs:
```bash
# Generate complete projects
ggen ai project "E-commerce API with Stripe" --name shop-api --rust
# Generate templates from descriptions
ggen ai generate -d "Database repository pattern" -o repo.tmpl
# Generate RDF ontologies
ggen ai graph -d "User management ontology" -o users.ttl
# Generate SPARQL queries
ggen ai sparql -d "Find all active users" -g schema.ttl
```
**Supported Providers:** OpenAI (GPT-4o), Anthropic (Claude 3.5), Ollama (local)
### ๐ฏ Deterministic & Reproducible
Generate byte-identical output every time:
```yaml
---
determinism: 42 # Fixed RNG seed
---
pub fn random() -> u32 {
{{ rand_int(0, 100) }} # Always generates same value
}
```
### ๐ Knowledge Graph-Driven
Embed RDF and query with SPARQL:
```yaml
---
rdf_inline:
- "@prefix foaf: <http://xmlns.com/foaf/0.1/> ."
- ":person foaf:name '{{name}}' ."
sparql:
get_name: "SELECT ?name WHERE { :person foaf:name ?name }"
---
Hello, {{ sparql(query="get_name") }}!
```
### ๐ฆ Marketplace Integration
Reusable template packages (gpacks):
```bash
ggen search "rust web" # Find packages
ggen add io.ggen.rust.axum # Install package
ggen list # Show templates
ggen update # Update packages
```
### ๐งช Production-Ready Testing
Hermetic, deterministic test environments:
- **Cleanroom Framework** - Isolated containers for testing
- **23+ Integration Tests** - Comprehensive CLI coverage
- **90%+ Test Coverage** - Critical paths validated
- **Zero `.expect()`** - Production-grade error handling
## ๐ Comparison
| **RDF/SPARQL** | โ
| โ | โ | โ |
| **AI Generation** | โ
| โ | โ | โ |
| **Multi-Language** | โ
| โ | โ | โ |
| **Deterministic** | โ
| โ ๏ธ | โ | โ ๏ธ |
| **Language** | Rust | Python | JavaScript | Python |
| **Performance** | <3s | Slower | Slower | Slower |
| **Marketplace** | โ
| โ
| โ
| โ |
| **Testing Framework** | โ
| โ | โ | โ |
## ๐ Template Example
```yaml
---
to: "src/{{name}}.rs"
vars:
name: "example"
rdf_inline:
- "@prefix ex: <http://example.org/> ."
- "ex:{{name}} a ex:Module ."
sparql:
get_type: "SELECT ?type WHERE { ex:{{name}} a ?type }"
determinism: 42
---
//! {{name}} module - Generated by ggen
//! Type from RDF: {{ sparql(query="get_type") }}
}
Self { name: name.into() }
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_new() {
let module = {{name | capitalize}}::new("test");
assert_eq!(module.name, "test");
}
}
```
**Generate it:**
```bash
ggen gen example.tmpl --vars name=my_module
```
## ๐๏ธ Architecture
**High-Level:**
```
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ ggen CLI โโโโโโโบโ ggen-core โโโโโโโบโ Output โ
โ (Commands) โ โ (Generation) โ โ (Code) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ ggen-ai โ
โ (LLM Client) โ
โโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ RDF + SPARQL โ
โ (Knowledge) โ
โโโโโโโโโโโโโโโโ
```
**Key Modules:**
- **cli/** - Command-line interface (Clap-based)
- **ggen-core/** - Template engine, RDF/SPARQL, marketplace
- **ggen-ai/** - AI providers (OpenAI, Anthropic, Ollama)
- **ggen-marketplace/** - Package management
- **utils/** - Shared utilities, configuration, logging
**๐ See:** [Architecture Deep Dive](https://seanchatmangpt.github.io/ggen/architecture)
## ๐ Examples
**Production-Ready Projects:**
- **[Microservices Architecture](examples/microservices-architecture/)** - Full stack with auth, users, payments
- **[AI Code Generation](examples/ai-code-generation/)** - Showcase of all AI features
- **[Advanced Rust Project](examples/advanced-rust-project/)** - Production Rust service with RDF
- **[Full Stack App](examples/full-stack-app/)** - Complete web application
**Quick Demos:**
```bash
# Browse all examples
ls examples/
# Run screencast demo
./examples/screencast-demo.sh
# Test an example
cd examples/microservices-architecture && cargo build
```
## ๐ ๏ธ Development
**Always use `cargo make` commands:**
```bash
# Quick workflow
cargo make quick # Format + test
cargo make dev # Format + lint + test
cargo make ci # Full CI pipeline
# Testing
cargo make test # All tests
cargo make test-coverage # Coverage report
cargo make deterministic # Reproducible tests
# Quality
cargo make fmt # Format code
cargo make lint # Clippy checks
cargo make audit # Security scan
# AI features
cargo make ai-dev # AI development
cargo make ai-demo # Run AI demo
```
## ๐ Documentation
**Essential Guides:**
- ๐ **[Full Documentation](https://seanchatmangpt.github.io/ggen/)** - Complete guides and API reference
- ๐ค **[AI Guide](docs/ai-guide.md)** - AI-powered generation
- ๐ **[CLI Reference](https://seanchatmangpt.github.io/ggen/cli)** - All commands explained
- ๐๏ธ **[Template Creation](https://seanchatmangpt.github.io/ggen/templates/creating)** - Build custom templates
- ๐ **[RDF & SPARQL](https://seanchatmangpt.github.io/ggen/rdf)** - Knowledge graph integration
**Production:**
- โ
**[Production Readiness](docs/v1-production-readiness.md)** - Validation report (88/100)
- ๐งช **[Testing Guide](docs/testing/README.md)** - Cleanroom testing framework
- ๐ **[Deployment](docs/DEPLOYMENT.md)** - GitHub Pages setup
**Development:**
- ๐ค **[Contributing](CONTRIBUTING.md)** - How to contribute
- ๐ ๏ธ **[Makefile Reference](MAKEFILE.md)** - All cargo-make tasks
- ๐ **[CLAUDE.md](CLAUDE.md)** - AI development guidelines
## โก Performance
**Build Times:**
- First build: ~3s (target โค15s) โ
- Incremental: 2-3s (target โค2s) โ
- RDF processing: <5s for 1k+ triples โ
**Generation:**
- CLI scaffolding: <3s end-to-end โ
- Memory usage: <100MB โ
- Reproducible: 100% byte-identical โ
**Testing:**
- Full suite: <60s โ
- Test coverage: 90%+ โ
- Deterministic: 100% reproducible โ
## ๐ฌ FAQ
**Q: Do I need Rust installed?**
A: Yes. Install with `brew install rust` or see [rustup.rs](https://rustup.rs).
**Q: Which AI providers are supported?**
A: OpenAI (GPT-4o), Anthropic (Claude 3.5), Ollama (local). Configure with `~/.config/ggen/ai-config.toml`.
**Q: Do I need to know RDF/SPARQL?**
A: No - basic generation works without RDF. Use RDF for advanced semantic features.
**Q: How do I create custom templates?**
A: Templates use YAML frontmatter + Tera syntax. Run `ggen ai generate -d "your idea"` or see [Template Creation Guide](https://seanchatmangpt.github.io/ggen/templates/creating).
**Q: Where do I get help?**
A: Run `ggen doctor` for diagnostics, `ggen help-me` for tips, or see [Troubleshooting Guide](https://seanchatmangpt.github.io/ggen/troubleshooting).
**More questions?** Check [GitHub Discussions](https://github.com/seanchatmangpt/ggen/discussions) or open an [issue](https://github.com/seanchatmangpt/ggen/issues).
---
## ๐ค Contributing
Contributions are welcome! **Quick start:**
1. Fork and clone: `git clone https://github.com/YOUR_USERNAME/ggen`
2. Verify setup: `cargo make quick`
3. Make changes and test: `cargo make ci`
4. Submit pull request
---
## ๐ License
MIT License - see [LICENSE](LICENSE) for details.
---
## ๐ Links
- **GitHub:** https://github.com/seanchatmangpt/ggen
- **Documentation:** https://seanchatmangpt.github.io/ggen/
- **Crates.io:** https://crates.io/crates/ggen
- **Homebrew:** `brew tap seanchatmangpt/tap && brew install ggen`
---
**Built with โค๏ธ using Rust, RDF, and SPARQL**