Webpage UI automatic generation method based on workflow and template
By abstracting web page functional requirements into workflows and using Pipeline and Jinja2 template languages to generate web page code, we solve the problems of low efficiency, high cost and high technical threshold in the traditional web UI development process, and achieve fast and flexible web UI development and Reduce development costs.
Patent Information
- Application Number
- CN202410529850.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-29
- Publication Date
- 2024-08-27
AI Technical Summary
The traditional web UI development process has low efficiency, high cost, high technical threshold, poor flexibility and adaptability, resulting in low development efficiency, high cost and poor user experience.
Abstract web page functional requirements into workflow, generate web page code through Pipeline processing and Jinja2 template language, simplify the UI design and development process, lower the technical threshold, and improve flexibility and adaptability.
It achieves fast and intuitive web UI development, reduces development costs, improves development efficiency and flexibility, and enables non-professionals to participate in web UI design and development.
Smart Images

Figure CN118550530A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a method for automatically generating a webpage UI. Background Art
[0002] In the field of modern web development, due to the low efficiency, high cost and high technical threshold of traditional UI design and code writing processes, some code automatic generation technologies have been applied to the development of web UI. However, the currently widely used sketch conversion method based on deep learning is difficult to satisfy in terms of accuracy. The web pages generated by the designer's sketch are not only prone to errors in function (such as high error rate in interface component recognition), but also do not save the cost of software developers drawing class diagrams and designers designing interfaces. In addition, UML activity diagrams and template technology have also been applied to code automatic generation. Although it provides a certain degree of automation for web UI development, it has some disadvantages: 1) High technical threshold: Existing technologies require developers to have an in-depth understanding and experience of UML, which is a major obstacle for non-professionals or beginners. Before code generation, complex UML diagrams need to be drawn. This process is time-consuming and error-prone, especially in projects with frequent changes in requirements, and the initial workload is large; 2) Limited flexibility and adaptability: For specific requirements of web UI, UML-based methods may not be flexible enough and difficult to quickly adapt to subtle adjustments in the design. Although template technology helps to improve a certain code reuse rate, the versatility and flexibility of templates in traditional methods are still limited. 3) Lack of specificity: It is a general design for general software, not very specific to web UI, and some details are not suitable. Summary of the invention
[0003] In view of this, the present invention proposes a method for automatically generating a web page UI based on workflow and template. The present invention can solve the main technical problems encountered in the development process of traditional web page user interface (UI), including:
[0004] 1) Low development efficiency: The traditional web UI development process is cumbersome and time-consuming, requiring developers to manually write a large amount of code, which not only reduces development efficiency but also increases the time cost of the project; 2) High professional skills requirements: Traditional methods require developers to have deep programming knowledge and web design experience, which limits the participation of non-professionals in the development of web UI and affects the flexibility and innovation of development; 3) Low code reusability: In the absence of effective templates and workflow automation support, developers often need to repeatedly write similar or identical codes, resulting in low work efficiency and increasing the difficulty of code maintenance; 4) Poor demand adaptability: With the rapid changes in market demand, traditional development methods are difficult to quickly adapt to new demand changes, resulting in slow web UI update iterations, affecting user experience and market competitiveness; 5) High development cost: Due to the large amount of manpower and time costs invested in the development process, the development cost of traditional web UI is relatively high, which is particularly challenging for small businesses and start-ups with limited resources.
[0005] The specific technical solutions are as follows:
[0006] From the perspective of the steps and processes of users using web pages, the functional requirements of web pages are abstracted into workflows for different user roles;
[0007] Convert the workflow into a certain form of data structure;
[0008] The obtained data structure is processed step by step using pipeline. The processed data structure can be directly called by each function in the template code to generate the target web page code.
[0009] Pre-write the template file, use the Jinja2 engine to parse the template file, bind the data processed by the pipeline to the template file to generate HTML code, that is, the target code, and run the target code to generate the required web page UI.
[0010] Furthermore, a workflow corresponds to a specific data structure, which includes: the name of the data structure, whether it is a core workflow, and several behaviors;
[0011] The name of the data structure, i.e., the name of the workflow, is a complete business workflow name in the web page;
[0012] Whether it is a core workflow is a true or false field, which is used to indicate whether this workflow is a key process;
[0013] Several behaviors, behaviors are several actions in the workflow, each behavior includes the subject of the behavior, i.e., the action of the behavior, i.e., the predicate, and the target object of the behavior, i.e., the object;
[0014] Furthermore, each behavior also includes the position of the next behavior and several conditional branches of the current behavior, wherein the conditional branches include the conditions for the action to occur and the actions triggered when the conditions are met.
[0015] Furthermore, the specific steps of pipeline step-by-step processing are as follows:
[0016] Use the createPipe function to create a processing pipeline. This pipeline includes a series of modules, namely: "humod", "integrity", "jobduty". Each module represents a processing step in the pipeline. Together, they define the process of data processing and conversion.
[0017] "humod": This module is used to handle business logic, role definition logic, and responsibility allocation logic;
[0018] "integrity": This module is responsible for ensuring the integrity of data and processing logic, including verifying data consistency, enforcing business rule validation, and ensuring data security and privacy protection tasks;
[0019] "jobduty": This module is used to define and manage job responsibilities, and to describe the responsibilities of different roles, task allocation, and the relationships and dependencies between responsibilities.
[0020] Furthermore, the pipeline also includes "uipage", "database", and "gql";
[0021] "uipage": related to user interface UI design and page generation, used to automatically generate user interface elements and layouts based on defined logic and data, involving template rendering, style definition, and interaction design;
[0022] "database": responsible for database-related operations, including data model definition, database access, data query and persistence;
[0023] "gql": used to define data models, API queries, and mutation operations to manage data exchange between clients and servers in an efficient and flexible way.
[0024] Furthermore, the template file is used to define the static part and the dynamic part of the web page UI.
[0025] Beneficial Effects
[0026] (1) The method proposed in this application does not require too much object-oriented and software development-related expertise, and does not require drawing a series of UML diagrams including activity diagrams and use case diagrams. It only requires understanding the workflow of each user role on the web page to use this method to automatically generate the UI interface of the web page. Compared with the automatic code generation technology based on UML activity diagrams, this application is simpler and faster in terms of process.
[0027] (2) This application simplifies the automatic generation process of web UI by adopting the concept of workflow and Jinja2 template language, making it easy for even non-professionals to get started and participate in the design and development of web UI, thereby lowering the technical threshold.
[0028] (3) This application optimizes web UI code generation by abstracting web page functional requirements into workflows (concretized into data structures) and combining them with the Jinja2 template language. This method reduces the preliminary preparation work and directly abstracts web page functional requirements into workflows in the form of data structures. Especially when requirements change frequently, it avoids the drawing of complex UML diagrams and improves development efficiency.
[0029] (4) Since this application uses Pipeline to generate the target code of the web UI, each step has output, which improves flexibility and adaptability. Through more flexible template technology and intuitive workflow representation, this application can quickly adapt to the details of the web UI design and better meet customization needs.
[0030] Instruction Manual
[0031] Figure 1 , a schematic diagram of the process of the method of the present invention;
[0032] Figure 2 (a) Buyer shopping workflow sorted out from the requirements document;
[0033] Figure 2 (b) The merchant delivery workflow sorted out from the requirements document;
[0034] Figure 2 (c) The merchant management product workflow sorted out from the requirements document;
[0035] Figure 3 , data structure diagram;
[0036] FIG. 4( a ) is a buyer's shopping workflow corresponding to a data structure in an embodiment;
[0037] FIG4( b ) is a merchant delivery workflow corresponding to the data structure in the embodiment;
[0038] FIG. 4( c ) is a workflow of a merchant managing goods corresponding to a data structure in an embodiment;
[0039] Figure 5 , schematic diagram of pipeline processing workflow.
[0040] Figure 6 , template code. DETAILED DESCRIPTION
[0041] The present invention provides a method for automatically generating a webpage UI based on workflow and template. The method is divided into three steps: Figure 1 shown.
[0042] Requirements Analysis Based on Workflow
[0043] Workflow refers to the sequential arrangement of a series of activities, tasks, steps or events required to complete a specific task or achieve a specific goal in an organization. These steps can involve manual operations, automated processes or a combination of the two, with the goal of processing information and tasks efficiently and orderly according to established business rules and logic. A more widely accepted and cited definition comes from the Workflow Management Coalition (WfMC), an international organization dedicated to workflow standardization. WfMC defines workflow as: the automation of the transfer of documents, information or tasks from one participant to another for operation according to a set of procedural rules in the entire or part of a business process.
[0044] Generally speaking, the code structure of web page interface is relatively fixed and simple, and the similarity between different web page UI codes is high; the functions implemented by the web page can often be directly reflected in the interface, which is more intuitive for users; the widely used web page development requirements specification documents mostly give different functional requirements of the web page according to user categories. These determine the particularity of the web page as a software.
[0045] Most of the services that web pages need to implement can be abstracted as workflows. The present invention proposes to migrate workflows to the use of web page software, abstract web page functional requirements (services) as workflows, express them in a specific structure, and combine template technology to achieve automatic generation of web page interface codes.
[0046] Considering that the currently widely used web development requirement description documents mostly give different functional requirements of web pages according to user categories, it is planned to improve the existing UML activity diagram, split different user roles and their workflows, introduce the concept of workflow from the perspective of the steps and processes of users using web pages, and convert the web business workflow into a certain form of data structure. This method is an optimization based on the existing software code generation method based on UML activity diagrams. It replaces object-oriented UML diagrams and their ideas with workflows, starting from the perspective of the steps and processes of users using web pages, and plans to convert workflows into a certain form of data structure, use Jinja2 template language to write templates, and combine the two to generate HTML code, realize the automatic generation of web UI code, and thus generate web UI. Figure 2 (a)-(c) are part of the workflow extracted from the requirements document of a shopping website.
[0047] The requirements that need to be analyzed for making a web UI interface mainly include the functional requirements of users. In the traditional software engineering process, the requirements analysis model is a graphical tool (UML diagram) that accurately describes the requirements, mainly including entity relationship diagrams, data flow diagrams, and state transition diagrams. The model established by the requirements analysis provides a model that can be translated into data structure, architecture, interface and processing process design for future software designers. Compared with other software, the functional requirements of the UI interface are relatively simple and intuitive, and the interface that can realize the functions that users can realize on this web page is qualified. On this basis, beautiful layout, easy user operation and familiarity are other requirements to be achieved. Therefore, the present invention intends to propose a requirements analysis method for web UI requirements, that is, from the perspective of web users, simulate the entire process and steps of users using the web page, analyze user requirements with workflow as the unit, and focus on how to sort out information from the given requirements document, summarize and summarize the functional requirements from the user's perspective, which is different from the traditional requirements analysis in terms of starting point.
[0048] UI interface design based on workflow
[0049] In the UI design stage, the traditional software engineering method is generally derived from the entity relationship diagram, data flow diagram, and state transition diagram in the previous step, which are delivered to UI designers for sketching, and finally written by coders using HTML. After obtaining the functional requirements of the web page from the perspective of users using the web page, the user's business workflow is refined and applied to design and development, which is called workflow-based interface function design.
[0050] 1) Standardization of requirements
[0051] For page development, the requirements obtained in the first step contain a lot of information. No matter what design method is used, it is very important to make the requirements standardized, accurate, and unambiguous. This determines whether the subsequent design and development will have problems with the requirements.
[0052] 2) Data structure representation
[0053] When applied to code generation templates, the most intuitive way is to use data structures as input. The workflow of users using web pages is disassembled and represented in a standardized and unified format, which generates the data structure to be used later.
[0054] In this application, a workflow corresponds to a specific data structure, the data structure is as follows Figure 3 shown.
[0055] This data structure contains the following parts:
[0056] The name of the data structure, that is, the name of the workflow, such as shopping, voting, etc., is a complete business workflow name in the web page.
[0057] Whether it is a core workflow. This is a true or false field, which is used to indicate whether this workflow is a main or key process.
[0058] Several behaviors. Behaviors are several actions in the workflow. For example, "sellers put products on shelves", "users select candidates" and other actions that contain subject, predicate and object. Each behavior should have a behavior subject (subject), verb (predicate), target object (object), *the location of the next behavior (next), *the conditional branches of the current behavior (several) (cncnt). The fields represented by * are non-essential fields.
[0059] Some conditional branches in the conditional branch include state (adverb, the condition for the action to occur, such as "when...") and trigger action (the action triggered by meeting the condition, which is the predicate verb).
[0060] Taking a shopping website as an example, the web page function requirements are as follows:
[0061]
[0062] Figure 4 (a)-(c) shows the workflow of the shopping process using data structures. The workflow parts are transformed into data structures as follows:
[0063]
[0064]
[0065] in,
[0066] $wfs.Shopping: defines an object named "Shopping".
[0067] core: true: This attribute indicates whether this shopping process object is a core process, indicating that this is a main and key process.
[0068] behaves: describes various behaviors in the shopping process.
[0069] subj, pred, obj: These are the subject, predicate, and object for each action, representing the subject, action, and object of the action.
[0070] next:-2: This attribute indicates the location of the next behavior after the current behavior is executed. It means that the next behavior is selected from the "cncnt" (conditional branch) of the current behavior.
[0071] cncnt: This attribute indicates the conditional branch of the current action. In this example, there are two possible conditional branches after the buyer views the logistics information. The first is that the buyer confirms receipt, and the second is that the system automatically confirms receipt after 15 days.
[0072] This data structure code describes several key steps in the shopping process and related behavioral rules, including the buyer selecting products, the merchant submitting the shipping order number, and the buyer checking the logistics information. At the same time, it also includes some conditional branch rules to handle possible special situations, such as if the buyer does not confirm receipt within 15 days, the system automatically confirms receipt.
[0073] Automatic code generation based on Jinja2 templates
[0074] "Boilerplate code" generally refers to code segments that are repeated almost unchanged in multiple places. This type of code is often used to complete routine, standardized programming tasks. Because this type of code is highly repetitive, it is called "boilerplate code". Template code is common in software development, especially when setting up infrastructure, writing common functionality, or when following specific programming patterns and protocols. For example, in object-oriented programming, it is often necessary to write a large number of standardized getter and setter methods, which can be considered template code.
[0075] Although boilerplate code can speed up the development process because it provides a way to quickly implement common functionality, it also has its disadvantages. Excessive use of boilerplate code can lead to code bloat, making it difficult to read and maintain. To reduce the negative impact of boilerplate code, developers and teams often seek to adopt some methods to reduce duplication of code, such as using code generation tools, frameworks, libraries, or higher-level programming paradigms (such as metaprogramming) to automate or simplify these common tasks.
[0076] Jinja2 is a very popular Python template engine for generating output in text formats ranging from HTML to XML. It is often used in web applications to dynamically generate web page content. Jinja2 is designed to be flexible and powerful, inspired by the Django template engine, but provides more expressiveness and extensibility.
[0077] 1) Page component selection and layout implementation
[0078] After obtaining all the data structures required for the web UI to implement the business according to the previous steps, the system needs to identify these data structures and match the corresponding components in the page, such as text boxes, buttons, links, etc.
[0079] 2) Template code writing
[0080] Based on the above steps and techniques, a set of web UI code is written using a template language such as Jinja2 to automatically generate templates. The input should be a data structure, and the output should be HTML code - target code. Running the target code will generate the required web page (only including UI). The template code format is shown in Figure 4.
[0081] Before using the Jinja2 template, you need to use pipeline to process the data structure obtained in the previous step. The specific steps are as follows.
[0082] The createPipe function is used to create a processing pipeline, which includes a series of modules: "humod", "integrity", "jobduty", "uipage", "database", "gql". Each module represents a processing step in the pipeline, and together they define the process of data processing and conversion.
[0083] "humod": This module is used to handle logic related to business logic, role definition, responsibility allocation, etc.
[0084] "integrity": This module is responsible for ensuring the integrity of data and processing logic. It may include tasks such as verifying data consistency, enforcing business rule validation, and ensuring data security and privacy protection.
[0085] "jobduty": This module is used for the definition and management of job responsibilities. It can be used to describe the responsibilities of different roles, task allocation, and the relationships and dependencies between responsibilities.
[0086] "uipage": This module is related to user interface (UI) design and page generation. It is used to automatically generate user interface elements and layouts based on defined logic and data, which may involve template rendering, style definition, and interaction design.
[0087] "database": This module is responsible for database-related operations, including data model definition, database access, data query and persistence.
[0088] "gql": This module is used to define data models, API queries and mutation operations, etc., in order to manage data exchange between clients and servers in an efficient and flexible way.
[0089] Among them, "humod", "integrity", and "jobduty" are the steps after the Jobduty step, and can be selected according to the situation. The process of pipeline processing workflow is as follows Figure 6 shown.
[0090] After using pipeline to process the data structure obtained in the previous step, the data can be directly called by various functions in the template code to generate the target web page code;
[0091] Then, the Jinja2 engine is used to parse the template file, and the data processed by the pipeline is bound to the template file to generate HTML code, namely the target code. Running the target code generates the required web page UI.
[0092] The present invention uses Jinja2 engine to manually write template files in advance. Jinja2 engine parses template files, binds pipeline-processed data to corresponding positions in template files, and processes any necessary logical operations, such as loops and conditional judgments. The results of the operation can be directly output to the console, or written to a file to save the generated HTML code or other types of files. The target web page is obtained by running the HTML file. Jinja2 engine parses template files containing specific tags or variables, which specify how to insert pipeline-processed data, and may also include some logical processing instructions (such as loops, conditional judgments, etc.). When Jinja2 engine receives pipeline-processed data, it fills the data into the appropriate position of the template file, processes the logical instructions, and generates the final output.
[0093] Writing template files is mainly about building a knowledge base, which is a combination of several code files. Template files: define the placeholders for the static and dynamic parts of the output document. Static objects refer to the parts that are directly output without changing during code generation. Dynamic objects require the introduction of special dynamic tags and are customized through variables or functions.
[0094] Components of a knowledge base
[0095] 1) Fixed components of the web page interface
[0096] Header, title, footer, etc. These parts are the components of most web pages.
[0097] Header: usually contains the website logo, navigation menu, login or registration link, etc. The header is the first part that users come into contact with and plays a key role in guiding users to browse the website.
[0098] Title: Each page should have a clear title that describes the theme or content of the page or website, which is very important for SEO (search engine optimization).
[0099] Footer: The footer contains copyright information, contact information, navigation links to main pages, social media links, etc.
[0100] 2) Common components of web interface
[0101] Such as buttons, input boxes, etc.
[0102] Buttons: Interface elements used for submitting forms, navigation, and other interactive commands.
[0103] Input Boxes: Allow users to enter data, commonly seen in search bars, login forms, feedback forms, etc.
[0104] Dropdown Menus: Allow users to select one option from multiple options and provide necessary functional choices.
[0105] Checkboxes and Radio Buttons: Used to select multiple options (checkboxes) or a single option (radio button) in a form.
[0106] 3) Service Block / Framework
[0107] Service blocks are a series of service modules that encapsulate specific functions. These modules can be reused in multiple applications or systems and are responsible for handling specific business logic or data processing tasks. Skeleton is used to represent the basic code structure, framework or template. This part provides developers with a set of basic structures for service modules that can be further developed and customized. This structure may be used to quickly start project development and provide some predefined services and configurations.
[0108] The key points of the present invention are as follows:
[0109] 1. The present invention proposes a workflow-based web page demand analysis and UI design:
[0110] The present invention discloses a method for automatically generating a web page UI based on workflow and template. One of the cores of the method is to convert web page functional requirements into a systematic workflow representation. Considering that the code structure of a web page UI is usually highly fixed and concise, and that different web pages have high similarities, the present invention further optimizes the existing software code generation technology based on the Unified Modeling Language (UML) activity diagram by abstracting the web page functional requirements into a workflow. By adopting a workflow to replace the traditional object-oriented UML diagram and its design concept, HTML code is automatically generated based on the process of user-web page interaction, thereby achieving fast and intuitive web page UI development.
[0111] 2. The present invention applies the pipeline-based workflow step-by-step processing to the automatic generation of web page UI:
[0112] Pipeline distributed processing technology is a method commonly used in data processing and workflow management, especially when large amounts of data need to be processed or complex tasks need to be performed. This technology relies on dividing the entire workflow into a series of interdependent steps or tasks, each of which processes input data and generates output as input for the next step. These steps can be executed in parallel or serially on different processing units or machines, thereby achieving distributed processing. In the web UI generation of this method, the pipeline settings of Pipeline are as follows.
[0113] pipeline=createPipe(["humod","integrity","jobduty","arch"])
[0114] After pipeline processing, the workflow has corresponding outputs at each step. They are:
[0115] Humod’s transformer stage:
[0116] The program processes the structure and data of the workflow during the conversion of Humod objects, including verifying node types and building internal model representations.
[0117] Integrity's fit and transformer stages:
[0118] This stage is to check and ensure the integrity of the data, including assumptions and adjustments to data types, such as the data type inference of the program processing "delivery order number".
[0119] JobDuty's fit and transformer phases:
[0120] In this phase, the program handles the mapping of roles and responsibilities, which may involve assigning roles and responsibilities based on the behaviors defined in the workflow. (e.g., merchant, administrator, buyer, etc.) Allocation of responsibilities in different workflows.
[0121] Arch:
[0122] The automatic generation of databases, interfaces, etc. can be realized later, which is not involved in the present invention.
[0123] The final output is the HTML code of the web page UI, which is run to obtain the correct target web page.
[0124] 3. The present invention proposes to use Jinja2 to write template code for web page UI generation:
[0125] Use Jinja2 to write template code as a template for automatically generating web UI code. Using highly flexible template languages such as Jinja2, you can create highly reusable UI components and layout templates, further improving development efficiency and code quality.
Claims
1. A method for automatically generating a webpage UI based on workflow and template, characterized in that: From the perspective of the steps and processes of users using web pages, the functional requirements of web pages are abstracted into workflows for different user roles; Convert the workflow into a certain form of data structure; The obtained data structure is processed step by step using pipeline. The processed data structure can be directly called by each function in the template code to generate the target web page code. Pre-write the template file, use the Jinja2 engine to parse the template file, bind the data processed by the pipeline to the template file to generate HTML code, that is, the target code, and run the target code to generate the required web page UI.
2. The method for automatically generating a webpage UI based on workflow and template according to claim 1, characterized in that: A workflow corresponds to a specific data structure, which includes: the name of the data structure, whether it is a core workflow, and several behaviors; The name of the data structure, i.e., the name of the workflow, is a complete business workflow name in the web page; Whether it is a core workflow is a true or false field, which is used to indicate whether this workflow is a key process; A number of behaviors, behaviors are a number of actions in the workflow, each behavior includes the subject of the behavior, that is, the action of the behavior, that is, the predicate, and the target object of the behavior, that is, the object.
3. A method for automatically generating a webpage UI based on workflow and template according to claim 2, characterized in that: Each behavior also includes the location of the next behavior and several conditional branches of the current behavior, where the conditional branches contain the conditions for the action to occur and the actions triggered when the conditions are met.
4. A method for automatically generating a webpage UI based on workflow and template according to claim 1, 2 or 3, characterized in that: The specific steps of pipeline step-by-step processing are as follows: Use the createPipe function to create a processing pipeline. This pipeline includes a series of modules, namely: "humod", "integrity", "jobduty". Each module represents a processing step in the pipeline. Together, they define the process of data processing and conversion. "humod": This module is used to handle business logic, role definition logic, and responsibility allocation logic; "integrity": This module is responsible for ensuring the integrity of data and processing logic, including verifying data consistency, enforcing business rule validation, and ensuring data security and privacy protection tasks; "jobduty": This module is used to define and manage job responsibilities, and to describe the responsibilities of different roles, task allocation, and the relationships and dependencies between responsibilities.
5. The method for automatically generating a webpage UI based on workflow and template according to claim 4, characterized in that: The pipeline also includes "uipage", "database", "gql"; "uipage": related to user interface UI design and page generation, used to automatically generate user interface elements and layouts based on defined logic and data, involving template rendering, style definition, and interaction design; "database": responsible for database-related operations, including data model definition, database access, data query and persistence; "gql": used to define data models, API queries, and mutation operations to manage data exchange between clients and servers in an efficient and flexible way.
6. The method for automatically generating a webpage UI based on workflow and template according to claim 5, characterized in that: The template file is used to define the static part and the dynamic part of the web page UI.
Citation Information
Cited By
Page generation method and system
CN121957594A
A page generation method and system
CN121957594B
