|
| 1 | +# Architecture |
| 2 | + |
| 3 | +Valens is a web application built using the __Hexagonal Architecture__ pattern with a __Rust-based frontend__ compiled to WebAssembly and a __Python-based backend__. |
| 4 | + |
| 5 | +## Frontend ([`crates/`](../crates)) |
| 6 | + |
| 7 | +Rust-based progressive web application (PWA) compiled to WebAssembly. |
| 8 | + |
| 9 | +### [`domain`](../crates/domain) |
| 10 | + |
| 11 | +Core business logic and interfaces. |
| 12 | + |
| 13 | +- Defines entities and services |
| 14 | +- Specifies the storage interfaces (ports) |
| 15 | +- Is completely independent of the rest of the web app |
| 16 | +- Has no hard dependencies on other crates except for essential functionality |
| 17 | +- Provides no serialization of entities |
| 18 | +- Is fully covered by tests |
| 19 | + |
| 20 | +### [`storage`](../crates/storage) |
| 21 | + |
| 22 | +Storage adapters. |
| 23 | + |
| 24 | +- Handles data storage on the server and in the browser (IndexedDB, Web Storage) |
| 25 | +- Implements repositories defined in `domain` and `web-app` |
| 26 | + |
| 27 | +### [`web-app`](../crates/web-app) |
| 28 | + |
| 29 | +Framework-agnostic UI logic. |
| 30 | + |
| 31 | +- Provides logic reusable across different frontend frameworks |
| 32 | +- Uses business logic provided by `domain` |
| 33 | + |
| 34 | +### [`web-app-seed`](../crates/web-app-seed) |
| 35 | + |
| 36 | +Framework-specific UI logic using Seed. |
| 37 | + |
| 38 | +- Defines the entry point of the web application |
| 39 | +- Implements rendering, event handling and routing |
| 40 | +- Integrates `domain`, `web-app` and `storage` |
| 41 | + |
| 42 | +### Dependencies |
| 43 | + |
| 44 | +```mermaid |
| 45 | +graph RL |
| 46 | + WAS[web-app-seed] |
| 47 | + WA[web-app] |
| 48 | + S[storage] |
| 49 | + D[domain] |
| 50 | + WAS --> D & S & WA |
| 51 | + WA --> D |
| 52 | + S --> D & WA |
| 53 | +``` |
| 54 | + |
| 55 | +## Backend ([`valens/`](../valens)) |
| 56 | + |
| 57 | +Python-based server application. |
| 58 | + |
| 59 | +- Provides a REST API using Flask |
| 60 | +- Stores data in a SQLite database |
| 61 | +- Enables WSGI-compatible deployment |
| 62 | + |
| 63 | +## Architectural Principles |
| 64 | + |
| 65 | +Valens follows the Hexagonal Architecture pattern. |
| 66 | + |
| 67 | +- Domain logic is isolated from external concerns (UI, storage, network). |
| 68 | +- Adapters implement interfaces (ports) to interact with the core logic. |
| 69 | +- Components are modular and independently testable. |
0 commit comments