elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
6.2k stars 1.13k forks source link

[PERF] Workflow Graph Loading Enhancement #5350

Open sfmskywalker opened 3 months ago

sfmskywalker commented 3 months ago

The Problem

The current UI retrieves and loads the entire workflow graph from the server, which leads to:

The Solution

New API Endpoint

UI Modifications

Benefits

Notes

The solution addresses performance issues related to sub-workflows (workflows as activities) and other complex activities like "ForEach" and "Container". It ensures efficient and scalable graph handling, regardless of the specific workflow structure or component type.

glime-ai[bot] commented 3 months ago

To implement the solution described in the problem statement, you would need to follow these steps:

  1. Create a New API Endpoint:

    • Develop a new API endpoint in the backend that accepts a parentId as an input parameter.
    • The endpoint should be designed to retrieve only the parent node and its immediate children from the workflow graph.
  2. Modify the Backend Logic:

    • Update the backend logic to handle the retrieval of a specific node and its immediate children based on the provided parentId.
    • Ensure that the backend can serialize the selected portion of the workflow graph into a JSON response.
  3. Update the UI for Lazy Loading:

    • Adjust the UI components to support lazy loading of the workflow graph.
    • Implement logic to trigger API calls when a user interacts with a parent node, such as clicking on it to expand and view its children.
  4. Optimize Data Handling:

    • Ensure that the UI only requests and processes the necessary data for the user's current context, reducing memory usage and improving performance.
  5. Test the Solution:

    • Thoroughly test the new API endpoint and the updated UI to ensure that they work as expected.
    • Validate that the performance improvements are significant and that the user experience is enhanced.

By following these steps, you can achieve the benefits of reduced initial load time, improved performance, and scalable data handling for complex workflow graphs in the UI.

This comment was generated by Glime.