Table of Contents
ggen - Graph-Aware Code Generation Framework
ggen is a deterministic, language-agnostic code generation framework that treats software artifacts as projections of RDF knowledge graphs. Generate reproducible, multi-language code from a single semantic ontology using template-based generation with SPARQL queries.
๐ Full Documentation
Features
- ๐ฏ Deterministic Generation - Byte-identical output with fixed seeds
- ๐ Language-Agnostic - Generate code in any language from the same ontology
- ๐ RDF Knowledge Graphs - Embed semantic metadata with SPARQL queries
- ๐ฆ Marketplace Integration - Reusable template packages (rpacks) with versioning
- ๐งช Template-Based - YAML frontmatter with Tera templating engine
- ๐ Injection Support - Modify existing files with idempotent updates
- ๐ GitHub Integration - Built-in GitHub Pages and Actions API support
- ๐ Post-Quantum Security (v1.0.0) - ML-DSA (Dilithium3) signatures for quantum-resistant package integrity
- โก Performance SLOs - Fast builds, low memory, reproducible outputs
Quick Start
Installation
Homebrew (macOS/Linux):
From Source:
Basic Usage
# Generate from a template
# Search marketplace for templates
# Add a template pack
# List available templates
# Check GitHub Pages status
Template Example
---
to: "src/{{name}}.rs"
vars:
name: "example"
author: "ggen"
prefixes:
ex: "http://example.org/"
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 {{author}}
pub struct {{name | capitalize}} {
// Module implementation
}
impl {{name | capitalize}} {
pub fn new() -> Self {
Self {}
}
}
Architecture
ggen/
โโโ cli/ # Clap CLI with subcommands
โโโ ggen-core/ # Core generation engine
โ โโโ pipeline.rs # Template rendering pipeline
โ โโโ template.rs # Frontmatter + body parsing
โ โโโ graph.rs # RDF graph with SPARQL caching
โ โโโ generator.rs # Generation orchestration
โ โโโ registry.rs # Marketplace client
โ โโโ github.rs # GitHub API integration
โโโ utils/ # Configuration, logging, errors
โโโ templates/ # Built-in templates
Key Capabilities
Deterministic Generation
Generate byte-identical output with fixed seeds:
---
determinism: 42 # Fixed RNG seed
---
RDF + SPARQL Integration
Embed semantic knowledge and query it:
---
prefixes:
foaf: "http://xmlns.com/foaf/0.1/"
rdf_inline:
- "@prefix foaf: <http://xmlns.com/foaf/0.1/> . :person foaf:name \"{{name}}\" ."
sparql:
get_name: "SELECT ?name WHERE { :person foaf:name ?name }"
---
Name from RDF:
Injection Modes
Modify existing files idempotently:
---
to: "src/lib.rs"
inject:
mode: "after"
pattern: "pub mod"
skip_if: "pub mod {{name}}"
---
pub mod {{name}};
GitHub Integration
Built-in GitHub API commands:
# Check Pages deployment status
# View workflow runs
# Trigger workflow
Development
CRITICAL: Always use cargo make commands, never direct cargo commands.
# Quick development workflow
# Testing
# Code quality
# Build
# GitHub/Pages
Marketplace (rpacks)
Rpacks are versioned, reusable template packages:
# Search for rpacks
# View categories
# Add an rpack
# List installed rpacks
# Update rpacks
Documentation
- ๐ Full Documentation - Complete guides and API reference
- ๐ Deployment Guide - GitHub Pages setup
- ๐ง GitHub API Integration - Rust-based GitHub integration
- ๐ CLAUDE.md - Development guidelines for Claude Code
- ๐ ๏ธ Makefile Reference - All cargo-make tasks
Performance SLOs
- First build: โค 15s
- Incremental build: โค 2s
- RDF processing: โค 5s for 1k+ triples
- Generation memory: โค 100MB
- CLI scaffolding: โค 3s end-to-end
- 100% reproducible outputs
Contributing
- Follow the guidelines in CLAUDE.md
- Always use
cargo makecommands - Ensure
cargo make cipasses before submitting - Add tests for new features
- Update documentation
License
MIT License - see LICENSE for details.
Repository
Source: https://github.com/seanchatmangpt/ggen
Homebrew Tap:
tap
brew
Built with โค๏ธ using Rust, RDF, and SPARQL