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

Overview

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.

You might also like...
Perlin: An Efficient and Ergonomic Document Search-Engine

Table of Contents 1. Perlin Perlin Perlin is a free and open-source document search engine library build on top of perlin-core. Since the first releas

 Rapidly Search and Hunt through Windows Event Logs
Rapidly Search and Hunt through Windows Event Logs

Rapidly Search and Hunt through Windows Event Logs Chainsaw provides a powerful โ€˜first-responseโ€™ capability to quickly identify threats within Windows

๐Ÿ”Ž A simple in-memory search for collections and key-value stores.
๐Ÿ”Ž A simple in-memory search for collections and key-value stores.

Indicium Search ๐Ÿ”Ž A simple in-memory search for collections (Vec, HashMap, BTreeMap, etc) and key-value stores. Features autocompletion. There are ma

Finding all pairs of similar documents time- and memory-efficiently

Finding all pairs of similar documents This software provides time- and memory-efficient all pairs similarity searches in documents. Problem definitio

Configurable quick search engine shortcuts for your terminal and browser.

Quicksearch Configurable quick search engine shortcuts for your terminal and browser. Installation Run cargo install quicksearch to install Configurat

๐Ÿ’ฐ Midas is a free and open source Moving Average Trading backtest simulator.
๐Ÿ’ฐ Midas is a free and open source Moving Average Trading backtest simulator.

Midas is a free and open source Moving Average Trading backtest simulator Bilibili Video: https://www.bilibili.com/video/BV11o4y1B7fL โš ๏ธ Warning Inves

AI-powered search engine for Rust

txtai: AI-powered search engine for Rust txtai executes machine-learning workflows to transform data and build AI-powered text indices to perform simi

A full-text search engine in rust

Toshi A Full-Text Search Engine in Rust Please note that this is far from production ready, also Toshi is still under active development, I'm just slo

Official Elasticsearch Rust Client

elasticsearch โ€ƒ Official Rust Client for Elasticsearch. Full documentation is available at https://docs.rs/elasticsearch The project is still very muc

Owner
Yuki Toyoda
Software Engineer ๐Ÿ‡ฏ๐Ÿ‡ต; they/them
Yuki Toyoda
๐Ÿ”Ž Impossibly fast web search, made for static sites.

Stork Impossibly fast web search, made for static sites. Stork is two things. First, it's an indexer: it indexes your loosely-structured content and c

James Little 2.5k Dec 27, 2022
weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

weggli Introduction weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify int

Google Project Zero 2k Jan 5, 2023
Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust

Tantivy is a full text search engine library written in Rust. It is closer to Apache Lucene than to Elasticsearch or Apache Solr in the sense it is no

tantivy 7.4k Dec 28, 2022
A full-text search and indexing server written in Rust.

Bayard Bayard is a full-text search and indexing server written in Rust built on top of Tantivy that implements Raft Consensus Algorithm and gRPC. Ach

Bayard Search 1.8k Dec 26, 2022
2 and 3-dimensional collision detection library in Rust.

2D Documentation | 3D Documentation | User Guide | Forum โš ๏ธ **This crate is now passively-maintained. It is being superseded by the Parry project.** โš 

dimforge 914 Dec 24, 2022
Tantivy is a full-text search engine library inspired by Apache Lucene and written in Rust

Tantivy is a full-text search engine library written in Rust. It is closer to Apache Lucene than to Elasticsearch or Apache Solr in the sense it is no

Quickwit OSS 7.5k Jan 9, 2023
A Solr 8+ Client for Rust and Python

Solrstice: A Solr 8+ Client for Rust and Python Solrstice is a SolrCloud aware client library written in rust. It also provides a wrapper to python. U

Andreas H Johansen 4 Aug 26, 2023
A simple and lightweight fuzzy search engine that works in memory, searching for similar strings (a pun here).

simsearch A simple and lightweight fuzzy search engine that works in memory, searching for similar strings (a pun here). Documentation Usage Add the f

Andy Lok 116 Dec 10, 2022
Represent large sets and maps compactly with finite state transducers.

fst This crate provides a fast implementation of ordered sets and maps using finite state machines. In particular, it makes use of finite state transd

Andrew Gallant 1.5k Jan 5, 2023
Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine

MeiliSearch Website | Roadmap | Blog | LinkedIn | Twitter | Documentation | FAQ โšก Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine ?? M

MeiliSearch 31.6k Dec 31, 2022