This is a copy of the Github readme.
Find the original on


08. Tutorial to refactor the database_web_ui_on_server (2022-10)
version: 0.1.01 date: 2022-10-10 author: repository: Github

Lines in Rust code Lines in Doc comments Lines in Comments Lines in examples Lines in tests

License Rust Hits

Hashtags: #rust #rustlang #tutorial
My projects on Github are more like a tutorial than a finished product: bestia-dev tutorials.


In the last tutorial we created a working prototype for a web application that can create, read, update and delete (CRUD) data in a postgres database. The user interface is server side rendered as html5 and css3. The code is pretty basic and repetitive, because the main focus was on concepts, tools, libraries and data flow. We will continue to develop this project in the 8th part of the Rust tutorial series. We will refactor this web app to deduplicate code and make it more idiomatic Rust.

This project has also a youtube video tutorial. Watch it:


The first function of software is to solve a problem. In this project, the user can read and write data in a database simply using a browser.
The second main function of software is maintainability. Software will always with no exception need to be updated or upgraded for any reason. When we write our source code, we want to make it easier and less error-prone to make changes later.
Rust is the champion of fearless refactoring. The strict type system warns the developer immediately if he forgets something. And I assure you, that happens a lot.

Separate code

Every programming language have a way to separate code into logical modules. If that does not exist, we can still use names by prefixing them with a namespace. That will also work. This distinction is just for the human brain to reason about one problem at a time. The computer itself does not need to know about this separation.
Our project is 3-tier and it is not a single coherent project, not even the same programming language. If we want to understand easily how the data flows from one project to the other, it is smart to give items the same name everywhere. We can then use the simple "Find text" tool of VSCode to find everything about an item.

Web app name

The project name is long and descriptive because this is a tutorial. But the executable binary can have a more meaningful name like "webpage_hits_admin".
It is enough to rename the folder in "src/bin/" to change the name of the binary. I will also rename the web_server_folder and css file accordingly.
Because of this change, I will change the name inside the automation_task_rs to reflect the new binary name.

cargo crev reviews and advisory

We live in times of danger with supply chain attacks.
It is recommended to always use cargo-crev to verify the trustworthiness of each of your dependencies.
Please, spread this info.
You can also read crev reviews quickly on the web:

open-source and free as a beer

My open-source projects are free as a beer (MIT license).
I just love programming.
But I need also to drink. If you find my projects and tutorials helpful,please buy me a beer donating on my paypal.
You know the price of a beer in your local bar ;-) So I can drink a free beer for your health :-)

Na zdravje! Alla salute! Prost! Nazdravlje! 🍻