GithubHelp home page GithubHelp logo

rust-template's Introduction

Rust template

A lightweight and flexible project template built with cargo generate. This template is designed to simplify the creation of projects that apply a Vertical Slice Architecture.

Table of Contents

Quick Start

cargo install cargo-generate

Create a new project

cargo generate --git https://github.com/MYuitsu/rust-template

Answer the prompts and a new project will be created.

Installation

  • Install Rust
  • Run cargo run to build and run service
  • Install cargo-make
  cargo install cargo-make

Structure of Project

project_root/
│
├── src/
│   ├── main.rs                             // Entry point for the application
│   ├── app.rs                              // Application setup and configuration
│   ├── config.rs                           // Configuration-related structures and functions
│   ├── slices/                             // Vertical slices of the application
│   │   ├── feature_x/                      // A feature slice (e.g., users, orders, etc.)
│   │   │   ├── commands/                   // CQRS commands for the feature
│   │   │   │   ├── create_command.rs        
│   │   │   │   ├── create_command_handler.rs        
│   │   │   ├── queries/                    // CQRS queries for the feature
│   │   │   │   ├── get_by_id.rs        
│   │   │   │   ├── get_by_id_handler.rs        
│   │   │   ├── endpoints.rs                // Axum endpoints for the feature
│   │   │   ├── models.rs                   // Domain models for the feature
│   │   │   ├── traits.rs                   // Domain models for the feature
│   │   │   ├── services.rs                 // Business logic for the feature
│   │   │   ├── repository.rs               // Repository for the feature
│   │   │   ├── validators.rs               // Validators for the feature
│   │   │   ├── messages.rs                 // Messages for the feature
│   │   │   ├── tests/                      // Tests for the feature
│   │   │   │   ├── unit_tests.rs      
│   │   │   │   ├── integration_tests.rs      
│   │   ├── feature_y/                      // Another feature slice
│   │   │   ├── ....
│   │
│   ├── infrastructure/                     // Infrastructure concerns
│   │   ├── migrations/                     // Database migrations
│   │   │   ├──yyyyddmm-hhMMss-create.sql   // Migration SQL script
│   │   ├── database.rs                     // Database connection and management
│   │   ├── auth.rs                         // Integration for authentication
│   │   ├── monitoring.rs                   // Monitoring setup (e.g., Prometheus, Grafana)
│   │   └── ...
│   │
│   ├── middleware/                         // Custom middleware for logging, tracing, etc.
│   │   ├── logging.rs
│   │   ├── tracing.rs
│   │   ├── metrics.rs                      // Custom middleware for metrics collection
│   │   └── ...
│   │
│   └── utils/                              // Utility modules
│       └── ...
│
├── Cargo.toml                              // Rust package manifest
├── Makefile.toml                           // Makefile for project
├── Cargo.lock                              // Lock file for dependencies
└── .env                                    // Environment variables for local development

The Goals of This Project

Monolithic application

  • Using Vertical Slice Architecture for architecture level.
  • Using Test Driven Development (TDD) for all business processes.

Plan

This project is a work in progress

Feature Status
Connect to DB In Progress

Technologies - Libraries

cargo-make

  • cargo-make - Build automation tool for Cargo projects.
  • axum - A web application framework that focuses on ergonomics and modularity.
  • dotenv - Library for loading environment variables from .env files.

Testing

Gathering code coverage

  cargo make coverage

Project References & Credits

License

This project is made available under the MIT license. See LICENSE for details.

rust-template's People

Contributors

myuitsu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.