Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture

This document specifies the architectural decisions of the serverwiz app.

High-level overview

graph TB
  A[ServerwizApplication] -- Injects --> B[Adapter] -- Into -->
    C[Use case] -- Calls --> D[Port]

Main

The main.rs file should only include presentation logic.

For reference: the current main.rs in the main branch:

{{#include ../../../serverwiz/src/main.rs}}

Lib

The lib.rs file should only inject dependencies to use cases and transfer calls from main.rs to use cases. For this it uses a ServerwizApplication struct.

For reference: the current lib.rs in the main branch:

{{#include ../../../serverwiz/src/lib.rs}}

It also serves the standard rust purpose of being the highest level module.

Hexagonal Architecture

The main paradigm serverwiz uses as the architectural base is hexagonal architecture. This architecture splits the logic into three separate layers: domain, ports and adapters, in which three separate types of structures are made: use cases, ports and adapters respectively.

Use cases

Use cases are domain-level structs that are independent of any dependencies. They call adapters to retrieve data and perform business logic on that data. Use cases should not be aware of the specific adapter they are calling, instead the adapter should be abstracted behind a port contract.

Ports

Ports are abstract contracts that define the expected functionality of an adapter.

Adapters

Adapters implement port contracts and are injected into use cases by the ServerwizApplication struct.