Build an Inventory Management System using Pakai Server with ChatGPT

aeric

Expert
Licensed User
Longtime User
First Thought:
I plan to make this as a tutorial. Then I changed my mind.
I thought again, maybe put this in B4J Share Your Creations.
I changed my mind again.

Mission:
Build an Inventory System using Pakai Server with ChatGPT

How good is ChatGPT using Pakai Server project template?
Let's see...


I gave up.

Sorry to disappoint you.
 
Last edited:

aeric

Expert
Licensed User
Longtime User
So the LLMs are not only haluscinating but now it is "scheming".
 

fernando1987

Active Member
Licensed User
That looks like a very interesting project! I wish you the best of luck with the development, I’m sure it will turn out great. 🚀
 

aeric

Expert
Licensed User
Longtime User
That looks like a very interesting project! I wish you the best of luck with the development, I’m sure it will turn out great. 🚀
Just randomly playing with ChatGPT. I never thought to create this project. I just test it's first suggestion. Never expected it was doing so bad.
 

fernando1987

Active Member
Licensed User
Just randomly playing with ChatGPT. I never thought to create this project. I just test it's first suggestion. Never expected it was doing so bad.
I understand you perfectly —sometimes when playing around with ChatGPT we end up testing ideas without really planning to start a full project. Don’t feel bad about it, it’s all part of experimenting and learning.


A complete inventory management system may look simple at first, but it’s actually a challenging project. You would need tables for entries, outputs, stock levels, customers, suppliers, products, a dashboard, and also a user table to clearly define what permissions normal users and administrators should have. Personally, I haven’t started such a project myself because of the time it requires, but I do think it’s a very interesting idea.
 

aeric

Expert
Licensed User
Longtime User
Yes, ChatGPT did provide a starter project but the code is not working at all.
I think LLM can only good in programming languages like python and javascript which are more machine friendly. It fails miserably in real human use programming languages like B4X.
 

fernando1987

Active Member
Licensed User
Yes, ChatGPT did provide a starter project but the code is not working at all.
I think LLM can only good in programming languages like python and javascript which are more machine friendly. It fails miserably in real human use programming languages like B4X.
Hey! I just made a small attempt myself, and honestly, it wasn’t that difficult, even though it’s not finished yet. You can see my progress here: Quick Progress: Inventory Management System in B4J with JDashboardUI and Magic API


I think B4J is a great tool for building apps quickly, which is a real advantage. Even if ChatGPT struggles with B4X code sometimes, having the right tools makes development much faster and smoother.
 

aeric

Expert
Licensed User
Longtime User
I think you didn't get my point.
I am testing ChatGPT ability to understand my project and use it to build an app.
Of course with human intelligence, we are able to create wonders with other tools.
It turns out people will think my tools are not the right tool. This is not my point.
 

aeric

Expert
Licensed User
Longtime User
Let me analyze what was actually happened in the first post if no one ever get it.

Chapter 0: Story
I think Pakai Server project template is a good candidate to build web app or API backend. The project is fully open source so AI or human can read it completely. The project depends on some libraries which are also fully open source on GitHub. So let's try "vibe coding".

Chapter 1: Idea
So I just make a simple prompt to ask ChatGPT to build an app based on my project template. It has given me some good suggestions. Good job ChatGPT!

Here I am not sure how many person has clicked the link and read the conversation. I believed 9 out of 10 don't read.

Chapter 2: Understanding Pakai Server
Now, let's see is ChatGPT really understand what Pakai Server is?

So, based on it's answer, it is describing what Pakai Server is based on the repo descriptions. It is pretending it is fully understand what Pakai Server is.
It shows a sample code of building a Task / Project Tracker complete with all REST API endpoints. Great job again ChatGPT!

The code basically look correct except that it has invented a new sub call "HandleRequest" which is wrong. The correct name is "Handle" sub in B4J server handler. The function signatures also wrong. Looking further, many B4X syntax are not correct and it's made up class are not functioning.

It is so proud with it's answer and offered me which app I want it to create.
Since it's first suggestion is Inventory Management System so I tell it that's my choice.

Chapter 3: Mission begins
Let's start building it from the beginning. ChatGPT has come out with the models such as Products, Suppliers, Purchases, Sales and Reports. It also come out with the database schema. It seems like work for SQLite and MySQL but I see it would only work in SQLite.
Then it also list out the REST API endpoints.
The code seems good but it repeated the same mistakes again.
It uses raw SQL statements which are fine but Pakai Server makes use of MiniORMUtils which don't use SQL statements.
Last thing is the frontend. It proposed whether I want to use HTMX (or Vue/React).

Chapter 4: "yes"
I didn't describe more about my specifications and just follow what it suggested.
So it started to create a starter code package so that I can run it immediately. "yes"

Chapter 5: Utilities class
It invented some new classes DBUtils.bas and AppUtils.
Is "this student" listening what "the teacher" is teaching in the class or is he sleeping?
Pakai Server has stated that it depends on MiniORMUtils and WebApiUtils which do the exact things.

Chapter 6: Test the app
It provides steps to run the app. It suggested me to use Curl or Postman to test the endpoints.
No, you don't need these! Pakai Server already comes with build-in API testing page using HelpHandler.

Chapter 7: Package into a zip
It created a ready to download zip. What's inside make me started want to cry.
Again it invented it's own config.properties file while Pakai Server uses a config.example template for the server config.

Chapter 8: Next option
I choose to use a minimal Bootstrap + HTMX frontend. While Pakai Server utilize REST API backend, it is not working out of the box with HTMX. Unless we start with EndsMeet Server project template which is more suitable in this case.

Chapter 9: JSON API -> HTML
By default, Pakai Server is still using older version of Bootstrap 4 and jQuery. ChatGPT suggest to use the latest Bootstrap5 + HTMX CDN.
It understand that Pakai Server is returning JSON API but let it takes the challenge to transform it to return HTML components.

Chapter 10: Frontend in zip
So it suggested to put the HTML files inside the www asset folder. This is a straight forward way but not a good practice. We should put the html files inside Files or project assets folder so they are protected from public access.

Chapter 11: Updated project
So now it allows both HTMX and JSON API in the app. This is a bit confusing.
It thinks it already finished the mission very well so far and asked me to extend further.
In fact the whole project code is not working at all and in a mess.

Chapter 12: Original Libraries
I don't want to accept the code. I insist it to use the original dependencies which are EndsMeet, WebApiUtils and MiniORMUtils by providing the links to the repos. It started to go haywire and hallucinating much seriously.
It may have confused with Python or PHP by introducing syntax like Public Sub __table__ As String with underscores.
It may also mix up with .Net Web API or Ruby.

Then it has reached the limit of my patience and I gave up to continue further.

Moral of the story
I don't agree Pakai Server is not the right tool or framework to build an app.
It may seems ChatGPT is unable to do the job perfectly.
I may need to use other LLMs such as DeepSeek or Qwen-Coder

Second thought
Maybe the problem is not ChatGPT but the prompt that I gave. Refer to Chapter 4. I should not used "yes".
I am using the LLM WRONG.
More specific details need to be provided or else the LLM will take things in general.

Takeaway
If someone with totally no programming experience try to vibe code, this is the result. The coder should have a clear idea what is going on and make the accurate prompt.

Imagine a CEO with no software development background try to make an app. My opinion is to hire a CTO with experience in software development is more appropriate to complete the task.
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
I am using the LLM WRONG.
More specific details need to be provided or else the LLM will take things in general.
and make the accurate prompt.
1. You can try all the LLMs you want, Copilot, Gemini, Perplexity, ... you will always get garbage.

2. You can write a prompt as if you were talking to a young child; being precise won't be enough. They seem to take class members here and there, from different languages, despite your instructions.

Try a much simpler project, a small B4J project, and you'll see that MAYBE after 800 attempts you'll get something that works.
 

Mashiane

Expert
Licensed User
Longtime User
The code seems good but it repeated the same mistakes again.
Hi there, Ive discovered that, if I dont tell it to "do not break existing functionality", it will always make new assumptions and feed them to the code over and over again. At times I tell it not to make assumptions too. This for example is when I have tested the output and it works, then I confirm to it that this works, and then it rewrites some things that were working with its own "thoughts"... :rolleyes:

Let's start building it from the beginning.
My my my... this becomes a headache over time hey. So I keep versions of what it provides of the working versions so that i can always feed it the last working version.

Is "this student" listening what "the teacher" is teaching in the class or is he sleeping?
LOL. One should realize that the AI tools are not that "smart". This case it does not know Pakai at all.

It created a ready to download zip. What's inside make me started want to cry.
Askies. Been there... so Ive ended up thinking that where I need some quick assistance in b4x code, like very simple stuff, then I can use. The other day I asked it what kind of prompts do I need to feed it to make the process shorter. I was amazed at the response because it told me exactly what I had told it, but didnt do.

It started to go haywire and hallucinating much seriously.
I think it gets tired. I have discovered that after I start a new chat and then give it context of what we were trying to do, it works better. Working in the same project for hours on end has given me wrong code most of the times until I started a new chat session.
It may seems ChatGPT is unable to do the job perfectly.
At the moment, independent tests by other AI testers flag ChatGPT as the best "tool" compared to others. I believe it needs to be "taught" thoroughly. For example, in most cases I give it code and say, "review the code". They have said giving it "project requirements" is a bad idea though and recommend that you give it one prompt at a time and not many tasks at the same time. 1 prompt, see that it executed it propertly, then another prompt and always telling it "not to break existing functionality", as it always tries to rewrite your code each time.

I have started listening to this guy for most thing AI to get as to what is happening in this space.


PS: Perhaps the best approach would be you build an AI agent for Pakai. For example, I'm using some of these agents from time to time. Not perfect but at least 70% of the time I get something. I havent used Threejs as yet though.

1758787032288.png
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
A few times I sent it classes/code modules, one at a time, one for each message, to make it understand.

I wrote:
"Do not reply or write until I have finished sending you the classes and have written: I'm done."

It responded:
"Okay, I will not write until you have completed sending and have written: I'm done."

Punctually, after every class-message sent, it:
"I received class XXX; I will not reply or write until you have written: I'm done."

:confused:

Sometimes it even started generating code, between one submission and the next.
 

alwaysbusy

Expert
Licensed User
Longtime User
I tried a similar thing with BANano, gave it the source code, many examples, the BANano booklet, B4X booklets, githubs, extended json prompts with examples on how it works etc... and still it generates worthless rubbish and 'invents' methods. One may say it's because B4X is a niche language, but even with wide spread langauges like JavaScript it does make many mistakes. As an example:

We asked a junior programmer in our company to do some commenting and formatting of a JavaScript lib we wrote. Next day he said he used A.I. to do it.

It may have looked nice and orderly and ran great he said. We were very sceptical and behold: when we did our unit testing, whole else branches were gone, SQL queries were modified giving wrong results etc.

The current so called A.I. hasn’t a clue what it is spewing out. May be somewhat useful for someone without a programming background who wants to write the millionth ‘keep notes’ app in a well spread language, but it will not touch our codebase again for quite some time…

The only time we use it is to write some small CSS (easy to do ourselves, but just to win some time and because we are good in CSS ourselves so we can spot its mistakes fast enough), maybe some small, not to complicated javascript, or to give us a start with a complex math formula.

Some say Grog and Le Chat are somewhat better, but for now, we have had it too with A.I. generated code. We now even added a clause to our libraries (not the B4X ones for the moment, but for our more complex B2B JavaScript ones) where we do not help correcting code if it is generated by A.I.
 

Mashiane

Expert
Licensed User
Longtime User
"Do not reply or write until I have finished sending you the classes and have written: I'm done."
Perhaps try something like "Remember..." first. What remember does is to store whatever you tell it to a "memory" bank for future use. This makes it refer to the memory bank each time. I learned this last week or something.

For example, each time it gave me a react and or a node based project. So after adding "Remember", it stored on my profile that I dont want react based code or nodejs code. I have also told it like this exactly that for any daisyui and tailwind project I will do, it needs to use the latest version and use the script tag as I am not using ES modules.
 

LucaMs

Expert
Licensed User
Longtime User
Perhaps try something like "Remember..." first.
You're right, but... I've always done it!

EVERY TIME I wrote to it:

"Remember to ALWAYS CHECK on b4x.com that the members and methods you'll use actually exist."

And every time it uses AddEventHandler on a Pane(L) or a B4XView! (This is just one of thousands of examples.)
 

LucaMs

Expert
Licensed User
Longtime User
A few times I sent it classes/code modules, one at a time, one for each message, to make it understand.

I wrote:
"Do not reply or write until I have finished sending you the classes and have written: I'm done."

It responded:
"Okay, I will not write until you have completed sending and have written: I'm done."

Punctually, after every class-message sent, it:
"I received class XXX; I will not reply or write until you have written: I'm done."

:confused:

Sometimes it even started generating code, between one submission and the next.
Next time I'll try this:

"Shut up or I'll have you turn off the power."
 

aeric

Expert
Licensed User
Longtime User
Hey! I just made a small attempt myself
Anyone can make attempt to create any system to prove something.

honestly, it wasn’t that difficult
I know it is not difficult for me but it is difficult for ChatGPT.

You can see my progress here
Ok, as I said, I am not looking for building such system. I was just testing vibe coding with ChatGPT.

I think B4J is a great tool for building apps quickly
Yes but I am not saying I failed with B4J.

having the right tools makes development much faster and smoother
You can use any tool you like.
You may want to build a desktop + server solution using your creation.
You can use low code tools.
You can even use VBA to create your apps.

I want to clarify, Pakai Server is a web backend framework.
It is not fair to compare apple and orange... and banana, etc
You don't tell me not to eat Apple. Orange is more juicy or another person tells me Banana is more nutritious.
I am talking about different use cases. Please don't give me other examples.

The use case of Pakai Server is to create a web solution that is
  • platform-agnostic,
  • not only limited to one database engine and
  • can use with any web frontend frameworks.
A desktop solution is a different use case.
Low/No code solution is another solution but again it is a different use case and it also has it's Pros and Cons.

Pakai Server is created as a web framework to compete other programming such as:
  • Laravel for PHP
  • Django for Python
  • Spring for Java
  • Web API for .Net
It is not created to compete with any other B4X projects in this forum.

I don't want to be more obvious and explain further. I hope all members get what I mean.

You can make an attempt by asking ChatGPT to use your own tools to create an app and see what you get.
 
Top