/axum-diesel-real-world

The goal of this repository is to have a real world template of a Rust backend using Axum, Diesel, etc.

Primary LanguageRustMIT LicenseMIT

Axum Diesel Real-World Example

GitHub stars GitHub license GitHub issues

A modular Rust backend template based on the Domain-Driven Design (DDD) architecture, utilizing the Axum and Diesel frameworks. This repository serves as a starting point for building real-world applications in Rust, with different modules and frameworks to choose from.

Table of Contents

Introduction

This repository provides a boilerplate for developing Rust backend applications following the principles of Domain-Driven Design (DDD). It leverages the power of Axum for building asynchronous APIs and Diesel for working with databases.

Features

  • Domain-Driven Design (DDD) architecture.
  • Integration with Axum for building asynchronous APIs.
  • Integration with Diesel for database operations.
  • Modular project structure for easy extension and maintainability.
  • Authentication modules with OAuth (optional).

Getting Started

Follow these steps to get started with your Rust backend project based on this template:

  1. Clone this repository:

    git clone https://github.com/Quentin-Piot/axum-diesel-real-world.git
  2. Choose a specific module/framework branch or work with the default configuration.

  3. Customize the project to your needs.

  4. uild and run your Rust backend:

    cargo run

Project Structure

The project follows a modular structure to keep your code organized and maintainable. Here's a brief overview of the project structure:

  • src/: Contains the main source code of your application.

    • domain/: Define your domain logic using DDD principles.
      • models/: Define your domain models.
    • handlers/: Define your API handlers.
    • infra/: Define your infrastructure logic.
      • db/: Define your database logic.
      • repositories/: Define your repositories.
    • utils/: Define your utility functions.
      • custom_extractors/: Define your custom extractors for Axum.
    • main.rs: Application entry point.
    • routes.rs: Define your API routes.
    • config.rs: Define your application configuration : use OnceCell for static config file.
    • error.rs: Define your custom global error types.
  • migrations/: Database migration files for Diesel (if applicable).

License

This project is licensed under the MIT License.