Skip to content

Repository files navigation

axum-cqrs-rust

Tech stack

  • Rust
  • Axum
  • MariaDB
  • Redis
  • Docker

Architecture

  • CQRS
  • Event Sourcing

You can see the architecture for more details.

How to run

  1. Run the devcontainer.
  2. Then, start the server with the following command:
cargo run --bin main

Or, you can use the watch script to automatically restart the server when you make changes to the code:

./watch.sh

Database Management Tools

When running the devcontainer, the following database management tools are automatically available:

phpMyAdmin (MySQL/MariaDB)

Access at: http://localhost:8081

Redis Commander (Redis)

Access at: http://localhost:8082

API Usage

check version to see if the server is running

curl -X GET http://127.0.0.1:8080/version

create

curl -X POST \
  -H "Content-Type: application/json" \
  -d '{
        "circle_name": "awesome music club",
        "capacity": 10,
        "owner_name": "John Lennon",
        "owner_age": 21,
        "owner_grade": 3,
        "owner_major": "Music"
      }' \
  http://127.0.0.1:8080/circle

find

curl -X GET http://127.0.0.1:8080/circle/HlPI7rLpLP5NqHNIecdtQVwpv4kCYfDF2PrE

find all

curl -X GET http://127.0.0.1:8080/circle

update

curl -X PUT \
  -H "Content-Type: application/json" \
  -d '{
        "circle_name": "football club",
        "capacity": 15,
        "version": 2
      }' \
  http://127.0.0.1:8080/circle/wMenk0sdVDfQ5cvcqDOs3ubmXVeJ3aXs6Pbu

References