Skip to content

akachida/vertical-slice-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vertical Slice Architecture with Rust

This is an example on how to implement the Vertical Slice Architecture, plus a basic CQRS, using Rust language. It's a simplistic way to do it, only to provide a little directions on how you can do it and use it as a template to start a web api project.

Tests

You can add an RUST_LOG=debug before the command to see more informations about the tests

Running integration tests:

cargo test --package backend-api --test tests --all-features

Running unit tests:

cargo test --package backend-api --lib --all-features

Useful commands

Running the API with debug logging:

RUST_LOG=debug cargo run

Create new migrations

sea-orm-cli migrate generate name_of_migration

...and then move the migration to a specific DB type folder

Updating database

The migrations are automatically runned by the application at startup but you can use:

DATABASE_URL={connection_string} sea-orm-cli migrate up

Revert a migration

DATABASE_URL={connection_string} sea-orm-cli migrate down

Generate a new entity

sea-orm-cli generate entity -s public -u {connection_string} -o ./entity/src -v

TO-DO API

  • server side securities
    • removing legacy headers
    • adding security headers
    • JSON parser
  • architecture
    • CQRS
    • ORM
    • RESTful
    • Logging -> Events, warnings, errors
  • authentication
    • login
    • validate jwt
    • refresh token
  • users
    • Create
    • Read
    • Update
    • Delete
  • gallery
    • Create
    • Read
    • Update
    • Delete
    • Ordering
  • photos
    • Create
    • Read
    • Update
    • Delete
    • Ordering

TO-DO Features

  • Docker
  • Better custom errors
  • Better error handling
  • Middlewares (Error handling, Auth, Validations...)
  • Separate C/Q validations from C/Q Handlers
  • Documentation

Give it a try (improvements)

  • Try GraphQL
  • Try some events
  • Try some crosscutting (MQ, Storage, Functions...)
  • Try scheduled tasks and recurrent jobs
  • Try some cache (noSQL, Redis or something)

About

Vertical Slice Architecture with Rust

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages