Leptos Axum Prisma starter with Admin dashboard and SSR/SPA website
MIT License
Intro: https://youtu.be/6eMWAI1D-XA Demo site: https://lapa.chepura.space
I want to have practical full-stack setup to build websites and services. Utilising type safety and performance of Rust opens the door for new era of web dev, that is taking off. Ecosystem and standardized approach is helpful to develop scalable and future-proof apps. Some benefits:
https://leptos.dev leptos-rs/leptos A cutting-edge, high-performance frontend framework SSR+SPA. Using reactive signals.
tokio-rs/axum Backend framework built with Tokio, Tower, and Hyper. Focuses on ergonomics and modularity.
https://www.prisma.io https://prisma.brendonovich.dev Brendonovich/prisma-client-rust Type-safe database access.
cargo prisma db push # generate client and push schema to db
# or
cargo prisma generate # only generate client
RUST_LOG="debug" cargo lapa settings-init
RUST_LOG="debug" cargo lapa user-add
RUST_LOG="info,admin=debug" cargo leptos watch -p admin
RUST_LOG="info,site=debug" cargo leptos watch -p site
Tip to enable tower_http debug
RUST_LOG="info,tower_http=debug,admin=debug" cargo leptos watch -p admin
RUST_LOG="info,tower_http=debug,site=debug" cargo leptos watch -p site
See relevant tutorial and demo project. https://github.com/alexichepura/leptos_axum_prisma_sozu https://www.youtube.com/watch?v=KLg8Hcd3K_U
cargo leptos build --release
Production with compress and ratelimit
cargo leptos build --release --features="compression,ratelimit"
# or
cargo leptos build --release --features="prod"
./ops folder contains example scripts to prepare production build and deploy it on server. Check .env.example Requires https://github.com/ryanfowler/precompress
./ops/site-deploy.sh && ./ops/site-run.sh # build, deploy and run site
./ops/admin-deploy.sh && ./ops/admin-run.sh # build, deploy and run admin
./ops/prisma-upload.sh # upload prisma folder with migrations to server
./ops/cli-deploy.sh # upload cli to server
Modern CSS is quite cool. Nesting, custom media, container queries. All that was used here before, but required cargo-leptos fork. As well another cli step to bundle everything into one css. For now returning to SASS. Considering return back to CSS if/when cargo-leptos will support lightningcss config and bundling.
Sass PR https://github.com/alexichepura/lapa/pull/24. Ligntningcss bundle with cli proof of concept https://github.com/alexichepura/lapa/pull/23.
How initial migration created https://www.prisma.io/docs/guides/migrate/developing-with-prisma-migrate/add-prisma-migrate-to-a-project
mkdir -p prisma/migrations/0_init
cargo prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > prisma/migrations/0_init/migration.sql
cargo prisma migrate resolve --applied 0_init
This project is licensed under the terms of the MIT license.