Author: π Hi, I'm CryptoPatrick! I create tools and frameworks for the Rust ecosystem. If you have questions or want to connect, reach out on X/Twitter.
π Status
- v1.0.0 - Production-ready release
- 208+ tests passing across all platforms
- 5 official templates included and maintained
- Multi-platform support - macOS, Linux, Windows
- Fully open-source and community-driven
π€ What is cargo-x402
cargo-x402 is a template scaffolding tool that helps you create production-ready Rust projects in seconds. It automatically discovers templates from GitHub repositories tagged with x402-template and provides an interactive CLI for creating projects with custom parameters.
Instead of manually setting up boilerplate code, copying files, and configuring projects, cargo-x402 handles it all instantlyβand it's customizable for your needs.
Use Cases
- Rapid Prototyping: Start API projects in seconds with batteries included
- Standardized Architecture: Enforce consistent project structure across teams
- Best Practices: Include production-grade patterns (logging, observability, database)
- Full-Stack Development: Scaffold complete applications (frontend + backend)
- CLI Tools: Create command-line utilities with proper argument parsing
- Microservices: Deploy production-ready services with observability built-in
π Architecture
- π Overall Workflow
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Command: cargo-x402 create β
β (Interactive or Direct) β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ
β Discovery Module β
β β’ Check local cache (< 1 hour) β
β β’ If stale, query GitHub API for x402-template topic β
β β’ Cache results locally β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Interactive Selection β
β (or use --template flag) β
β User chooses template β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Parameter Input β
β (Project name, options) β
β Validation & prompts β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Download & Extract β
β Template from GitHub β
β Clone to temp directory β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Validate x402.toml β
β Schema validation β
β Parameter verification β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Liquid Rendering β
β Substitute parameters β
β Process conditionals β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Project Creation β
β Copy files to destination β
β Clean up .git directory β
β Initialize git repo β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β Success! β β
β Ready to develop β
β Next steps displayed β
βββββββββββββββββββββββββββββββ
- π Discovery & Caching Flow
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β cargo-x402 list (or discover templates) β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
ββββββββββΌβββββββββ
β Check Local β
β Cache (1hr) β
ββββββββββ¬βββββββββ
β
βββββββββββββ΄ββββββββββββ
β β
ββββββββΌβββββββ ββββββββΌβββββββ
β Cache Valid β βCache Stale β
β Return! β βor Missing β
β (Fast) β β β
βββββββββββββββ ββββββΌβββββββββββ
β Query GitHub β
β API (topic) β
ββββββ¬βββββββββββ
β
βββββββββΌβββββββββ
β Parse Results β
β Extract Metadata
β (name, description,
β owner, stars) β
βββββββββ¬βββββββββ
β
βββββββββΌβββββββββ
β Update Cache β
β + timestamp β
βββββββββ¬βββββββββ
β
βββββββββΌβββββββββ
β Display List β
β to User β
ββββββββββββββββββ
- π Template Creation Flow
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Selected Template Details β
β β’ Name, description, URL β
β β’ x402.toml manifest β
β β’ Parameters (string, boolean, enum) β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 1. Download Template β
β β’ Clone from GitHub β
β β’ Temporary directory β
β β’ Extract files β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 2. Parse x402.toml β
β β’ Read manifest β
β β’ Extract parameters β
β β’ Validate schema β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 3. Prompt for Parameters β
β (or use defaults) β
β β’ Validate input β
β β’ Type checking β
β β’ Regex patterns β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 4. Render with Liquid β
β β’ Variable substitution β
β β’ Conditionals β
β β’ File processing β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 5. Create Project Directory β
β β’ Create output folder β
β β’ Check for collisions β
β β’ Copy rendered files β
βββββββββββββββ¬βββββββββββββββββ
β
βββββββββββββββΌβββββββββββββββββ
β 6. Finalization β
β β’ Remove .git (template) β
β β’ Initialize new .git β
β β’ First commit β
β β’ Display success β
βββββββββββββββββββββββββββββββ
- βοΈ Module Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β cargo-x402 CLI β
β (src/main.rs) β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
ββββββΌββββββ ββββββββΌβββββββ βββββββΌβββββββ
β Discoveryβ β Schema β β Template β
β Module β β Validation β β Render β
β β β β β β
β β’ GitHub β β β’ x402.toml β β β’ Liquid β
β β’ Cache β β β’ Validator β β β’ File β
β β’ Topics β β β’ Parameter β β copy β
β β β types β β β
ββββββ¬ββββββ ββββββββ¬βββββββ βββββββ¬βββββββ
β β β
ββββββββββββββββββΌβββββββββββββββββ
β
ββββββββββββββββββΌβββββββββββββββββ
β β β
ββββββΌβββββββ ββββββββΌβββββββ βββββββΌβββββββ
β Commands β β Interactive β β Error β
β β β Prompts β β Handling β
β β’ list β β β β β
β β’ create β β β’ Dialoguer β β β’ Error β
β β β β’ Colored β β types β
β β β output β β β’ Helpful β
β β β β’ Validationβ β messages β
βββββββββββββ βββββββββββββββ ββββββββββββββ
π· Features
Core Capabilities
- Template Discovery: Automatic discovery from GitHub via
x402-templatetopic - Interactive CLI: User-friendly terminal interface with colored output
- Smart Caching: 1-hour cache with manual refresh option
- Parameter Handling: Support for string, boolean, and enum parameters
- Schema Validation: Comprehensive validation of template configuration
- Liquid Templating: Safe variable substitution with conditionals and loops
Template System
- x402.toml Schema: Declarative template configuration
- File Rules: Include/exclude patterns for flexible file management
- Version Constraints: Specify minimum Rust and cargo-x402 versions
- Parameter Validation: Regex patterns and enum options for user input
- Metadata Support: Template name, description, authors, and tags
- GitHub Integration: Seamless discovery and download from GitHub
Developer Experience
- Zero Configuration: Works out of the box
- Progress Indicators: Visual feedback for all operations
- Helpful Error Messages: Clear guidance when something goes wrong
- Smart Defaults: Sensible defaults reduce the number of prompts
- Git Integration: Automatic git repository initialization
- Template Examples: 5 official templates to get started
π Quick Start
Installation
Install from crates.io:
Or build from source:
Your First Project (30 seconds)
Option 1: Interactive Mode
# Start interactive menu
# Follow prompts to:
# 1. Browse available templates
# 2. Select template
# 3. Enter project name and options
# 4. Confirm and create
Option 2: Direct Command
# Create project directly
# Skips template selection and uses defaults
Option 3: List Templates First
# See all available templates
# Show templates matching tags
What You Get
After running cargo-x402 create, you'll have:
my-awesome-api/
βββ src/
β βββ main.rs # Ready-to-run code
βββ Cargo.toml # Configured dependencies
βββ README.md # Project documentation
βββ .gitignore # Git configuration
βββ .env.example # Environment template
βββ Dockerfile # Container support
βββ .git/ # Initialized git repo
Everything is ready to build and run:
π¦ Templates
Official Templates (v0.2.0)
1. Basic Axum API
Production-ready REST API with Axum framework
Features:
- Health check endpoints
- Request/response handling
- Structured logging
- Error handling
Use for: Quick API prototypes, microservices, REST backends
2. Axum + PostgreSQL
Full-featured API with database support
Features:
- SQLx with Postgres
- Database migrations
- Connection pooling
- CRUD operations
Use for: Data-driven applications, persistent storage requirements
3. Full-Stack (Axum + React)
Complete web application with backend and frontend
Features:
- Axum REST API backend
- React 18 frontend with TypeScript
- Vite build system
- CORS configuration
- Docker Compose setup
Use for: Web applications, SPA + API combos, full-stack projects
4. Microservice with Observability
Production-grade microservice with tracing and metrics
Features:
- Jaeger distributed tracing
- Prometheus metrics
- Structured logging
- JSON output
- Health checks
Use for: Cloud deployments, observability needs, production services
5. CLI Tool
Professional command-line tool template
Features:
- Clap argument parsing
- Colored output
- Progress indicators
- File operations
- Error handling
Use for: CLI utilities, scripts, command-line tools
Create Your Own Template
See TEMPLATE_AUTHOR_GUIDE.md for:
- Template structure and format
- Parameter configuration
- Publishing on GitHub
- Best practices
π Documentation
For Users
- QUICKSTART.md - Get started in 10 minutes
- Installation methods
- Your first project
- Common customizations
- FAQs and troubleshooting
For Template Authors
- TEMPLATE_AUTHOR_GUIDE.md - Create custom templates
- Complete template structure guide
- x402.toml manifest specification
- Liquid templating syntax and examples
- Parameter validation and file handling
- Publishing and GitHub discovery
- Best practices and troubleshooting
For Developers
- API Documentation - Full Rustdoc reference
- GitHub Repository - cryptopatrick/cargo-x402
- Official Templates - xForth Templates
πΊοΈ Roadmap
v0.5.0 β (Current : Production Ready)
- Stable public API
- 5 official maintained templates
- Comprehensive test coverage (208+ tests)
- Full documentation and guides
- Multi-platform support (macOS, Linux, Windows)
v0.6.0 (Work on this will start in december)
- Enhanced template caching and offline mode
- Template repository metadata indexing
- Improved parameter validation with custom validators
- Template dependency resolution
v0.7.0
- Local template support (non-GitHub templates)
- Custom template hooks (pre/post generation)
- Private repository template support
- Performance profiling and optimization
v0.8.0
- Official template marketplace/registry
- IDE integrations (VS Code, IntelliJ)
- Template signing and verification
- Advanced dependency management
π Author
CryptoPatrick - Rust ecosystem tools & frameworks
π£ Support
Star β this project if you find it useful!
Report Issues
- Open GitHub Issue
- Include: command, error message, OS/Rust version
Get Help
- Check QUICKSTART.md for common questions
- Review TEMPLATE_AUTHOR_GUIDE.md for template creation
- Search existing GitHub Issues
π€ Contributing
Found a bug? Want a feature? Have a template idea?
Contributions are welcome! Please see CONTRIBUTING.md for:
- Code style and standards
- Testing requirements
- Submitting PRs
- Development setup
Ways to Contribute
- Report Bugs - Found an issue? Open a GitHub issue
- Suggest Features - Have an idea? Share it in discussions
- Create Templates - Build and publish templates to GitHub
- Improve Docs - Help improve guides and documentation
- Submit Code - Fix bugs or implement features
π License
This project is licensed under the MIT License. See LICENSE for details.