Web App Example: A full-stack ERP App

Search for a command to run...

No comments yet. Be the first to comment.
In this series, we will show how to create a basic web application in PicoLisp.
"This world is but a canvas to our imagination." (Hery David Thoreau)
In our previous post, we introduced how to utilize Discrete Event Simulation (DES) in PicoLisp. Now, let's explore another application: a railroad model simulation that includes tracks and trains. The visualization is ASCII-based, so feel free to unl...

The Dining Philosophers

In this post, we will introduce the concept of co-routines and how they are handled in PicoLisp. This will be the foundation for the subsequent posts on Discrete Event Simulation and finally a couple of examples, including an ASCII model railway simu...

One of the many nice things of PicoLisp is that it comes with a built-in database. This makes it easy to collect and store our own data, for example via a mobile app. But not all data is best represented in tables and lists: sometimes a colorful litt...

In the last two posts, we have built a little app that shows the current location and displays the nearest ice cream shops: https://picolisp-explored.com/an-openstreetmap-app-written-in-picolisp-pt-1 https://picolisp-explored.com/an-openstreetmap-ap...

To close the database / web app session, let's take a look at a more complex example: A full stack Enterprise-Resource-Planning app (in a quite simplified form of course).
This app has several different pages, a navigation menu, calculations, PDF documents and other things that might be helpful for you as reference.
You can test the app online on https://picolisp.com/app, login with "admin", password "admin". If the login was successful, a green "admin logged in" text is visible:

In the menu of the left side, you can see the sections "Data", "Report", and "System" with various subitems. For example let's click on Orders:

We can see a lot of "orders" sorted by date. We can filter the list by supplier or customer name, date, number, item... Also, we can create new items by clicking the "new" item on the bottom left.
Next, let's check out Inventory:

Here we can see the current inventory and the prices for the items. We can download the table as CSV too.
And since we're the "admin", we can also see some administrative tasks, like the role and user administration. At first you see a list of names, by clicking them you can see a control panel where you can edit the settings.

Next, let's check out the sourcecode and test it locally. I have uploaded the sources to here.
Note: This article was written in 2021. Since then there have been minor changes in PicoLisp. In order to run the ERP-app with newer versions of pil, please download the ERP-sources fromthis link.
You can start the application from the ERP-example/ folder with:
$ pil app/main.l -ap~main -'go 4040' +
Now you should be able to access it from http://localhost:8080. It starts with the admin user logged in.
The source code contains the following files (sorted by size):
gui.l is the longest file (237 lines) and contains the functions that render the user interface.
er.l describes the entities and relations . You can also find them visualized in a little graph:
### Entity/Relations ###
#
# nr nm nr nm nm
# | | | | |
# +-*----*-+ +-*----*-+ +--*-----+
# | | sup | | | |
# str --* CuSu O-----------------* Item *-- inv | Role @-- perm
# | | | | | |
# +-*-*--O-+ +----O---+ +----@---+
# | | | | | usr
# nm tel -+ | | | |
# | | | | itm | role
# +-*-----+ | | +-------+ +---*---+ +----*---+
# | | | | | | ord | | | |
# | Sal +---+ +---* Ord @--------* Pos | nm --* User *-- pw
# | | cus | | pos | | | |
# +-*---*-+ +-*---*-+ +-*---*-+ +--------+
# | | | | | |
# hi sex nr dat pr cnt
loc/ folder contains the translation in various languages.init.l supplies some initial objects to the database.lib.l contains four functions related to PDF printing.main.l defines the entry point, like defining global variables and starting server and database.menu.css is the css file.ord.l, cusu.l, item.l and sal.l are edit forms for the individual database classes,sales.l and inventory.l are simple reports.The ERP app is well documented in the PicoLisp App tutorial, so I don't think it is helpful if I copied this here.
If you followed the Web Application- and Database tutorial up to this point, you should be able to understand most of what is happening in the code. I think the best approach would be to take this as a basis for own modifications and see where it takes you.
If you have any questions or get stuck, feel free to contact the PicoLisp community for support!
https://software-lab.de/doc/app.html#minApp
https://picolisp.com/app
```