• Stars
    star
    120
  • Rank 295,983 (Top 6 %)
  • Language
    Rust
  • Created almost 3 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An example of web application by using Rust and Axum with Clean Architecture.

stock-metrics

Stock price and stats viewer.

Getting Started

Middleware

Launch the middleware by executing docker compose:

cd local-middleware
docker compose up -d

This app now takes advantage of the following tools:

  • MySQL
  • DynamoDB (future)

Setting up database tables

Please run SQLs in migrations directory. up.sql can be up tables, down.sql removes them.

Run the app

cargo run

After running the command, you can see tracing logs.

    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/bootstrap`
2021-12-21T13:49:54.407374Z  INFO stock_metrics_driver::startup: Server listening on 127.0.0.1:8080

Architecture

This example has 4 workspaces as following:

  • stock-metrics-driver (driver or controller)
  • stock-metrics-app (app or usecase)
  • stock-metrics-kernel (kernel or domain)
  • stock-metrics-adapter (adapter or infrastructure)

The upper side in this list is to be an upper layer, the lower ones are to be a lower layer. The upper layers can call or use the lower ones but the opposite calling isn't allowed. For instance, the driver layer can call the app layer's modules but the app layer cannot call the driver layer's modules.

DIP (Dependency Inversion Principle) is applied between kernel and adapter layer. For example, the kernel layer's repositories have just definitions of traits, these implementations are in the adapter layer. As a sample, StockViewRepository and DatabaseRepositoryImpl<Stock> help us understand that.

The driver layer has only around Axum's definition. Axum's Router, handler and launching the server. Things around definitions and settings for web applications have to be defined within this layer.

The app layer has a so-called "use case" layer (in the context of clean architecture). The layer controls the entire application process and logic has to be defined in the range of this layer.

The kernel layer has a so-called "domain" layer (in the context of clean architecture as well). This layer is the core context of the application. For instance, calculators for stock stats have to be described within this layer.

The adapter layer has around infrastructure's concerns. This layer can connect and access outside middlewares, services or APIs. The access and connection processes have to be bounded in this layer.

More Repositories

1

learning-systems-programming-in-rust

「Rustでもわかるシステムプログラミング」
Rust
400
star
2

sabi

Rust programming, in Japanese
Rust
70
star
3

rust-webapp-tutorial

Rust
29
star
4

rust-basic-handson

Used for a workshop took place at Eureka, inc. on 16th, July
Rust
23
star
5

book-algorithm-solution

『アルゴリズムとデータ構造』(大槻兼資著、秋葉拓哉監修; 講談社)という本を Python で書き直しているプロジェクトです。
Python
18
star
6

rusty-monad

An implementation for Monad in Rust as a prototype
Rust
16
star
7

blockchain-in-rust

Rust
16
star
8

cpu-4bit-emulator

Reinventing the wheel.
Rust
14
star
9

simple-http-server

Simple HTTP Server written in Rust
Rust
8
star
10

dotfiles

Lua
8
star
11

cloud-storage-emulator

Rust
6
star
12

sandbox

A sandbox project for me. Learning new programming languages, libraries, tools and etc.
Rust
6
star
13

readygo

Instant setup tool to start new Go project
Go
6
star
14

statemachine-rs

Zero dependency state machine implementation for Rust
Rust
6
star
15

connpass-rs

Rust
5
star
16

simple-http-serverj

An non-blocking http server written in Java with java.nio.
Java
4
star
17

conventional-release-note

Create a release note with conventional commits
TypeScript
3
star
18

risc-v-emu

RISC-V emulator written in Rust
Rust
3
star
19

weekend-dns-resolver-rs

A tiny trial of DNS resolver written in Rust
Rust
3
star
20

mikanos-helloyuki

My MikanOS
3
star
21

simple-interpreter-rs

Rust
3
star
22

cmdrss

Rust
3
star
23

lsh-rs

Simple shell implementation written in Rust
Rust
3
star
24

embeded-rust-handson

Rust
3
star
25

toytcp

Minimum TCP implementation written in Rust
Rust
2
star
26

zenndev

2
star
27

kotlin-analyzer

A Kotlin compiler front-end for IDEs (totally experimental for now)
Kotlin
2
star
28

vscalatags

Associate ScalaTags with Vue.js directives and attributions.
Scala
2
star
29

my-robinson

Rust
2
star
30

introduction-to-aws-networking-with-terraform

An exercise with terraform. The tutorial is in a Japanese book titled 『Amazon Web Services 基礎からのネットワーク&サーバー構築』(第 3 版).
HCL
2
star
31

functional-domain-modeling

"Functional and Reactive Domain Modeling"
Scala
2
star
32

scala-hindley-milner

Hindley-Milner type inference implementation written in Scala
Scala
1
star
33

serde-example

Rust
1
star
34

project-euler

Rust
1
star
35

programming-bitcoin

Rust
1
star
36

rocket-errors

A crate that can handle `anyhow` and `eyre` on Rocket v0.5+
Rust
1
star
37

seaql-examples

Rust
1
star
38

toy-lang

"Toys" language rewritten in Rust
Rust
1
star
39

minituna-rs

Rust
1
star
40

easy-learn-clean-architecture

Go
1
star
41

twitter-cache

An utility library for twitter/util/util-cache.
Scala
1
star
42

obscura

My experimental project building my own toy browser.
Rust
1
star
43

rust-app-example

web application server-side example with DDD-like architecture in Rust
Rust
1
star
44

scratch-io-monad

An educational project for understanding cats' IO monad.
Scala
1
star
45

async-rocket-example

Rust
1
star
46

rstest-example

Rust
1
star