https://github.com/zahash/fullstack
solidjs + axum
https://github.com/zahash/fullstack
Last synced: 10 months ago
JSON representation
solidjs + axum
- Host: GitHub
- URL: https://github.com/zahash/fullstack
- Owner: zahash
- License: mit
- Created: 2024-09-10T14:55:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-01T11:07:03.000Z (10 months ago)
- Last Synced: 2025-08-01T13:37:40.635Z (10 months ago)
- Language: Rust
- Size: 761 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fullstack Workspace
This is a monorepo containing a fullstack application with Rust (backend, WASM) and SolidJS (frontend) components.
## Prerequisites
- [Rust](https://www.rust-lang.org/tools/install)
- [Node.js](https://nodejs.org/) (for frontend)
- [wasm-bindgen-cli](https://rustwasm.github.io/wasm-bindgen/reference/cli.html) `cargo install wasm-bindgen-cli`
- [sqlx-cli](https://crates.io/crates/sqlx-cli) `cargo install sqlx-cli`
- [mailtutan](https://github.com/mailtutan/mailtutan) `cargo install mailtutan`
### Email Testing (Mailtutan)
To test email functionality locally, you can use [mailtutan](https://github.com/mailtutan/mailtutan), a simple SMTP server for development
```sh
mailtutan --ip 127.0.0.1
```
This will start a local SMTP server on port 1025 by default. Configure your `.env` or server launch to use `127.0.0.1:1025` as the SMTP relay.
## Frontend (SolidJS) setup
```sh
cd ui
npm install
```
### Start the development server
```sh
npm run dev
```
### Build for production
```sh
npm run build
```
The output will be in the `ui/dist` folder.
## Backend (Rust) Setup
### Database
**Important:**
There is a chicken-and-egg problem: the SQLite database is expected in the `target` directory, but that directory does not exist until the codebase is built. However, building the codebase (with sqlx in online mode) requires the database to be present and `DATABASE_URL` to be set.
**Workaround:**
Manually create the `target` directory before running sqlx commands:
```sh
mkdir target
```
Set the `DATABASE_URL` environment variable (see below), then create the database and run migrations as described.
```sh
sqlx database create -D sqlite://target/data.db
sqlx migrate run --source .\migrations\ -D sqlite://target/data.db
```
### WASM (Rust → JS)
```sh
cargo build -p wasm --target wasm32-unknown-unknown --profile web
wasm-bindgen ./target/wasm32-unknown-unknown/web/wasm.wasm --out-dir ./ui/lib/wasm --target web
```
### Server
```sh
cargo run --bin server
```
## Feature Flags
This workspace uses Cargo feature flags to enable optional functionality in various crates. You can enable features at build or run time using `--features`.
### Server Crate Features
The following features are available for the `server` binary crate:
- **rate-limit**: Enables rate limiting middleware.
- **smtp**: Enables SMTP email sending support (adds `lettre`, `tera`, and `token` dependencies, and enables related features in `lettre`).
- **smtp--no-tls**: Enables SMTP support without TLS (used for testing purposes only).
- **ui**: Enables serving the frontend UI from the backend.
You can enable these features at build or run time using the `--features` flag. For example:
```sh
cargo run --bin server --features smtp,ui,rate-limit
```
Or for a release build:
```sh
cargo build --bin server --release --features smtp,ui,rate-limit
```
The release binary will be in `target/release/server.exe` (Windows) or `target/release/server` (Linux/macOS).
## Deployment
- Backend: Deploy the Rust server as you would any Axum-based service.
- Frontend: Deploy the contents of `ui/dist` as static files.
- WASM: Ensure the generated WASM files are available in the frontend's `lib/wasm` directory.
## Useful Links
- [SolidJS Documentation](https://solidjs.com)
- [Vite Documentation](https://vite.dev/guide/static-deploy.html)
- [Rust WASM Book](https://rustwasm.github.io/book/)