billymosis / axum-saas-template

Kickstart your SaaS projects with this Rust Axum template! πŸš€ Features include Axum web framework, SQLx for the database (PostgreSQL), and cool authentication stuff. It's all powered by Rust 1.75.0 with the fresh async trait feature. Ready, set, code! πŸ¦€πŸ’» #SaaSTastic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust Axum Saas Template

Minimum Required Rust Version: 1.75.0

async trait

This repository contains a Rust Axum-based web application with SQLx, PostgreSQL database, and authentication features for a SaaS template. Follow the steps below to set up and run the project.

Development Setup

  1. Install sqlx-cli:

    cargo install sqlx-cli
  2. Run the Database Setup Script: Execute the following commands in your terminal:

    ./db.sh
    sqlx-cli db setup
  3. Run the Application:

    cargo run

Building for Production

Ensure that you can successfully run the application in development mode before proceeding.

  1. Run the Build Script:

    ./build.sh
  2. Run Docker Compose:

    docker-compose up

Available Routes

  • Home:

    • Method: GET
    • URL: {{base_url}}/
  • Login Form:

    • Method: GET
    • URL: {{base_url}}/login
  • Login:

    • Method: POST
    • URL: {{base_url}}/api/auth/login
    • Body:
      {
        "email": "{{email}}",
        "password": "{{password}}"
      }
  • Protected Resource:

    • Method: GET
    • URL: {{base_url}}/api/protected
  • Register:

    • Method: POST
    • URL: {{base_url}}/api/auth/register
    • Body:
      {
        "username": "haheho",
        "email": "senpai@mail.com",
        "password": "Doplhin123!"
      }
  • User email verification:

    • Method: POST
    • URL: {{base_url}}/api/auth/verify-email/:token
  • Send Reset Password:

    • Method: POST
    • URL: {{base_url}}/api/auth/reset-password
    • Body:
      {
        "email": "senpai@mail.com"
      }
  • Verify Reset Password:

    • Method: POST
    • URL: {{base_url}}/api/auth/reset-password/:token
    • Body:
      {
        "password": "Dolphin123!"
      }

Variables

  • base_url: Set your base URL.
  • email: Set the email for testing.
  • password: Set the password for testing.

Credits

This project is inspired by and incorporates elements from the following repositories:

  1. Realworld Axum SQLx by David Pedersen
  2. Rust Axum Course by Jeremy Chone
  3. Cargo Chef by Luke Math Walker
  4. Lucia Auth by pilcrow

A big thank you to the contributors of these projects for their valuable insights and code contributions. And chat GPT cause all this message generated by it LOL!

About

Kickstart your SaaS projects with this Rust Axum template! πŸš€ Features include Axum web framework, SQLx for the database (PostgreSQL), and cool authentication stuff. It's all powered by Rust 1.75.0 with the fresh async trait feature. Ready, set, code! πŸ¦€πŸ’» #SaaSTastic

License:MIT License


Languages

Language:Rust 95.3%Language:Dockerfile 2.8%Language:PLpgSQL 1.4%Language:Shell 0.5%