Uchat is a revolutionary full-stack chat app built completely on Rust, while leveraging the capabilities of WASM.
Ethereum wallet connect is live — sign up or log in with MetaMask (or any EIP-6963-compatible wallet) via sign-in-with-Ethereum, no password required. Ethereum Mainnet only; the app prompts a network switch if a different chain is detected.
Demo video is available here
The design/ directory contains some design-related files and assets used throughout the project.
If you are on Windows, using WSL is highly recommended to manage build dependencies and tooling.
If you haven't installed Rust yet, you can do so using rustup and then install cargo.
Compiling Rust for the browser requires adding the wasm32 compilation target:
rustup target add wasm32-unknown-unknownThis project uses PostgreSQL for the database. Please follow the official instructions for how to install PostgreSQL on your system. Alternatively, you can use a managed database like Supabase (see the Deployment section below).
Trunk is a tool to build and bundle Rust WASM applications. Install it with:
cargo install --locked trunk
# Apple M1/M2/M3 users may also need to install this:
cargo install --locked wasm-bindgen-cliDiesel is a Rust SQL query builder and ORM for working with the database.
Ensure you have PostgreSQL installed locally (or its development libraries) before proceeding.
Install the Diesel CLI with:
cargo install diesel_cli --no-default-features --features postgresNote: If you receive build or linker errors, make sure you install
libpq. This may be packaged separately depending on your operating system and package manager (e.g.,libpq-devon Ubuntu/WSL).
Create a .env file in the workspace directory containing:
API_DATABASE_URL="postgres://DATABASE_USER:PASSWORD@localhost/uchatfinal"
API_PRIVATE_KEY="API_PRIVATE_KEY_HERE"
API_URL="http://127.0.0.1:8070/"
API_BIND="127.0.0.1:8070"
# Development only
DATABASE_URL="postgres://DATABASE_USER:PASSWORD@localhost/uchatfinal"
TEST_DATABASE_URL="postgres://DATABASE_USER:PASSWORD@localhost/uchatfinal_test"
FRONTEND_URL="http://127.0.0.1:8080"Substitute the following:
DATABASE_USER: Role created to access PostgreSQLPASSWORD: Your password to login to the database (omit:PASSWORDif not using a password)
After the .env is ready, run this command to create the database:
diesel setupThe server needs an RSA private key (used to sign session tokens). Generate one with the built-in CLI subcommand:
cargo run --bin api -- gen-keyThis writes a base64-encoded key to private_key.base64 in the current directory. Copy its contents into your .env as the value for API_PRIVATE_KEY.
Note: If
API_PRIVATE_KEYis not set, the server will generate an ephemeral key on startup and log a warning — existing sessions will not survive a restart. Set the variable for persistent sessions.
This project uses Tailwind CSS for utility classes.
You will need Node.js and npm installed to use the npx command for Tailwind.
just is a handy command runner which simplifies running different development commands. Install it with:
cargo install justAvailable Recipes:
| Command | Description |
|---|---|
just init |
Sets up project dependencies and installs npm packages. |
just serve-all |
Runs both the frontend and backend development servers concurrently. |
just serve-pro-all |
Runs the frontend and backend in highly optimized release mode. |
just test |
Runs the test suite using cargo nextest. |
just build |
Builds the frontend and backend in release mode for production. |
just check |
Runs cargo check for both frontend (WASM) and backend targets. |
just clippy |
Runs the cargo clippy linter across the entire codebase. |
just fix |
Auto-fixes standard linting issues across the codebase. |
just db-migrate |
Runs pending database migrations and resets the test database. |
just db-reset |
Wipes and resets the entire PostgreSQL database. |
just db-new-migration <NAME> |
Generates a new blank database migration. |
just doc |
Builds and optionally opens the Rust project documentation. |
just sweep |
Cleans up old cargo build artifacts to free up disk space. |
This will check for the dependencies listed above and attempt to install the required Rust dependencies. It will provide installation links for dependencies that require manual installation.
cargo run -p project-initTo build the documentation:
cargo doc -F docbuild(Note: Enabling the docbuild feature is a temporary workaround for a minor bug in a transitive dependency.)
To run a development server for the frontend and open a new browser window:
trunk serve --openTo run the backend server:
cargo run -p uchat_serverCheck the frontend and backend targets:
cargo check -p frontend --target wasm32-unknown-unknown
cargo check --workspace --exclude frontendRun clippy for the frontend and backend targets:
cargo clippy -p frontend --target wasm32-unknown-unknown
cargo clippy --workspace --exclude frontendThis project uses cargo-nextest as a faster, more robust test runner.
-
Install nextest (if you haven't already):
cargo install cargo-nextest --locked
-
Run the test suite: The test suite includes full-stack integration tests (such as simulating a user logging in and creating a post) as well as data validation unit tests. You can run all tests across the workspace with:
cargo nextest run
(Note: The
TEST_DATABASE_URLenvironment variable in your.envmust be configured properly to run the integration tests).
To build the project for distribution:
trunk --config Trunk-release.toml build
cargo build --release --workspace --exclude frontendTo run the production build locally:
Frontend:
trunk serve --release --config Trunk-release.tomlBackend:
Navigate to target/release/ and run the executable:
cd target/release/
./apiTo create new database migrations, run:
diesel migration generate MIGRATION_NAMEThis creates a new folder in data/migrations/timestamp_MIGRATION_NAME/. Add your SQL for applying the migration to up.sql and the SQL for reverting it to down.sql.
Apply the migration with:
diesel migration runTo verify your down.sql works, run this command to revert and then reapply the migration:
diesel migration redoAfter creating a new migration, you may want to delete the testing database:
psql -d postgres -c 'DROP DATABASE IF EXISTS uchat_test;'This project's architecture is fully decoupled, making it perfectly suited for modern "best-of-breed" free-tier hosting platforms.
We recommend using Neon.tech for a Serverless PostgreSQL database.
- Create a new free tier project on Neon.
- Retrieve your Connection String (it will look like
postgres://username:password@.../neondb). - Run your migrations against this database locally:
DATABASE_URL="<your-neon-connection-string>" diesel migration run
(Alternatively, you can also use Supabase following a similar process).
Render.com provides native Rust build environments without needing a Dockerfile.
- Create a new Web Service on Render and connect your GitHub repository.
- Configure the build settings:
- Language/Environment: Rust
- Build Command:
cargo build --release -p uchat_server - Start Command:
./target/release/api
- Under Environment Variables, add the following:
API_DATABASE_URL: (Your Neon Connection String)API_BIND:0.0.0.0:10000PORT:10000FRONTEND_URL:https://your-frontend-app.netlify.app(Must match your Netlify domain exactly, without a trailing slash)
- Click Deploy.
Netlify will automatically build the Trunk WebAssembly frontend and serve it over a global CDN.
- Connect your repository to Netlify. Netlify will automatically detect the
netlify.tomlfile and its build configuration. - Go to Site Settings > Environment Variables and add:
API_URL:https://your-backend-app.onrender.com/(Make sure to include the trailing slash if required by your API client)
- Trigger a manual deploy in the Deploys tab to ensure the environment variable is injected during the build process.
(Note: The netlify.toml file is configured to create an empty .env file during the build process to satisfy the load_dotenv!() macro requirements without needing to commit your secrets).