Table of Contents
ggen - Graph-Aware Code Generation Framework
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
# Install via Homebrew (macOS/Linux)
# Or install from source
Your First Generation
# 1. Check your environment
# 2. Generate a template-based project
# 3. Or use AI to generate an entire project
# 4. Search marketplace for packages
๐ That's it! You've generated your first ggen project.
๐ฏ Core Workflow
ggen follows a simple, powerful workflow for all projects:
# 1. Search & Discover - Find existing packages
# 2. Install & Setup - Add packages to your project
# 3. Generate - Create code from templates
# 4. Test & Validate - Ensure quality
# 5. Deploy - Ship to production
Key Commands:
| Command | Purpose | Example |
|---|---|---|
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 |
๐ See: Complete Workflow Guide | CLI Reference
โจ Key Features
๐ค AI-Powered Generation
Generate templates, projects, and ontologies using advanced LLMs:
# Generate complete projects
# Generate templates from descriptions
# Generate RDF ontologies
# Generate SPARQL queries
Supported Providers: OpenAI (GPT-4o), Anthropic (Claude 3.5), Ollama (local)
๐ฏ Deterministic & Reproducible
Generate byte-identical output every time:
---
determinism: 42 # Fixed RNG seed
---
pub fn random() -> u32 {
# Always generates same value
}
๐ Knowledge Graph-Driven
Embed RDF and query with SPARQL:
---
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):
๐งช 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
๐ See: Production Readiness Report | Testing Guide
๐ Comparison
| Feature | ggen | Cookiecutter | Yeoman | Copier |
|---|---|---|---|---|
| RDF/SPARQL | โ | โ | โ | โ |
| AI Generation | โ | โ | โ | โ |
| Multi-Language | โ | โ | โ | โ |
| Deterministic | โ | โ ๏ธ | โ | โ ๏ธ |
| Language | Rust | Python | JavaScript | Python |
| Performance | <3s | Slower | Slower | Slower |
| Marketplace | โ | โ | โ | โ |
| Testing Framework | โ | โ | โ | โ |
๐ Template Example
---
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:
pub struct {{name | capitalize}} {
name: String,
}
impl {{name | capitalize}} {
pub fn new(name: impl Into<String>) -> Self {
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:
๐๏ธ 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
๐ Examples
Production-Ready Projects:
- Microservices Architecture - Full stack with auth, users, payments
- AI Code Generation - Showcase of all AI features
- Advanced Rust Project - Production Rust service with RDF
- Full Stack App - Complete web application
Quick Demos:
# Browse all examples
# Run screencast demo
# Test an example
&&
๐ See: Examples Directory | Project Gallery
๐ ๏ธ Development
Always use cargo make commands:
# Quick workflow
# Testing
# Quality
# AI features
๐ See: CONTRIBUTING.md | Makefile Reference
๐ Documentation
Essential Guides:
- ๐ Full Documentation - Complete guides and API reference
- ๐ค AI Guide - AI-powered generation
- ๐ CLI Reference - All commands explained
- ๐๏ธ Template Creation - Build custom templates
- ๐ RDF & SPARQL - Knowledge graph integration
Production:
- โ Production Readiness - Validation report (88/100)
- ๐งช Testing Guide - Cleanroom testing framework
- ๐ Deployment - GitHub Pages setup
Development:
- ๐ค Contributing - How to contribute
- ๐ ๏ธ Makefile Reference - All cargo-make tasks
- ๐ 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.
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.
Q: Where do I get help?
A: Run ggen doctor for diagnostics, ggen help-me for tips, or see Troubleshooting Guide.
More questions? Check GitHub Discussions or open an issue.
๐ค Contributing
Contributions are welcome! Quick start:
- Fork and clone:
git clone https://github.com/YOUR_USERNAME/ggen - Verify setup:
cargo make quick - Make changes and test:
cargo make ci - Submit pull request
๐ See: CONTRIBUTING.md | Good First Issues | Development Guide
๐ License
MIT License - see 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