In Agile development, it is crucial to refine the backlog to prioritize tasks, resolve problems quickly, and align development efforts with project goals. Automated tools can help in this process by generating Unified Modeling Language (UML) diagrams, allowing teams to work more efficiently with a clear understanding and communicate product requirements. This paper presents an automated approach to Agile methodology which refines backlogs by detecting duplicate user stories and clustering them. Following the refinement process, our approach generates UML diagrams automatically for each cluster, including both class and use case diagrams. Our method is based on machine learning and natural language processing techniques. To implement our approach, we developed a tool that selects the user stories file, groups them by actor, and employs the unsupervised k-means algorithm to form clusters. After that, we used Sentence Bidirectional Encoder Representations from Transformers (SBERT) to measure the similarity between user stories in a cluster. The tool highlights the most similar user stories and facilitates the decision to delete or keep them. Additionally, our approach detects similar or duplicate use cases in the UML use case diagram, making it more convenient for computer system designers. We evaluated our approach on a set of case studies using different performance measures. The results demonstrated its effectiveness in detecting duplicate user stories in the backlog and duplicate use cases. Our automated approach not only saves time and reduces errors, but it also improves collaboration between team members. With an automatic generation of UML diagrams from user stories, all team members can understand product requirements clearly and consistently, regardless of their technical expertise.