Sequence and class diagrams
The actual flow illustrated. No Mermaid loading or Internet connection is required.
How to read a sequence
Each column represents a participant; time flows downwards. Numbered arrows show calls and responses on the success path. Internal library steps are grouped for readability. Errors stop the flow before the success response.
1. Login
If the account does not exist, is disabled or its password does not match, 401 is returned and no JWT is issued. Notice that the controller reloads AppUser after authenticate to issue the response.
2. Registration
Input validation may return 400. Duplicate detection or the database unique constraint may result in 409. saveAndFlush obtains the id before constructing sub.
3. Protected request
Missing or invalid JWT: 401. Disabled or deleted account: 401. Valid USER identity on an ADMIN route: 403, without running the controller. The diagram shows /me, which accepts both roles.
4. Administrative editing
Editing occurs within the service transaction. The edited account's JWT does not change: its next request reads the new role from the database. Input validation occurs when the controller resolves @Valid.
5. Class diagram
AuthController also depends on AuthenticationManager, UserRepository and PasswordEncoder; UserService uses PasswordEncoder for account creation and password changes. SecurityConfig declares those beans and the JWT converter, which also uses the repository. Spring Data implements UserRepository at runtime; the project has no handwritten repository class.
AppUser is transformed into UserResponse; AuthResponse contains a UserResponse. Requests and responses are DTOs, not database entities. GlobalExceptionHandler translates exceptions into ApiError. The diagram groups infrastructure and DTOs to show key relationships without inventorying the entire Spring library.