File size: 1,844 Bytes
9c0bc0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import streamlit as st
import graphviz
from io import BytesIO

# Function to create a process flow diagram
def create_flow_diagram(process_name):
    diagram = graphviz.Digraph(format="png")
    diagram.attr(rankdir="LR")
    
    # Example of a simple flow
    diagram.node("Start", "Start")
    diagram.node("Process", process_name)
    diagram.node("End", "End")
    
    # Add edges
    diagram.edge("Start", "Process")
    diagram.edge("Process", "End")
    
    return diagram

# Function to generate explanation
def generate_explanation(process_name):
    explanation = (
        f"The process named '{process_name}' begins with the initiation phase (Start), "
        f"then transitions through the core processing stage (Process), "
        f"and finally concludes in the termination phase (End). This flow ensures clarity and simplicity in execution."
    )
    return explanation

# Streamlit App
def main():
    st.title("Process Flow Diagram & Explanation Generator")
    
    # Input for the process name
    process_name = st.text_input("Enter the name of the process:", "Example Process")
    
    if process_name:
        # Display process flow diagram
        st.subheader("Process Flow Diagram")
        diagram = create_flow_diagram(process_name)
        diagram_data = diagram.pipe()
        
        # Display Diagram
        st.image(BytesIO(diagram_data), format="PNG")
        
        # Display explanation
        st.subheader("Process Explanation")
        explanation = generate_explanation(process_name)
        st.write(explanation)

        # Provide download options
        st.download_button(
            label="Download Diagram as PNG",
            data=diagram_data,
            file_name=f"{process_name}_flow_diagram.png",
            mime="image/png"
        )

if __name__ == "__main__":
    main()