# multiservices-psi/authentication_backend architecture

> Architecture diagram of the GitHub repository multiservices-psi/authentication_backend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/multiservices-psi/authentication_backend
- Repository: https://github.com/multiservices-psi/authentication_backend
- Video tour (about a minute): https://gitdiagram.com/multiservices-psi/authentication_backend/video

## Overview

This is a Spring Boot authentication API. Clients register or sign in with username/email and password, or authenticate with a Google ID token; successful flows return an internal JWT. Subsequent protected requests present that token for validation and user loading. The graph also includes the local credential lookup and Google verification branches. Security configuration and protected-route behavior are described in the README, but their implementation was not sampled, so wiring beyond the documented filter/security roles is omitted.

Main entry points: [`src/main/java/promo67/login/invent/auth/AuthService.java`](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthService.java) (Local auth service), [`src/main/java/promo67/login/invent/auth/AuthGoogleService.java`](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthGoogleService.java) (Google auth service), [`src/main/java/promo67/login/invent/auth/AuthController.java`](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthController.java) (Auth controller), [`src/main/java/promo67/login/invent/jwt/JwtAutenticationFilter.java`](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/JwtAutenticationFilter.java) (JWT filter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Authentication API"]
  node_controller["Auth controller"]
  node_authservice["Local auth service<br/>[AuthService.java]"]
  node_googleservice["Google auth service"]
  node_errors["Exception handler"]
end

subgraph group_identity["Identity and tokens"]
  node_googleverify["Google token verifier"]
  node_jwtservice["JWT service<br/>[JwtService.java]"]
end

subgraph group_security["Request security"]
  node_jwtfilter["JWT filter"]
  node_securityconfig["Security configuration"]
  node_appconfig["Auth provider setup"]
  node_manager["Authentication manager"]
  node_userdetails["User details lookup"]
  node_encoder["Password encoder"]
end

subgraph group_persistence["User persistence"]
  node_repository["User repository"]
  node_user["User model<br/>[User.java]"]
  node_database[("MySQL database")]
end

node_client(("API client"))
node_google(("Google identity"))

node_client -->|"sends auth request"| node_controller
node_controller -->|"dispatches local auth"| node_authservice
node_controller -->|"dispatches Google auth"| node_googleservice
node_authservice -->|"authenticates credentials"| node_manager
node_authservice -->|"checks and saves user"| node_repository
node_authservice -->|"hashes password"| node_encoder
node_authservice -->|"issues JWT"| node_jwtservice
node_googleservice -->|"verifies ID token"| node_googleverify
node_googleverify -->|"checks token"| node_google
node_googleservice -->|"finds or saves user"| node_repository
node_googleservice -->|"hashes generated password"| node_encoder
node_googleservice -->|"issues JWT"| node_jwtservice
node_jwtservice -->|"returns token"| node_controller
node_repository -->|"reads and writes users"| node_database
node_manager -->|"loads principal"| node_userdetails
node_userdetails -->|"looks up username or email"| node_repository
node_appconfig -->|"provides bean"| node_manager
node_appconfig -->|"provides bean"| node_userdetails
node_appconfig -->|"provides BCrypt bean"| node_encoder
node_securityconfig -->|"configures filter"| node_jwtfilter
node_client -->|"sends bearer token"| node_jwtfilter
node_jwtfilter -->|"validates token"| node_jwtservice
node_jwtfilter -->|"loads token user"| node_userdetails
node_jwtfilter -->|"continues secured request"| node_securityconfig
node_controller -->|"raises handled errors"| node_errors

click node_controller "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthController.java"
click node_authservice "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthService.java"
click node_googleservice "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthGoogleService.java"
click node_errors "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/exception/GlobalExceptionHandler.java"
click node_googleverify "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/GoogleTokenVerifierService.java"
click node_jwtservice "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/JwtService.java"
click node_jwtfilter "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/JwtAutenticationFilter.java"
click node_securityconfig "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/SecurityConfig.java"
click node_appconfig "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java"
click node_manager "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java"
click node_userdetails "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java"
click node_encoder "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java"
click node_repository "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/models/UserRepository.java"
click node_user "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/models/User.java"
click node_database "https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/resources/application.properties"

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_controller,node_authservice,node_googleservice,node_errors,node_client toneBlue
class node_googleverify,node_jwtservice toneAmber
class node_jwtfilter,node_securityconfig,node_appconfig,node_manager,node_userdetails,node_encoder toneMint
class node_repository,node_user,node_database toneRose
class node_google toneIndigo
```

## Components

### Authentication API

- [Auth controller](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthController.java): `src/main/java/promo67/login/invent/auth/AuthController.java`
- [Local auth service](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthService.java): `src/main/java/promo67/login/invent/auth/AuthService.java`
- [Google auth service](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/auth/AuthGoogleService.java): `src/main/java/promo67/login/invent/auth/AuthGoogleService.java`
- [Exception handler](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/exception/GlobalExceptionHandler.java): `src/main/java/promo67/login/invent/exception/GlobalExceptionHandler.java`

### Identity and tokens

- [Google token verifier](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/GoogleTokenVerifierService.java): `src/main/java/promo67/login/invent/jwt/GoogleTokenVerifierService.java`
- [JWT service](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/JwtService.java): `src/main/java/promo67/login/invent/jwt/JwtService.java`

### Request security

- [JWT filter](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/jwt/JwtAutenticationFilter.java): `src/main/java/promo67/login/invent/jwt/JwtAutenticationFilter.java`
- [Security configuration](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/SecurityConfig.java): `src/main/java/promo67/login/invent/config/SecurityConfig.java`
- [Auth provider setup](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java): `src/main/java/promo67/login/invent/config/ApplicationConfig.java`
- [Authentication manager](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java): `src/main/java/promo67/login/invent/config/ApplicationConfig.java`
- [User details lookup](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java): `src/main/java/promo67/login/invent/config/ApplicationConfig.java`
- [Password encoder](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/config/ApplicationConfig.java): `src/main/java/promo67/login/invent/config/ApplicationConfig.java`

### User persistence

- [User repository](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/models/UserRepository.java): `src/main/java/promo67/login/invent/models/UserRepository.java`
- [User model](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/java/promo67/login/invent/models/User.java): `src/main/java/promo67/login/invent/models/User.java`
- [MySQL database](https://github.com/multiservices-psi/authentication_backend/blob/main/src/main/resources/application.properties): `src/main/resources/application.properties`

### Other components

- **API client**
- **Google identity**

## Connections

- API client → Auth controller: sends auth request
- Auth controller → Local auth service: dispatches local auth
- Auth controller → Google auth service: dispatches Google auth
- Local auth service → Authentication manager: authenticates credentials
- Local auth service → User repository: checks and saves user
- Local auth service → Password encoder: hashes password
- Local auth service → JWT service: issues JWT
- Google auth service → Google token verifier: verifies ID token
- Google token verifier → Google identity: checks token
- Google auth service → User repository: finds or saves user
- Google auth service → Password encoder: hashes generated password
- Google auth service → JWT service: issues JWT
- JWT service → Auth controller: returns token
- User repository → MySQL database: reads and writes users
- Authentication manager → User details lookup: loads principal
- User details lookup → User repository: looks up username or email
- Auth provider setup → Authentication manager: provides bean
- Auth provider setup → User details lookup: provides bean
- Auth provider setup → Password encoder: provides BCrypt bean
- Security configuration → JWT filter: configures filter
- API client → JWT filter: sends bearer token
- JWT filter → JWT service: validates token
- JWT filter → User details lookup: loads token user
- JWT filter → Security configuration: continues secured request
- Auth controller → Exception handler: raises handled errors
