1 unstable release
| 0.1.0 | Oct 26, 2025 |
|---|
#2120 in Command line utilities
17KB
180 lines
π₯ Trestle
Trestle a new path for Rust web development. One command to rule all your boilerplate.
Trestle is a command-line tool designed to eliminate the boilerplate and setup cost of starting a new full-stack project in Rust. Inspired by frameworks like Django and Rails, Trestle scaffolds a complete, runnable application with a lightning-fast Axum backend, so you can start building features immediately.
Choose between a modern, reactive frontend with Dioxus (all in Rust!) or the elegant simplicity of server-rendered HTMX.
Core Features
- Powerful Rust Backend: All projects are built on the fast, ergonomic Axum
- Flexible Frontend: Choose your preferred paradigm:
- Dioxus: For building rich, interactive SPAs entirely in Rust (compiled to WASM).
- HTMX: For a traditional, server-rendered HTML approach using the Maud templating engine.
- Database Integration: Out-of-the-box support for multiple databases. The default is a static site with no database.
- SQL: PostgreSQL, MySQL (via
sqlx) - NoSQL: MongoDB
- BaaS:: Firebase (via REST API)
- SQL: PostgreSQL, MySQL (via
- Ready to Run: Generated projects include a
.env.example, pre-configuredCargo.toml, and all necessary connection logic.
π Installation
Once published, you can install trestle directly from crates.io:
cargo install trestle
From Source
You can also build and install from the source code:
git clone https://github.com/RedHoodJT1988/trestle.git
cd trestle
cargo install --path .
Usage
The main command is Trestle new. It takes a project name and optional flags to configure the frontend and database.
trestle new <PROJECT_PATH> [OPTIONS]
Options
| Flag | Argument | Description |
|---|---|---|
--frontend |
dioxus (default), htmx |
The frontend framework to use. |
--db |
postgres, mysql, mongodb, firebase |
The database to configure. If omitted, a static site (no DB) is created. |
-h, --help |
Print help information. |
Examples
- Create a default static site with Dioxus (no database):
trestle new my_static_site
- Create a static HTMX site (no database):
trestle new my_htmx_blog --frontend htmx
- Create a Dioxus app with PostgreSQL:
trestle new my_store --db postgres
- Create an HTMX dashboard with MongoDB:
trestle new my_dashboard --frontend htmx --db mongodb
Generated Project Structure
Running trestle new my_app --db postgres will generate the following structure:
my_app/
βββ .env.example # Environment variables (e.g., DATABASE_URL)
βββ .gitignore
βββ Cargo.toml # Pre-configured with Axum, Dioxus, SQLx, etc.
βββ Dioxus.toml # Dioxus build configuration
βββ index.html # Entrypoint for the Dioxus WASM app
βββ src/
βββ main.rs # Axum server entrypoint, routing, and state
βββ lib.rs # The root Dioxus application component
βββ db.rs # Database connection pool logic and models
π Contributing
We are thrilled you're interested in contributing to Trestle! This project is a community effort, and we welcome help of all kinds, from fixing bugs to adding new features.
How to Contribute
- Find an Issue: Look through our GitHub Issues. Good first issues are a great place to start.
- Open an Issue: If you have a feature idea or find a bug, please open an issue first to discuss it.
- Fork and Clone: Fork the repository and clone it locally.
git clone https://github.com/RedHoodJT1988/trestle.git
cd trestle
- Create a Branch: Create a new branch for your feature or bugfix.
git checkout -b feature/my-new-feature
- Make Your Changes:
- The core logic is in
src/main.rsandsrc/scaffold/mod.rs. - All project blueprints are located in the
templates/directory. - To add a feature (e.g., a new database), you would create new template directories (e.g.,
templates/redis-htmxandtemplates/redis-dioxus) and update themain.rsfile to recognize the new--db redisflag.
- Test Your Changes: Build the CLI and test it locally.
cargo build --release
./target/release/trestle new test-project --db YOUR_NEW_DB
cd test-project
cargo run
- Submit a Pull Request: Push your branch to your fork and open a Pull Request against the
mainbranch of the original repository.
πΊοΈ Roadmap
We have big plans for trestle! Here are some of the features we'd love to add:
- [] Authentication: Scaffold complete auth logic (registration, login, sessions) for different strategies (e.g., JWT, cookies).
- [] More Databases: Add support for
Redis,SQLite(great for simple apps!), and other popular databases. - [] Deployment: Add
Dockerfileandfly.tomlgeneration for easy deployment. - [] Interactive Mode: An interactive
trestle newcommand that walks the user through the setup process.
Your contributions are essential to making this happen!
πͺͺLicense
This project is licensed under the MIT License. See the LICENSE file for details.
Dependencies
~1β12MB
~81K SLoC