# abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management architecture

> Architecture diagram of the GitHub repository abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management
- Repository: https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management

## Overview

This is a Spring Boot REST API for user registration, login, and JWT-protected requests. The main workflow is: a client submits credentials or registration data to the user endpoints; registration hashes the password and persists the user, while login authenticates through Spring Security and returns a JWT. Later requests pass through the configured JWT filter, which validates the token and loads the user before protected endpoints run. The source excerpts show these calls; database provisioning and runtime configuration are not included.

Main entry points: [`src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/controller/UserController.java) (User endpoints), [`src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java`](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java) (Security configuration), [`src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java`](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java) (User repository), [`src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java`](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java) (JWT request filter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_userapi["User endpoints"]
  node_homeapi["Home endpoints"]
end

subgraph group_security["Authentication"]
  node_securityconfig["Security configuration"]
  node_jwtfilter["JWT request filter<br/>[JwtFilter.java]"]
  node_jwtservice["JWT service<br/>[JwtService.java]"]
  node_userdetails["User details lookup"]
  node_authmanager["Authentication manager"]
end

subgraph group_users["User records"]
  node_userservice["User service<br/>[UserService.java]"]
  node_userrepo["User repository<br/>[UserRepo.java]"]
  node_usermodel["User account<br/>[User.java]"]
  node_role["Account role<br/>[Role.java]"]
end

node_client(("API client"))
node_database[("Configured database")]
node_application["Spring application"]

node_client -->|"sends requests"| node_userapi
node_client -->|"requests pages"| node_homeapi
node_userapi -->|"registers, lists"| node_userservice
node_userapi -->|"authenticates login"| node_authmanager
node_userapi -->|"creates token"| node_jwtservice
node_userservice -->|"saves, reads"| node_userrepo
node_userdetails -->|"looks up email"| node_userrepo
node_userrepo -->|"persists entity"| node_usermodel
node_usermodel -->|"uses role"| node_role
node_jwtfilter -->|"extracts, validates"| node_jwtservice
node_jwtfilter -->|"loads account"| node_userdetails
node_securityconfig -->|"registers filter"| node_jwtfilter
node_securityconfig -->|"configures provider"| node_userdetails
node_securityconfig -->|"exposes manager"| node_authmanager
node_userrepo -.->|"uses JPA store"| node_database
node_application -.->|"starts application"| node_securityconfig

click node_userapi "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/controller/UserController.java"
click node_homeapi "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/controller/HomeController.java"
click node_securityconfig "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java"
click node_jwtfilter "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java"
click node_jwtservice "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/JwtService.java"
click node_userdetails "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/MyUserDetailsService.java"
click node_userservice "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/UserService.java"
click node_userrepo "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java"
click node_usermodel "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/model/User.java"
click node_role "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/enums/Role.java"
click node_application "https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/SecurityLastChanceApplication.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_userapi,node_homeapi,node_client toneBlue
class node_securityconfig,node_jwtfilter,node_jwtservice,node_userdetails,node_authmanager,node_database toneAmber
class node_userservice,node_userrepo,node_usermodel,node_role toneMint
class node_application toneTeal
```

## Components

### REST API

- [User endpoints](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/controller/UserController.java): `src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`
- [Home endpoints](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/controller/HomeController.java): `src/main/java/com/elmn/SecurityLastChance/controller/HomeController.java`

### Authentication

- [Security configuration](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java): `src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java`
- [JWT request filter](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java): `src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java`
- [JWT service](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/JwtService.java): `src/main/java/com/elmn/SecurityLastChance/service/JwtService.java`
- [User details lookup](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/MyUserDetailsService.java): `src/main/java/com/elmn/SecurityLastChance/service/MyUserDetailsService.java`
- **Authentication manager**

### User records

- [User service](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/service/UserService.java): `src/main/java/com/elmn/SecurityLastChance/service/UserService.java`
- [User repository](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java): `src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java`
- [User account](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/model/User.java): `src/main/java/com/elmn/SecurityLastChance/model/User.java`
- [Account role](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/enums/Role.java): `src/main/java/com/elmn/SecurityLastChance/enums/Role.java`

### Other components

- **API client**
- **Configured database**
- [Spring application](https://github.com/abdallahelameen/spring-boot-rest-api-with-jwt-authentication-and-user-management/blob/main/src/main/java/com/elmn/SecurityLastChance/SecurityLastChanceApplication.java): `src/main/java/com/elmn/SecurityLastChance/SecurityLastChanceApplication.java`

## Connections

- API client → User endpoints: sends requests (evidence: `src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`)
- API client → Home endpoints: requests pages (evidence: `src/main/java/com/elmn/SecurityLastChance/controller/HomeController.java`)
- User endpoints → User service: registers, lists (evidence: `src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`)
- User endpoints → Authentication manager: authenticates login (evidence: `src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`)
- User endpoints → JWT service: creates token (evidence: `src/main/java/com/elmn/SecurityLastChance/controller/UserController.java`)
- User service → User repository: saves, reads (evidence: `src/main/java/com/elmn/SecurityLastChance/service/UserService.java`)
- User details lookup → User repository: looks up email (evidence: `src/main/java/com/elmn/SecurityLastChance/service/MyUserDetailsService.java`)
- User repository → User account: persists entity (evidence: `src/main/java/com/elmn/SecurityLastChance/repo/UserRepo.java`)
- User account → Account role: uses role (evidence: `src/main/java/com/elmn/SecurityLastChance/model/User.java`)
- JWT request filter → JWT service: extracts, validates (evidence: `src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java`)
- JWT request filter → User details lookup: loads account (evidence: `src/main/java/com/elmn/SecurityLastChance/config/JwtFilter.java`)
- Security configuration → JWT request filter: registers filter (evidence: `src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java`)
- Security configuration → User details lookup: configures provider (evidence: `src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java`)
- Security configuration → Authentication manager: exposes manager (evidence: `src/main/java/com/elmn/SecurityLastChance/config/SecurityConfig.java`)
- User repository → Configured database: uses JPA store
- Spring application → Security configuration: starts application
