The automated generation of class diagrams is a crucial task in software engineering, facilitating the understanding, analysis, and documentation of complex software systems. Traditional manual approaches are time and energy consuming, error-prone, and lack consistency. To address these challenges, this research presents an automated proposed approach that utilizes Graph Neural Networks (GNNs), a machine learning algorithm, to generate class diagrams from source code within the context of Model Driven Architecture (MDA) and reverse engineering. A comprehensive case study is conducted to compare the results obtained from the automated approach with manually created class diagrams. The GNN model demonstrates high accuracy in capturing the system’s structure, associations, and relationships. Notably, the automated approach significantly reduces the time required for class diagram generation, leading to substantial time and energy savings. By advancing automated software documentation, this research contributes to more efficient software engineering practices. It promotes consistency, eliminates human errors, and enables software engineers to focus on higher-value tasks. Overall, the proposed approach showcases the potential of GNNs in automating class diagram generation and its practical benefits for software development and documentation.