import graphviz # Create a new Digraph for the use case diagram use_case = graphviz.Digraph(format='svg') # Define the style for nodes and edges use_case.attr('node', shape='ellipse', style='filled', color='lightgrey', fontname='Arial') use_case.attr('edge', fontname='Arial') # Define the nodes (Actors and Systems) with use_case.subgraph(name='cluster_sensor_nodes') as c: c.attr(style='dashed', color='blue', label='Ad-hoc Network') c.node('Sensor Nodes 1', 'ESP8266 Nodes\n(Temperature Sensors)') c.node('Sensor Nodes 2', 'ESP8266 Nodes\n(Temperature Sensors)') c.node('Sensor Nodes 3', 'ESP8266 Nodes\n(Temperature Sensors)') c.node('Sensor Nodes 4', 'ESP8266 Nodes\n(Temperature Sensors)') use_case.node('Exit Node', 'ESP8266\n(Exit Node)') use_case.node('Backend Server', 'Rust Backend\n(on PC)') use_case.node('Postgres DB', 'PostgreSQL\nDatabase') use_case.node('Frontend', 'Frontend\n(Web Browser/App)') use_case.node('API', 'API') use_case.node('User', 'User') # Add edges between nodes to show interactions use_case.edge('Sensor Nodes 1', 'Exit Node', label='Sends Data') use_case.edge('Sensor Nodes 2', 'Exit Node', label='Sends Data') use_case.edge('Sensor Nodes 3', 'Exit Node', label='Sends Data') use_case.edge('Sensor Nodes 4', 'Sensor Nodes 3', label='Sends Data') use_case.edge('Exit Node', 'Backend Server', label='Sends Data over WLAN') use_case.edge('Backend Server', 'Postgres DB', label='Persists Data in DB') use_case.edge('Backend Server', 'API', label='Provides API Endpoints') use_case.edge('Frontend', 'API', label='API Calls to Backend') use_case.edge('User', 'Frontend', label='Interacts with Frontend') # Render the use case diagram as an SVG use_case.render('docs/use_case_diagram') #use_case.render('/mnt/data/use_case_diagram') # Output the file path for user to download "docs/use_case_diagram.svg" #"/mnt/data/use_case_diagram.svg"