fork download
  1. # Re-importing necessary libraries and re-drawing the diagram for the website system as explained earlier.
  2.  
  3. import matplotlib.pyplot as plt
  4. import matplotlib.patches as mpatches
  5.  
  6. # Create figure for component diagram
  7. fig, ax = plt.subplots(figsize=(10, 8))
  8.  
  9. # Function to create component boxes with labels
  10. def create_component(ax, x, y, width, height, label, color='lightblue'):
  11. ax.add_patch(mpatches.FancyBboxPatch((x, y), width, height, boxstyle="round,pad=0.3", edgecolor='black', facecolor=color, lw=2))
  12. ax.text(x + width/2, y + height/2, label, ha='center', va='center', fontsize=10, fontweight='bold')
  13.  
  14. # Title for component diagram
  15. ax.set_title('Component Diagram for ĐHCN Website System', fontsize=14, fontweight='bold')
  16.  
  17. # Creating components for the website system
  18. create_component(ax, 0.5, 7, 3, 1, "Client (Browser)")
  19. create_component(ax, 0.5, 5, 3, 1, "Web Server 1")
  20. create_component(ax, 4, 5, 3, 1, "Web Server 2")
  21. create_component(ax, 0.5, 3, 3, 1, "Database Server 1 (SQL/Oracle)")
  22. create_component(ax, 4, 3, 3, 1, "Database Server 2 (SQL/Oracle)")
  23.  
  24. # Label the user role components
  25. create_component(ax, 0.5, 1, 3, 1, "Module: News")
  26. create_component(ax, 4, 1, 3, 1, "Module: Forum")
  27. create_component(ax, 7, 1, 3, 1, "Module: Recruitment")
  28.  
  29. # Adding arrows between components
  30. ax.annotate('', xy=(2, 7), xytext=(2, 6), arrowprops=dict(facecolor='black', shrink=0.05)) # Client to Web Server 1
  31. ax.annotate('', xy=(5.5, 7), xytext=(5.5, 6), arrowprops=dict(facecolor='black', shrink=0.05)) # Client to Web Server 2
  32. ax.annotate('', xy=(2, 5), xytext=(2, 4), arrowprops=dict(facecolor='black', shrink=0.05)) # Web Server 1 to DB1
  33. ax.annotate('', xy=(5.5, 5), xytext=(5.5, 4), arrowprops=dict(facecolor='black', shrink=0.05)) # Web Server 2 to DB2
  34.  
  35. # Remove axes
  36. ax.set_xticks([])
  37. ax.set_yticks([])
  38.  
  39. # Show the component diagram
  40. plt.show()
  41. # your code goes here
Success #stdin #stdout 1.69s 56808KB
stdin
Standard input is empty
stdout
Standard output is empty