This is a second post in a 2 post series of my experience building inventory websites over the last few years. The first post talks about building inventory websites using MEAN stack and superfluousness of using MEAN for smaller inventory footprint / user base. If you haven't read the first post, you could read that here
In this post, I'd like to talk about a simpler version of inventory website (with just enough functionality) that you could build right now. I'll add my code at the end too.
The framework in question is called 'streamlit'. Streamlit is a python based framework to showcase your data science work developed with data scientists in mind. It natively runs in a web browser backed by a python script. And it is interactive - you can create and respond to user actions. If you know what Jupyter notebooks are (if you dont, they are a browser based execution environment backed by the terminal , again great for data science experimentation ), streamlit has what Jupyter notebook has , plus controls like text input, buttons, sliders etc.
Before we talk about why streamlit is the right framework, let me cover the bare bones of an inventory website in terms of database, web server and web page.
The fundamental building block of any inventory application is a data base containing all the information. This is the heart of the entire system. Think of this as CENTRAL STATE. Every user action either reads or updates this one central state. The user actions one could perform are usually called CRUD ( Create - Read - Update - Delete ). All the inventory actions could be composed using CRUD operations.
The second building block of an inventory application is a web server. Think of this as the brain of the system. It accepts requests from the user and sends responses. It is also connected to the database and does CRUD operations on behalf of the user. A web site is the interface for the user to get current inventory, update inventory , create new inventory items etc. When you enter an address in the browser bar, that's the first request made to the web server. It responds with a website. Now once the browser has the website, you can interact with your inventory through it. When you click a button, push a slider, select an option etc, your website sends a request to the web server on your behalf. The server has some pre defined rules for each request. Some requests make the server request inventory from the database and send it to the webpage.
So in summary , you need a database, a web server and a webpage. In the MEAN world, you use a MongoDB database, Express.js server , Angular 2 framework for building a website and all of this built the nodejs environment. If the above jargon doesnot make sense to you, that's alright. Replace everything by javascript and more javascript to give it some shape.
Now let's talk about streamit. First things first, it's based on python. Oh wait, you did go through the initiation into python in the previous post.
Moving on. I've give you a very simple recipe of an inventory website. All in a less than 100 lines of code [obviously, you can't launch into space with this. Oh wait, can you ? ]
Install python and streamlit on your PC ( or server ), you can find installation instructions here. Take all your inventory in excel sheets. You can even convert it into .csv files, but if you don't, that's fine too. Write a .py file with the interaction you need. Look at the code for more details. Open a terminal and run 'streamlit run <filename>.py' and there you have it.
An inventory website being server on you LAN network. Just give everyone your IP address and port and they could use it too. No more writing code for the web server, html, css, javascript, angular boiler plate etc. One file, some python code and your inventory excel sheet or csv. This setup solves a simple problem I call visibility. Every one know the current state of inventory. All you have do is keep the excel sheet up to date and your users would see the latest inventory on the website automatically.
There are some problems it does not solve. For example, there's no real authentication. So don't use for external facing websites, obviously. Apart from that, you could create an excel sheet of user name and passwords and link it to your streamlit app to authenticate people.
Without further ado, you can find sample code here.
Call or text me if you need any help.