Pfd-Maker / app.py
MuhammadHananKhan123's picture
Update app.py
9c0bc0f verified
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()