How gowtham-m-2005/spring-authify works
1. System shape
- Authify is a Spring Boot 4 backend that exposes a versioned REST API under /api/v1.0.
- It is a stateless authentication service: clients log in, receive a JWT, and then use that token to call protected endpoints.
2. Application bootstrap and configuration
- AuthifyApplication is the entry point.
- application.yml wires the main infrastructure: PostgreSQL, Spring Mail/SMTP, JWT secret, and the servlet context path.
- The repository is built with Maven and targets Java 21.
3. Security boundary
- SecurityConfig is the central gatekeeper for request authorization.
- JwtRequestFilter sits in the Spring Security filter chain and validates incoming JWTs before controller execution.
- CustomAuthenticationEntryPoint handles unauthenticated/unauthorized access paths.
- The README indicates the token is handled securely, including HTTP-only cookies.
4. Authentication API
- AuthController is the main API surface for:
- login
- authentication status checks
- sending password-reset OTPs
- resetting passwords
- Request/response payloads are isolated in the io package, mainly through AuthRequest, AuthResponse, and ResetPasswordRequest.
5. User identity and token generation
- AppUserDetailsService bridges the persistence model into Spring Security’s user lookup mechanism.
- JwtUtil is responsible for creating and validating JWTs.
- These two classes form the core of the “authenticate user → issue token → validate token later” flow.
6. Profile management subsystem
- ProfileController exposes protected profile operations.
- ProfileService and ProfileServiceImpl contain the business logic for reading and updating profile data.
- ProfileRequest and ProfileResponse keep API contracts separate from internal persistence models.
7. Persistence layer
- UserEntity is the JPA-backed domain object stored in PostgreSQL.
- UserDao is the data-access boundary for user records.
- The architecture follows a standard controller → service → DAO → database flow.
8. Email subsystem
- EmailService handles outbound email delivery through SMTP.
- The templates folder contains the email bodies for:
- verification
- welcome
- password reset
- This is a separate outbound integration boundary from the REST API and database layers.
9. Password reset flow
- The readme describes an OTP-based recovery flow.
- The typical path is: request OTP → email sent → user submits OTP plus new password → backend verifies and updates credentials.
- This flow crosses the auth controller, email service, and user persistence layer.
10. Package-level separation
- config = security and framework configuration
- controller = HTTP API endpoints
- service = business logic
- dao = database access
- model = JPA entities
- io = API DTOs
- filter and util = cross-cutting security/token support
11. External dependencies that matter architecturally
- Spring Security defines the authentication model and filter chain.
- Spring Data JPA + PostgreSQL provide persistence.
- Spring Mail provides outbound email delivery.
- JJWT provides token handling.
- Lombok reduces boilerplate, but doesn’t change the runtime architecture.
12. Testing and packaging
- There is a small test footprint visible (AuthifyApplicationTests), so the repo appears to rely mostly on integration-style Spring Boot wiring rather than a large standalone test harness.
- The project is packaged as a deployable Spring Boot service, with optional Docker support described in the README.
Main entry points: AuthController.java Auth API · ProfileController.java Profile API · UserDao.java User DAO · SecurityConfig.java Security config
Components 20
Bootstrap
Application entrypoint and runtime wiring
- Authify · Application entry point
src/main/java/com/frostyfox/authify/AuthifyApplication.java
Security
Authentication and request protection
- Security config · Configures authentication and authorization
src/main/java/com/frostyfox/authify/config/SecurityConfig.java - JWT filter · Validates bearer token on requests
src/main/java/com/frostyfox/authify/filter/JwtRequestFilter.java - Auth entrypoint · Handles unauthenticated and unauthorized access
src/main/java/com/frostyfox/authify/config/CustomAuthenticationEntryPoint.java - JWT util · Creates and validates JWTs
src/main/java/com/frostyfox/authify/util/JwtUtil.java - User details · Loads users for authentication
src/main/java/com/frostyfox/authify/service/AppUserDetailsService.java
API
REST controllers and request/response contracts
- Auth API · Login, status, OTP, and password reset endpoints
src/main/java/com/frostyfox/authify/controller/AuthController.java - Profile API · Protected profile operations
src/main/java/com/frostyfox/authify/controller/ProfileController.java - Auth request · Login and auth payloads
src/main/java/com/frostyfox/authify/io/AuthRequest.java - Auth response · Authentication result payload
src/main/java/com/frostyfox/authify/io/AuthResponse.java - Reset request · Password reset submission payload
src/main/java/com/frostyfox/authify/io/ResetPasswordRequest.java - Profile request · Profile update payload
src/main/java/com/frostyfox/authify/io/ProfileRequest.java - Profile response · Profile output payload
src/main/java/com/frostyfox/authify/io/ProfileResponse.java
Services
Business logic and outbound integrations
- Profile service · Profile business boundary
src/main/java/com/frostyfox/authify/service/ProfileService.java - Profile impl · Reads and updates profile data
src/main/java/com/frostyfox/authify/service/ProfileServiceImpl.java - Email service · Sends verification, welcome, and reset emails
src/main/java/com/frostyfox/authify/service/EmailService.java
Persistence
Entity and data-access layer
- User entity · Persisted user record
src/main/java/com/frostyfox/authify/model/UserEntity.java - User DAO · Database access boundary for users
src/main/java/com/frostyfox/authify/dao/UserDao.java
Infrastructure
Build, config, and runtime resources
- App config · Database, mail, JWT, and context settings
src/main/resources/application.yml - Email templates · Welcome, verification, and password reset mail bodies
src/main/resources/templates
Connections 22
- Authify → Security config: loads security · Bootstraps the security boundary
- Authify → App config: reads config · Loads runtime settings
- Security config → JWT filter: installs · Adds JWT validation to the filter chain
- Security config → Auth entrypoint: configures · Sets unauthorized access handling
- JWT filter → JWT util: validates token · Parses and checks JWTs
- JWT filter → User details: loads user · Resolves authenticated identity
- User details → User DAO: queries · Looks up user records
- User DAO → User entity: maps · Persists and reads user data
- Auth API → Auth request: accepts · Consumes login payloads
- Auth API → Auth response: returns · Emits authentication results
- Auth API → Reset request: accepts · Consumes password reset payloads
- Auth API → User details: authenticates via · Delegates identity lookup
- Auth API → JWT util: issues token · Creates JWT after successful login
- Auth API → Email service: sends otp · Triggers recovery email delivery
- Profile API → Profile service: uses · Delegates profile operations
- Profile service → Profile impl: implemented by · Concrete profile business logic
- Profile impl → User DAO: reads/writes · Persists profile changes
- Profile API → Profile request: accepts · Consumes profile updates
- Profile API → Profile response: returns · Emits profile data
- Email service → Email templates: renders · Uses HTML email bodies
- Email service → User DAO: updates user · Supports verification and reset flows
- Auth API → Profile API: shares auth boundary · Both operate behind JWT-protected access