Menu Home

Modern Full-Stack Web Applications for a Fraction of the Time and Cost

Modern web applications are useful software solutions that can be accessed from any web-connected device. Most of the newer applications are responsive (i.e. the user-interface adjusts automatically to suit the device viewport size) and are compatible with most modern Web Browsers. However, a professional quality web application can take hundreds, if not thousands, of hours of development time to create, deploy, and maintain, often reaching into the tens-of-thousands of dollars for the total cost of ownership. That’s where rapid development, or “low code”, software solutions have an advantage. Low-code solutions are often promoted to companies lacking the resources and expertise, or needing to get a solution to market fast. These tools can help companies be up and running in no time flat, at a fraction of the cost.

In this post, I will discuss a Full-Stack Web Application platform that I’ve recently discovered, called Anvil1. I will also highlight one of the projects I completed using this new platform.

Anvil – Production Ready Web Applications

Before I describe Anvil, a little background is needed. If you have read my other blog posts, then you know that I am a fan of the Python software language. I’ve been writing production-level Python code for about five years now. I also have some experience with building modern web-applications using JavaScript, HTML and CSS. However, I am not as confident with my client-side (i.e. browser-side) software skills. If you are wondering what I mean by “client-side” see this article. Now, what about this Anvil.

Anvil is a web-based, rapid-development platform that allows developers to build full-stack web applications using nothing but Python. That’s right, with Anvil you can work with Python on the Client, and the Server. Anvil converts Python code, behind-the-scenes, into native JavaScript code that runs in the browser. This is a powerful feature, as it allows the developer to work fully in Python, including the ability to incorporate native JavaScript libraries seamlessly. As an example, one of my projects needed a mapping component, and I was able to incorporate the MapBox GL JS library with just two lines of code.

In addition, Anvil takes care of the DevOps for you, with one-click deployment to the Cloud. Also, because Anvil is an open-source platform, you can run it anywhere, even on your own servers behind a firewall. Another nice feature of Anvil is the backend database is built on PostgreSQL, and the Anvil web-based IDE makes interacting with the database extremely simple. There is no need to use PostgreSQL PgAdmin, or to create the database schema using SQL DDL scripts. It’s all handled for you by the Anvil IDE.

In addition, Anvil also has some very powerful integrations with User/Session management, User authentication, API tools and interfaces, Google Maps, Google Drive, Media files, and built-in GIT version control. In all my years working with software, I have never seen a more rich set of features out of the box than what Anvil provides. You can literally have a fully functional web application running in a matter of minutes.

I typically work solo, and using Anvil has been a godsend, increasing my productivity 300-400%. It’s like having three or four professional web developers on the payroll, without the payroll. What I’ve built thus far with Anvil are in the style of SPA’s (single-page web applications), but Anvil also has features for building visual dashboards and applications that showcase Data Science solutions.

In the next section, I will describe the project I completed recently using Anvil.

Loblolly Pine Thinning Schedule Using an SDI Approach

Background

One of my favorite pastimes is reading scientific journals that describe growth and yield models developed for Loblolly Pine plantations. When I find one that I’m really interested in, I try to replicate the models using a Spreadsheet, or Jupyter Notebook. This process is helpful for learning something new, or if you’re like me, remembering something you’ve previously forgotten.

Recently, I discovered a paper that I had stashed away almost twenty years ago titled “Use of Stand Density Index to Schedule Thinnings in Loblolly Pine Plantations: A Spreadsheet Approach.” by Paul F. Doruska, and W. Robert Nolan, Jr. (1999). I was immediately drawn to the simplicity of the approach the authors presented. In the article, the models were incorporated into a Spreadsheet solution, but my goal was to update this approach using a Single-page application that was user-friendly and responsive. For the remainder of the article I will briefly discuss this process.

In the article, the authors presented four methods to schedule a thinning, or harvest, for Loblolly Pine stands based on the user-supplied current stand information,

  1. schedule the next thinning
  2. schedule one thinning and a harvest
  3. schedule two thinnings and a harvest
  4. schedule a final harvest

My Solution and Approach

My previous experience with growth and yield projection models, is that they work well for planning purposes, but fail miserably on an operational level. I believe this is partly due to highly variable stand dynamics, and because thinning operations can have significant stand altering effects, which add a heuristic element to these forecasts.

Knowing this, my approach was to develop a tool that would be more practical, at least operationally, and so I removed the one- and two- thinning approaches outlined above. The application I built only addresses the next-thin and and final harvest scenarios. My assumption is that a Forester using the model would have a good understanding of the current stand conditions, and thus predictions to the next future operation (thin or harvest) would be more applicable than attempting to model the stand through one or more unpredictable thinning operations.

One additional feature that I wanted to build was a diameter distribution chart in the output screen, to visually display the change in stand structure resulting from an operation. For the harvest scenario, only the pre-harvest diameter distribution is plotted. This was accomplished using the Moment-Percentile Estimation approach on the Weibull distribution, described by Baldwin & Feduccia (1987). Anvil provides an interactive charting component that works with Plotly, and various other graphical libraries.

I will avoid getting into the details about the development process and the models here, but, I urge readers to download Doruska & Nolan’s article (1999) to learn more about the models and methods involved.

For the technical stuff, all I did was replicate the methods using Python code running in a Server module. The client-side interface passes data to the Server for calculations, and the Server sends the result back to the client for display to the user. In all, this was accomplished with 1034 lines of Python code (client and server-side). I estimate that the total time from start to completion was around 35 man-hours, which included development, debugging, and testing. If you are interested in seeing the source code for this project, please email me directly, or provide a comment in the post.

Screenshots of the application interface and Next Thin process are shown below.

Application Login Screen – user authentication provided by Anvil
Home Screen – after successful Login.
Thinning Input Interface – With an option to model using previous thin attributes.
Tabular Output – showing before and after thin stand attributes.
Graphic Output – showing diameter distributions before and after thin.
Sources:

Baldwin, V. C., Jr., and Feduccia, D. P. (1987). Loblolly pine growth and yield prediction for managed west gulf plantations. U.S. Department of Agriculture, Forest Service – Southern Forest Experiment Station. Research Paper SO-236

Doruska, P. F., and Nolen, W. R., Jr. (1999). Use of stand density index to schedule thinnings in loblolly pine plantations: a spreadsheet approach. Southern Journal of Applied Forestry 23(1), pp. 21-29

1Anvil is a trademark of the Tuesday Project, LTD.

Categories: Forestry Apps Python

JwL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: