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.
Take a look!
You can test the app online on 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.
Downloading the file
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 localhost:8080. It starts with the admin user logged in.
The structure
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
- the
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
andsal.l
are edit forms for the individual database classes,sales.l
andinventory.l
are simple reports.
Read the documentation
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!