16 stable releases (5 major)
| 5.1.3 | Jan 6, 2026 |
|---|---|
| 5.0.2 | Dec 21, 2025 |
| 4.0.0 | Dec 12, 2025 |
| 3.4.1 | Dec 11, 2025 |
| 0.2.1 | Oct 9, 2025 |
#681 in Template engine
Used in 9 crates
(8 directly)
2.5MB
46K
SLoC
ggen-core - Core graph-aware code generation engine
This crate provides the core functionality for RDF-based code generation, including template processing, RDF handling, and deterministic output generation.
Overview
ggen-core is the foundational crate for the ggen code generation system. It provides:
- Template Processing: Parse, render, and generate code from templates with RDF integration
- RDF Graph Management: Load, query, and manipulate RDF data using SPARQL
- Project Generation: Scaffold complete projects from templates
- Registry Integration: Discover and install template packs from the registry
- Lifecycle Management: Orchestrate build, test, and deployment phases
- Deterministic Output: Ensure reproducible code generation
Key Modules
Template System
template- Core template parsing and renderingtemplates- File tree generation from templatespipeline- Template processing pipelinegenerator- High-level generation engine
RDF Integration
graph- RDF graph management with SPARQL caching- [
rdf] - Template metadata and validation delta- Delta-driven projection for graph changes
Project Management
project_generator- Scaffold new projects (Rust, Next.js, etc.)cli_generator- Generate CLI projects from ontologieslifecycle- Universal lifecycle system for cross-language projects
Registry and Packs
registry- Registry client for pack discoverycache- Local cache manager for downloaded packslockfile- Dependency lockfile managementresolver- Template resolution from packsgpack- Gpack manifest structure and file discovery
Utilities
inject- File injection utilitiesmerge- Three-way merge for delta-driven projectionsnapshot- Snapshot management for baselinespreprocessor- Template preprocessor pipelineregister- Tera filter and function registrationtera_env- Tera template engine environment utilities
Security (Week 4 Hardening)
security- Security hardening module (command injection prevention, input validation)
Quick Start
Basic Template Generation
use ggen_core::{Generator, GenContext, Pipeline};
use std::collections::BTreeMap;
use std::path::PathBuf;
let pipeline = Pipeline::new()?;
let mut vars = BTreeMap::new();
vars.insert("name".to_string(), "MyApp".to_string());
let ctx = GenContext::new(
PathBuf::from("template.tmpl"),
PathBuf::from("output")
).with_vars(vars);
let mut generator = Generator::new(pipeline, ctx);
let output_path = generator.generate()?;
println!("Generated: {:?}", output_path);
Using RDF Graph
use ggen_core::Graph;
let graph = Graph::new()?;
graph.insert_turtle(r#"
@prefix ex: <http://example.org/> .
ex:alice a ex:Person ;
ex:name "Alice" .
"#)?;
let results = graph.query("SELECT ?s ?o WHERE { ?s ex:name ?o }")?;
assert!(!results.is_empty());
Creating a New Project
use ggen_core::project_generator::{ProjectConfig, ProjectType, create_new_project};
use std::path::PathBuf;
let config = ProjectConfig {
name: "my-cli".to_string(),
project_type: ProjectType::RustCli,
framework: None,
path: PathBuf::from("."),
};
create_new_project(&config).await?;
ggen-core
Core graph-aware code generation engine for ggen, providing RDF processing, template management, and code generation capabilities.
Features
- RDF/SPARQL processing and querying
- Template engine with frontmatter support
- Deterministic code generation
- Marketplace and registry support
- Pipeline management for code generation workflows
Usage
This crate is primarily used internally by the main ggen binary. See the main ggen documentation for usage examples.
Dependencies
~98MB
~1.5M SLoC