Language-agnostic boilerplate generator from YAML data models
Project description
Patisserie
Language-agnostic boilerplate code generator from YAML data models and Jinja2 templates.
Define your data model once in YAML. Generate boilerplate code in any language (Java, Rust, Python, Go, TypeScript, etc.) using Jinja2 templates.
Why Pattiserie?
- Single Source of Truth: Define your data model once, generate code for multiple languages
- Template-Driven: Use Jinja2 to create language-specific templates
- Configuration as Code: YAML schemas with anchors for DRY configuration
- Language Agnostic: Generate Java, Rust, Python, Go, TypeScript, or any text-based format
- Zero Runtime Dependencies: Just Python, PyYAML, and Jinja2
Quick Start
Installation
pip install patisserie
5-Minute Example
-
Initialize a project:
mkdir my-project && cd my-project pati mise
The pati mise command will create the .pati directory for you and create the sample schema.yaml and templates files you can edit.
-
Edit your data model (
.pati/schema.yaml):jobs: user_entity: template: entity.java.j2 output: generated/User.java context: package: com.example class_name: User fields: - name: id type: Long - name: username type: String
-
Customize a template (
.pati/tmplts/entity.java.j2):package {{ package }}; public class {{ class_name }} { {% for field in fields %} private {{ field.type }} {{ field.name }}; {% endfor %} } -
Generate code:
pati cuire -
Check the output:
cat generated/User.java
Features
๐ YAML Schema Support
- Define jobs with template, output, and context
- YAML anchors (
&name) and aliases (*name) for reusable config - Merge key (
<<: *alias) for DRY configuration - Full PyYAML support for complex structures
๐จ Jinja2 Templates
- Variables:
{{ variable }} - Loops:
{% for item in items %} - Conditionals:
{% if condition %} - Filters:
{{ value | filter }} - Complete Jinja2 feature set
๐ ๏ธ CLI Tools
# Generate all jobs from default schema (.pati/schema.yaml)
pati cuire
# Generate specific job(s) by name
pati cuire pojo_user
# Generate jobs matching a glob pattern
pati cuire 'pojo*'
# Generate jobs matching multiple patterns
pati cuire 'pojo*' dto_user
# Generate from a specific schema
pati cuire --config path/to/schema.yaml
# Dry run (preview without writing)
pati cuire --dry-run
# Override output directory
pati cuire --output-dir /path/to/output
# Initialize new project, creating a sample yaml
# and the sample template files in the directory .pati
pati mise
๐ฆ Built-in Examples
- Java Spring Boot: Entities, DTOs, Repositories, Liquibase migrations
- Rust SQLx: Models with SQLx derive macros
- Python SQLAlchemy: ORM models
- Go GORM: Struct definitions with GORM tags
These examples are for demonstration purpose only. They are simplified. Real word examples can start from these templates, but they will likely be extended.
Documentation
- Installation Guide โ Setup and troubleshooting
- Quick Start Guide โ Get running in 5 minutes
- YAML Schema Reference โ Complete schema documentation
- Jinja2 Template Syntax โ Template language reference
- Real-World Examples โ Complete working examples
- Why Pรขtisserie? โ The philosophy behind the name
Example Use Cases
Multi-language ORM Models
jobs:
user_java:
template: entity.java.j2
output: src/main/java/User.java
context: { class_name: User, fields: [...] }
user_python:
template: model.py.j2
output: models/user.py
context: { class_name: User, fields: [...] }
user_rust:
template: model.rs.j2
output: src/models/user.rs
context: { struct_name: User, fields: [...] }
Microservice Scaffolding
Generate controllers, services, and DTOs from a single data model schema.
API Client/Server Code
Generate OpenAPI specs, request/response models, and route handlers.
Database Migrations
Generate SQL migrations, Liquibase changesets, or Flyway migrations.
Configuration Files
Generate Docker Compose, Kubernetes manifests, or Terraform code.
Architecture
schema.yaml Template files Generated code
โ (Jinja2) โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
pati
(config loader + generator)
- Load YAML schema
- Extract job configuration
- Initialize Jinja2 environment
- Render each template with context
- Write generated files
Development
This chapter is about how to develop the code of Pรขtisserie itself.
Setup
git clone https://github.com/yourusername/pati.git
cd pati
pip install -e ".[dev]"
Running Tests
pytest tests/ -v --cov
Building
./build.sh
Releasing
./release.sh 0.2.0
CLI Reference
# Generate from default schema
pati cuire [JOB ...] [OPTIONS] # French: "to bake"
pati generate [JOB ...] [OPTIONS] # English alias โ identical
JOB Job name(s) or glob patterns to run (default: all)
Examples: pojo_user 'pojo*' 'pojo*' dto_user
--config, -c FILE Path to schema file (default: .pati/schema.yaml)
--dry-run Show what would be generated without writing
--output-dir DIR Override output directory for all jobs
# Initialize new project structure
pati mise [OPTIONS] # French: "mise en place"
pati init [OPTIONS] # English alias โ identical
--output, -o DIR Output directory (default: current directory)
# Show version
pati --version, -v
# Logging level (global flags, mutually exclusive)
pati --verbose COMMAND # debug output
pati --quiet COMMAND # warnings and errors only
pati -q COMMAND
pati --silent COMMAND # errors only
pati -s COMMAND
# Show help
pati --help
pati COMMAND --help
Project Structure
pati/
โโโ src/pati/ # Main package
โ โโโ __init__.py # Package metadata
โ โโโ cli.py # CLI entry point
โ โโโ config.py # YAML config loader
โ โโโ generator.py # Template generator
โ โโโ utils.py # Helper functions
โโโ examples/ # Example templates
โ โโโ java-spring/
โ โโโ rust-sqlx/
โ โโโ python-sqlalchemy/
โ โโโ go-gorm/
โโโ tests/ # Test suite
โโโ docs/ # Documentation
โโโ setup.py # Package metadata
โโโ pyproject.toml # Modern Python config
โโโ build.sh # Build script
โโโ release.sh # Release script
License
Licensed under either of:
at your option.
Contributing
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Write tests for new features
- Ensure tests pass:
pytest tests/ -v --cov - Submit a pull request
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Docs: Full Documentation
Roadmap
- Watch mode for live template development
- Template inheritance and includes
- Custom Jinja2 filters and globals
- Schema validation with JSON Schema
- Plugin system for extensibility
- Web UI for template editing
- Template marketplace
Ready to generate? โ Quick Start Guide
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file patisserie-1.1.0.tar.gz.
File metadata
- Download URL: patisserie-1.1.0.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e11ebe8ae38bdb5d5f3d3a0c9fef135edef0472741f15e8363015d0e71ff21ea
|
|
| MD5 |
5667e37391e7782c0184012516133e2e
|
|
| BLAKE2b-256 |
1035f16cf0f1f6608427fff7efaed2ec6bceae94800a8cf54b25ff6e40667e77
|
File details
Details for the file patisserie-1.1.0-py3-none-any.whl.
File metadata
- Download URL: patisserie-1.1.0-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6828a0df8dc474886448890f78cad1c71d94f8b2c725f94bfb3e63d5697b517d
|
|
| MD5 |
39de57458fd14f70cbdcb5f92335212c
|
|
| BLAKE2b-256 |
35fbbc22b354f0417820e3fccf895295a5322fff57bff9ae44e5939328271d0d
|