Database (ER) diagram for Jam.py app

23 views
Skip to first unread message

Dean D. Babic

unread,
Jul 27, 2025, 3:13:11 AMJul 27
to Jam.py Users Mailing List
Hi all,


As seen, got it to work. The next stage would be to create this diagram FROM
Jam.py app, with the lookups presenting the relations.


er_diagram_jampy.png
It should not be that hard to "drive" ChatGPT to achieve this.

Here is the admin.sqlite. 
Enjoy!
admin.sqlite

Dean D. Babic

unread,
Jul 27, 2025, 6:30:13 AMJul 27
to Jam.py Users Mailing List

- the below is chatGPT way of displaying ER diagram:

function show_er(item) {
    item.server("get_markdown", function (markdownText, error) {
        if (error) {
            console.error("Error fetching Markdown:", error);
            return;
        }
        console.log("Received diagram:\n", markdownText);
        // Set the diagram text
        const container = document.querySelector(".mermaid");
        if (container) {
            container.innerHTML = markdownText.trim();  // inject content
            // Dynamically import and render
            import('https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs')
                .then((mermaid) => {
                    mermaid.default.initialize({ startOnLoad: false });
                    mermaid.default.run();  // trigger rendering
                })
                .catch((err) => {
                    console.error("Mermaid failed to load:", err);
                });
        }
    });
}


This is the Jamtonic way (mermaid.min.js is in index.html):

function show_er(item) {
    item.server("get_markdown", function (markdownText, error) {
        if (error) {
            console.error("Error fetching Markdown:", error);
            return;
        }
        item.view_form.find(".mermaid").html(markdownText);
        mermaid.initialize({ startOnLoad: false });
        mermaid.run({ querySelector: '.mermaid' });
    });
}



Dean D. Babic

unread,
Jul 27, 2025, 8:46:13 AMJul 27
to Jam.py Users Mailing List
Follow the ChatGP discussion here:

https://chatgpt.com/share/6886016d-ca10-8012-9222-f7a998a421bc


Perfect — now we’re at the fun part: generating the Mermaid ER diagram dynamically from the Jam.py admin.sqlite schema!

Since admin.sqlite holds the metadata for your app (like tables, fields, relationships), we can query it and generate a Mermaid-style erDiagram block.


✅ Step-by-Step Plan
  1. Query Jam.py metadata (tables and fields) from admin.sqlite.

  2. Detect foreign key relationships from SYS_FIELDS.

  3. Construct Mermaid erDiagram syntax.

  4. Return it as a string from get_markdown().


It automatically generated the Python script get_markdown(), and after feeding with proper info,
here is the result for dynamic diagram!

demo_er_diagram_jampy.png 

The final code is in admin.sqlite for smaller V7 app. 

Cheers

admin.sqlite

Dean D. Babic

unread,
Jul 28, 2025, 2:30:42 AMJul 28
to Jam.py Users Mailing List
There is a problem with a size on 100 tables Jam.py project tho.
Because this is not a picture, but JavaScript.

demo_er_diagram_large_jampy.png
And I'm not sure if modal form can be zoomed! 
Reply all
Reply to author
Forward
0 new messages