Mangrove Manager

Table of contents

🚧Project in progress🚧

The Mangrove Manager project is a 100% Rust tool to manage a mangrove nursery operation across multiple locations for a local non-profit. Beyond the basic functionality of the site the primary design consideration is to create a system that is stable and easy to maintain. A secondary object of the project is to explore how feasible it is to build a production grade frontend using Rust compiled to WASM.

Background

The Mangrove Manager started life as an upgrade to the nursery that my wife runs for Marine Resources Council (MRC), a local non-profit devoted to the conservation of the Indian River Lagoon. They run a state-licensed mangrove nursery program to grow the trees from propagules (similar to seeds, propagules are dropped by mature trees to reproduce) to ultimately be used in coastline restoration projects around Florida. The nursery is split between two locations, a smaller nursery at the MRC main office and a larger nursery at a conservation property managed by MRC. By implementing this system we are hoping to introduce more automation in the management of the nursery and provide efficiency insights through data.

System Requirements

Basic Functionality

The basic functionality of the system is to track individual plants by assigning an ID number that can be encoded on a barcode or QR code and attached to the plant. In order to add new plants they will scan the ID codes and create new entries in the database. Plants will be able to be viewed and modified either by navigating the web interface or by scanning an ID code on the plant.

Also of note in the basic requirements is that this system is about as un-scaled as you could imagine. All users of the system will be in the same state, the total number of concurrent users possible is around 10 and the most likely maximum number of concurrent users is 3. 97% of the time the system will only have a single user.

Data Model

The data points that will be collected for each plant are as follows:

Tech Stack

As stated before this project is 100% Rust (ok maybe more like 95% if we include HTML and CSS). I was fortunate enough to find a project template created by Robert Krahn that was using the two frameworks that had made there way to my short list. You can read about the template on his blog here (archived) or checkout the github page here.

Tailscale Linode Phone Interface Website or App Database(SQLite) Database API Website Data View Scanner Reads

Shortlist

For the API layer I’m using Axum, a web framework from the Tokio project utilizing web primitives from Tower and Hyper. Axum seemed like the best maintained and most ergonomic choice out of the available libraries.

For the frontend I wound up choosing Yew. While there are plenty of Rust frontend frameworks to choose, Dioxus was a close second choice, Yew won out due to it’s position as an established framework with many contributors. Yew also has an order of magnitude more downloads than Dioxus at the time of writing.

The final major component of the tech stack was to pick out a library or ORM for the data layer. I prefer to make that kind of choice after I have already settled on a database system, to ensure an acceptable Developer Experience. Normally my go to solution for databases is Postgres, however in this case I felt that it would be the wrong choice. This system is intended to have minimal maintenance, adding a full database system means additional work to keep it up to date. It also complicates the hosting requirements of the system, either the host will need enough resources to run the database and web server or the database will need its own host. Instead I decide to go with SQLite. I have no concerns around hitting a performance bottle neck in this system, the only addition to the deployment will be to ensure that the SQLite package is installed on the host, and it makes backups trivial.

With a database system chosen I was able to review the libraries available. In the end I decided to go with SQLx, primarily because I was interested in exploring the features of their sql macro. This macro accepts normal SQL statements as well as any data that needs to be bound to the statement and provides intellisense (via LSP builds) and build time validation of your SQL statements. This validation goes beyond a simple syntax check and can actually check your queries against your own database scheme! That means it can tell you that your query is invalid because it is trying to select from the column pot_szei which doesn’t exist in your database 🤯.

Minimal Viable Product

As there is currently no management system in place for the nurseries any system that can meet the basic functionality requirements laid out above will be a vast improvement. In order to deliver value as soon as possible I’m attempting to be dogmatic about creating a minimally viable product. I’ve identified a few key areas of work that will establish patterns or underlying infrastructure that will be needed before I can start focusing on the basic functionality.

Pre-MVP Validation

MVP Goals

The rest of the MVP will consist of the following features: