{"id":13417515,"url":"https://github.com/Wulf/create-rust-app","last_synced_at":"2025-03-15T02:31:28.192Z","repository":{"id":37046116,"uuid":"365623200","full_name":"Wulf/create-rust-app","owner":"Wulf","description":"Set up a modern rust+react web app by running one command. ","archived":false,"fork":false,"pushed_at":"2025-03-10T09:31:13.000Z","size":44736,"stargazers_count":1562,"open_issues_count":25,"forks_count":66,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-03-14T06:05:11.211Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://wulf.github.io/create-rust-app/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wulf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-08T22:33:18.000Z","updated_at":"2025-03-10T17:02:31.000Z","dependencies_parsed_at":"2024-05-20T07:39:48.086Z","dependency_job_id":null,"html_url":"https://github.com/Wulf/create-rust-app","commit_stats":{"total_commits":191,"total_committers":11,"mean_commits":"17.363636363636363","dds":"0.32984293193717273","last_synced_commit":"fd10180d9d071d84e43fb9dad39764a7ec312aa7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wulf%2Fcreate-rust-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wulf%2Fcreate-rust-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wulf%2Fcreate-rust-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wulf%2Fcreate-rust-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wulf","download_url":"https://codeload.github.com/Wulf/create-rust-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243532551,"owners_count":20306155,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:38.937Z","updated_at":"2025-03-15T02:31:28.174Z","avatar_url":"https://github.com/Wulf.png","language":"Rust","readme":"# \u003cimg src=\"https://user-images.githubusercontent.com/4259838/150465966-7ac954d1-9f0c-48d4-a37a-10543b3bbfe1.png\" height=\"40px\"\u003e Create Rust App\n\n\u003c!-- markdownlint-disable-file MD033 --\u003e\n\n\u003ca href=\"https://crates.io/crates/create-rust-app\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/create-rust-app.svg?style=for-the-badge\" height=\"20\" alt=\"License: MIT OR Apache-2.0\" /\u003e\u003c/a\u003e\n\nSet up a modern rust+react web app by running one command. [Join us on discord](https://discord.gg/tm6Ey33ZPN).\n\n[create-rust-app.dev](https://create-rust-app.dev)\n\n## Requirements\n\n- [Rust](https://www.rust-lang.org/tools/install)\n- [`diesel_cli`](http://diesel.rs/guides/getting-started#installing-diesel-cli)\n  - For SQLite, if you don't wish to dynamically link `diesel_cli` with your system's `libsqlite3`, you may run `cargo install diesel_cli --no-default-features --features sqlite-bundled`.\n\n## Install\n\n```sh\ncargo install create-rust-app_cli\n```\n\n## Quick start\n\n```sh\ncreate-rust-app my-todo-app\n# .. select backend framework, plugins, etc.\n```\n\n```sh\n# Code-gen resources for your project\ncd ./my-todo-app\ncreate-rust-app\n# .. select resource type / properties\n```\n\n## Features\n\n### 1. Project creation\n\n```rust\ncreate-rust-app create \u003cproject_name\u003e\n```\n\n- Run frontend \u0026 backend with a single command: `cargo fullstack`\n- Rust backend\n  - One of the following frameworks:\n    - `actix-web`\n    - `poem` (support temporarily on hold, use version 9.2.2: `cargo install create-rust-app_cli@9.2.2`)\n  - Database migrations (using diesel.rs)\n    - Generate diesel structs and types by running `cargo dsync` in your project (see codegen section below).\n  - Sending mail\n  - PostgreSQL, SQLite 3.35+ support\n  - ViteJS (blazing fast frontend compile speeds)\n  - SSR templating with an option to include bundles that are automatically code-split\n    - The `/views` folder contains all templates\n    - The `/frontend/bundles` folder contains all the bundles which can be included in your views via `{{bundle(name=\"MyBundle.tsx\")}}`\n  - Automatically route to your single page application(s)\n    - Use `create_rust_app::render_single_page_application(\"/app\",\"your_spa.html\")` (if you're using Poem, the parameters are slightly different, an example is provided in the function's documentation)\n- React frontend (or install your own framework!)\n  - Typescript, with backend type definition generation (run `cargo tsync` in your project folder; see codegen section below)\n  - Routing (via `react-router-dom`)\n  - Typed `react-query` hooks generation (`$ cd my_project \u0026\u0026 create-rust-app`, then select \"Generate react-query hooks\")\n\n#### Available Plugins\n\n- **Authentication (+ Authorization) plugin**\n\n  - Add JWT token-based auth with a simple command\n  - Session management: restoration of previous session, revoking of refresh tokens\n  - Credentials management/recovery\n  - Email validation / activation flow\n  - Adds frontend UI + react hooks\n  - Adds auth service, and user / session models\n  - Block your endpoints via `Auth` guard\n  - Follows OWASP security best practices\n  - RBAC permissions out of the box (assign roles and permissions to users)\n\n- **Social authentication (OIDC) plugin**\n\n  - Adds Oauth2-based authentication (requires auth plugin)\n  - Just configure some OIDC providers:\n\n  ```rust\n  app.app_data(Data::new(AuthConfig {\n    oidc_providers: vec![GOOGLE(\n    \"client_id\",\n    \"client_secret\",\n    \"/success/redirect\",\n    \"/error/redirect\",\n    )],\n  }))\n  ```\n\n  Then, redirect your users to start the flow!\n\n  ```jsx\n  \u003ca href={\"/api/auth/google\"}\u003eLogin with Google\u003c/a\u003e\n  ```\n\n- **Container plugin**\n\n  - Dockerfile to containerize your rust app into a single image\n\n- **Development plugin**\n\n  - View your database via the admin portal at `localhost:3000/admin` (still in development)\n  - A \"devbox\" on the frontend indicates when the backend is compiling or when the database is not reachable\n  - Moreover, the devbox displays when migrations are pending + includes a \"run migrations\" button\n  - In-browser compilation errors and migration checking:\n    \u003ca href=\"https://user-images.githubusercontent.com/4259838/218256539-b94ecba1-abe6-4e42-b4f4-4d80b6d4079b.png\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/4259838/218256539-b94ecba1-abe6-4e42-b4f4-4d80b6d4079b.png\" width=\"650px\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://user-images.githubusercontent.com/4259838/218256539-b94ecba1-abe6-4e42-b4f4-4d80b6d4079b.png\"\u003e\u003cimg src=\"https://user-images.githubusercontent.com/4259838/218256528-4b6ca2a4-ffae-4c9e-bc20-c4a483355b01.png\" width=\"650px\" /\u003e\u003c/a\u003e\n\n- **Storage plugin**\n\n  - Adds `Storage` extractor which allows you to upload/download files from an S3-compatible object store\n  - Seamlessly add single or multiple attachments to your models using `Attachment::*`!\n  - Here are some examples:\n\n    - Adding an avatar to a user in your users table:\n\n    ```rust\n    let s3_key = Attachment::attach(\"avatar\", \"users\", user_id, AttachmentData {\n        file_name: \"image.png\",\n        data: bytes\n    })?;\n    ```\n\n    - Getting the url for the attachment\n\n    ```rust\n    let storage: Storage // retreive this via the appropriate extractor in your frameowrk of choice\n    let url = storage.download_uri(s3_key)?;\n    ```\n\n    (note: see `Attachment::*` and `Storage::*` for more functionality!)\n\n- **GraphQL plugin**\n\n  - Adds all the boilerplate necessary to expose GraphQL\n  - Requires the auth plugin: authentication and authorization setup out-of-the-box\n  - Find a graphql playground at `localhost:3000/graphql`\n\n- **Utoipa plugin**\n\n  - Uses the [utoipa](https://github.com/juhaku/utoipa) crate to add OpenAPI documentation and serve it in a SwaggerUI playground.\n  - Find the playground at `http://localhost:3000/swagger-ui/`\n  - Requires the backend be Actix (for now ;) )\n  - check out [this page](https://github.com/juhaku/utoipa/tree/master/examples) to see how to document your own API endpoints with a variety of backends\n  - Has a soft dependency on the Auth plugin\n\n- **Tasks Plugin**\n  - For running background jobs, currently only supports actix-web and postgresql\n  - Uses [`fang`](https://github.com/ayrat555/fang) under the hood and all it's features are exposed.\n  - Add a task to the queue with `create_rust_app::tasks::queue()`\n  - Run the queue with `cargo run --bin tasks`\n\n- **Workspace Support** (Enabled by default, not tied to a feature flag)\n  - allows you to organize your rust app in workspaces, and changes the defaults for the environment variables that specify paths to various important places.\n  - to organize you project as a workspace:\n    - enable this feature\n    - refactor your codebase into workspaces (see [#194](https://github.com/Wulf/create-rust-app/issues/194))\n    - Optional: set the following environment variables (paths are relative to the directory you call cargo fullstack/backend/run from)\n      - `CRA_MANIFEST_PATH`: default `./frontend/dist/manifest.json` when called from workspace root, `../frontend/dist/manifest.json` otherwise.\n      - `CRA_FRONTEND_DIR`: default `./frontend` when called from workspace root, `../frontend` otherwise.\n      - `CRA_VIEWS_GLOB`: default `backend/views/\\*\\*/\\*.html` when called from workspace root, `views/\\*\\*/\\*.html` otherwise.\n    - Note that in any non-standard setup, you will need to set the above environment variables to the correct values for your project to ensure correct behavior.\n\n### 2. Code-gen to reduce boilerplate\n\n```sh\ncargo dsync\n```\n\n- Run this commmand to generate diesel model structs and queries in your `backend/models` folder!\n- See dsync docs [here](https://github.com/Wulf/dsync)\n\n```sh\ncargo tsync\n```\n\n- Run this command to generate typescript types for your rust code marked with `#[tsync::tsync]`. You'll find the output for this command here: `frontend/src/types/rust.d.ts`.\n- See tsync docs [here](https://github.com/Wulf/tsync)\n\n```sh\ncd my_project \u0026\u0026 create-rust-app\n```\n\n- CRUD code-gen to reduce boilerplate\n  - Scaffolds the db model, endpoints service file, and hooks it up in your `/api`!\n- `react-query` hooks generation for frontend\n  - Generates a hook for each handler function defined in the `services/` folder\n  - Edit generated hooks afterwards -- they won't be regenerated unless you delete (or rename) the hook!\n\n## Walkthrough (old)\n\n[![Gif](docs/create-rust-app-v2.gif)](https://github.com/Wulf/create-rust-app/blob/main/docs/create-rust-app-v2.mp4)\n\n## Contributing\n\nQuestions and comments are welcome in the issues section!\n\nIf you're experiencing slow compilation time, make sure there isn't any bloat in the template files (look for `node_modules` or typescript / parcel caches and delete them).\nMoreover, you can try using the [mold](https://github.com/rui314/mold) linker which may also improve compilation times.\n","funding_links":[],"categories":["Integrations with Backends","Rust","Development tools","开发工具 Development tools","others"],"sub_categories":["Rust","Web Servers","Web服务器 Web Servers","Workflow Automation"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWulf%2Fcreate-rust-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWulf%2Fcreate-rust-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWulf%2Fcreate-rust-app/lists"}