Skip to content

Commit a7534af

Browse files
chore: update deps; (#106)
1 parent 45f7899 commit a7534af

File tree

8 files changed

+624
-683
lines changed

8 files changed

+624
-683
lines changed

ARCHITECTURE.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
# Architecture
33

4-
Table of content:
4+
Table of contents:
55

66
* [Overview](#overview)
77
* [How it works](#how-it-works)
@@ -15,61 +15,61 @@ Table of content:
1515

1616
## Overview
1717

18-
The general info about this project you can read in the [README.md](https://github.com/TheBestTvarynka/crypto-helper/blob/main/README.md) file. In this document, you will find a more detailed explanation of how it works, how we write components, etc.
18+
For general info about this project, you can read in the [README.md](https://github.com/TheBestTvarynka/crypto-helper/blob/main/README.md) file. In this document, you will find a more detailed explanation of how it works, how we write components, etc.
1919

2020
## How it works
2121

2222
> From [README.md](https://github.com/TheBestTvarynka/crypto-helper/blob/main/README.md):
2323
>
2424
> Written in [Rust](https://github.com/rust-lang/rust) :crab: using [yew](https://github.com/yewstack/yew) :sparkles:
2525
26-
So, as you can already guess, the Rust code is compiled into [WASM](https://en.wikipedia.org/wiki/WebAssembly) using [trunk](https://trunkrs.dev) and then executes on the client side in the browser. It also means that any heavy computation will affect the client browser performance and can even freeze it (for example, `bcrypt` with 20 rounds).
26+
So, as you can already guess, the Rust code is compiled into [WASM](https://en.wikipedia.org/wiki/WebAssembly) using [trunk](https://trunkrs.dev) and then executed on the client side in the browser. It also means that any heavy computation will affect the client's browser performance and can even freeze it (for example, `bcrypt` with 20 rounds).
2727

2828
The compiled app looks like a bunch of files (`.html`, `.css`, `.wasm`, `.js`). All these files are just served in the user's browser.
2929

3030
### Why [`yew`](https://github.com/yewstack/yew)?
3131

32-
Because it's a great framework for building web applications in Rust. It is very familiar to [`React.js`](https://react.dev) devs. The only disadvantage I've seen is styling: yew doesn't have any good tools/libraries for styling at this moment. At this moment, all styles are written in `.scss` files. Classes are used in components via the [`classes!`](https://docs.rs/yew/latest/yew/macro.classes.html) macro.
32+
Because it's an excellent framework for building web applications in Rust, it is very familiar to [`React.js`](https://react.dev) devs. The only disadvantage I've seen is styling: `yew` doesn't have any good tools/libraries for styling at this moment. At this moment, all styles are written in `.scss` files. Classes are used in components via the [`classes!`](https://docs.rs/yew/latest/yew/macro.classes.html) macro.
3333

3434
### So, what do we have:
3535

36-
* [Rust](https://www.rust-lang.org/) is the main programming language in this project. It allows us to write highly maintained code with less amount of bugs.
36+
* [Rust](https://www.rust-lang.org/) is the primary programming language in this project. It allows us to write highly maintainable code with fewer bugs.
3737
* Fast computations thanks to the [WASM](https://en.wikipedia.org/wiki/WebAssembly).
3838

3939
## Code style
4040

41-
1. We use the custom [`rustfmt.toml`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/rustfmt.toml) configuration. If you want to change some formatting options then create a pull request with changes and an explanation of your motivation, how it'll help us, etc.
41+
1. We use the custom [`rustfmt.toml`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/rustfmt.toml) configuration. If you want to change some formatting options, create a pull request with your changes and an explanation of your motivation and how it'll help us.
4242
2. All code must be formatted using the `cargo fmt`. Run `cargo +nightly fmt --all -- --check`.
43-
3. All build and clippy warnings must be fixed. Run `cargo clippy -- -D warnings`.
43+
3. All build and Clippy warnings must be fixed. Run `cargo clippy -- -D warnings`.
4444

4545
## Components
4646

4747
We have three main groups of components (divided by purpose):
4848

49-
1. General purpose components.
49+
1. General-purpose components.
5050
2. Crypto-helper related components.
51-
3. Jwt related components.
51+
3. JWT-related components.
5252
4. Other components.
5353

54-
### General purpose components
54+
### General-purpose components
5555

56-
Those components can be used on any app page and located in the [`src/common`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/common) directory. They are small, without side effects, and have only one special purpose. Examples:
56+
Those components can be used on any app page and located in the [`src/common`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/common) directory. They are small, side-effect-free, and have only one special purpose. Examples:
5757

58-
* [`ByteInput`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/src/common/byte_input.rs). This component is used for the bytes entering. You can use it in any place where you need to take any input bytes from the user. It automatically supports many input formats, validation, etc.
58+
* [`ByteInput`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/src/common/byte_input.rs). This component is used for the bytes entering. You can use it anywhere you need to read input bytes from the user. It automatically supports many input formats, validation, etc.
5959

6060
![](/public/img/architecture/bi_1.png) ![](/public/img/architecture/bi_2.png) ![](/public/img/architecture/bi_3.png)
61-
* [`Switch`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/src/common/switch.rs). Just a regular switch. Can be used to switch between any two options. For example, `encrypt <-> decrypt`, `hash <-> verify`, etc.
61+
* [`Switch`](https://github.com/TheBestTvarynka/crypto-helper/blob/main/src/common/switch.rs). Just a regular switch. It can be used to switch between any two options. For example, `encrypt <-> decrypt`, `hash <-> verify`, etc.
6262

6363
![](/public/img/architecture/s1.png) ![](/public/img/architecture/s2.png)
64-
* There are and will be more common components. The above two are just examples. **If some component was purpose specialized during creation but become common, then it should be moved in the [`src/common`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/common) directory.**
64+
* There are and will be more common components. The above two are just examples. **If some component was purpose-specialized during creation but became common, then it should be moved to the [`src/common`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/common) directory.**
6565

6666
### Crypto-helper related components
6767

6868
In short: all components from the [`src/crypto_helper`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/crypto_helper) directory belong to this group. Here are the input/output components for the different algorithms, computations, etc.
6969

7070
If some components will be used only on the `/crypto-helper` page, then they should be placed somewhere in the [`src/crypto_helper`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/crypto_helper) directory.
7171

72-
### Jwt related components
72+
### Jwt-related components
7373

7474
In short: all components from the [`src/jwt`](https://github.com/TheBestTvarynka/crypto-helper/tree/main/src/jwt) directory belong to this group. Here are the input/output components for the JWT, its parts parsing/editing/viewing, etc.
7575

@@ -83,9 +83,9 @@ The `About` page, `Header`, `Footer`, etc.
8383

8484
1. Validate on input.
8585

86-
Components that take some input from the user usually have their validation rules. For example, the `ByteInput` component with the `ByteFormat::Hex` parameter will require only hex-encoded bytes from the user.
86+
Components that take user input usually have validation rules. For example, the `ByteInput` component with the `ByteFormat::Hex` parameter will require only hex-encoded bytes from the user.
8787

88-
In the app state, we save only validated/parsed data. If the user enters an invalid string, then inform about it. But do not save raw `String` or smth like that in the state. If you look at the `Algorithm` enum, you can see that all input data for algorithms save in a "parsed" state:
88+
In the app state, we save only validated/parsed data. If the user enters an invalid string, inform them. But do not save raw `String` or smth like that in the state. If you look at the `Algorithm` enum, you can see that all input data for algorithms is saved in a "parsed" state:
8989

9090
```rust
9191
// some fields and structures are omitted
@@ -111,13 +111,13 @@ You won't find any raw Strings. Bytes for hashing/encryption are `Vec<u8>` (not
111111

112112
2. Logging.
113113

114-
This app has a simple and typical logging system: [`wasm-logger`](https://crates.io/crates/wasm-logger) + [`log`](https://crates.io/crates/log) crates. If you want to log something, then just use any suitable for you macros from the `log` crate. All logs will be written into the browser's console. This is how it looks:
114+
This app uses a simple, typical logging system: [`tracing-web`](https://docs.rs/tracing-web/latest/tracing_web/) and [`tracing`](https://docs.rs/tracing/latest/tracing/). If you want to log something, then use any suitable macros from the `tracing` crate. All logs will be written into the browser's console. This is how it looks:
115115

116116
![](/public/img/architecture/logs_exmaple.png)
117117

118-
3. Inform user about everything.
118+
3. Inform the user about everything.
119119

120-
You have two main ways how to tell the user that something went wrong:
120+
You have two main ways to tell the user that something went wrong:
121121

122122
* Spawn notifications using the [`use_notifications`](https://yn-docs.qkation.com/yew_notifications/fn.use_notification.html) hook from the [`yew_notifications`](https://github.com/TheBestTvarynka/yew-notifications) crate.
123123
* Different UI tricks like painting the input component in red, on-page messages, etc. Example:

0 commit comments

Comments
 (0)