How y0i7/full-stack-jwt-user-manager works
1. This repository contains two separate applications that work together: a Spring Boot backend in Backen_Modules/ and a React frontend in frontend_components/. The architecture is a classic client–server split: the frontend handles user interaction, while the backend owns authentication, user data, and persistence.
2. The backend is a Java 17 / Spring Boot 3 service built around a REST-style flow. Its main entry point is BackenModulesApplication.java, and the backend is organized into controller, service, repository, model, and security/config layers.
3. The core backend business domain is “usuario” management. Usuario is the main entity, while LoginDTO and RegistroDTO are request payloads used to separate API input from the persistence model. This keeps authentication and registration data distinct from the database entity.
4. Request handling flows through two controllers: AuthenticationController for login/registration-related endpoints, and UsuarioController for user/profile-related endpoints. These controllers delegate business logic to UsuarioService, with the concrete implementation in UsuarioServiceImpl.
5. Persistence is handled through UsuarioRepository, which is the data-access boundary to SQL Server via Spring Data JPA/Hibernate. The repository/service separation suggests the application reads and writes user records primarily through a single database-backed aggregate.
6. Security is centered on JWT. WebSecurityConfig defines the Spring Security setup, JwtAuthorizationFilter intercepts requests to validate tokens, and JwtUtils encapsulates token creation/parsing. JwtRequest and JwtResponse are support models for the auth handshake. This means authenticated requests are authorized at the filter layer before reaching controllers.
7. Error handling is centralized in GlobalException, which acts as a cross-cutting boundary for API failures. That keeps controller logic simpler and makes auth/data validation errors more consistent for the frontend.
8. Backend configuration is externalized in src/main/resources/application.properties. The README indicates this file holds sensitive/runtime settings such as the JWT secret and SQL Server connection details, so the backend is environment-configured rather than hardcoded.
9. The frontend is a React application structured by feature area. Auth/LoginForm.jsx and Auth/RegisterForm.jsx handle authentication UI, Profile/Profile.jsx displays authenticated user data, Home/Home.jsx is the landing page, and Layout/Navbar.jsx plus Footer.jsx provide shared chrome.
10. Frontend state and route protection are handled in two key places: context/AuthContext.js stores auth/session state, and utils/ProtectedRoute.jsx gates access to protected screens. This indicates the UI both stores the JWT/session client-side and uses route-level checks to prevent unauthenticated navigation.
11. The frontend communicates with the backend through API calls, likely using Axios as noted in the README. The data flow is: user submits credentials in React, the backend authenticates and returns a JWT, the frontend stores that auth state, and subsequent protected requests include the token to fetch user/profile data.
12. From an architecture-diagram perspective, the important boundaries are: browser/UI, auth state management, route protection, REST API controllers, JWT security filter chain, service layer, and SQL Server persistence. The repo is also testable at both ends, with a Spring Boot test module on the backend and React testing setup on the frontend.
Main entry points: App.jsx React app · AuthenticationController.java Auth API · UsuarioController.java User API · WebSecurityConfig.java JWT security
Components 20
Frontend
React app for authentication, profile access, and shared UI.
- React app · Browser-facing UI for login, registration, profile, and navigation.
frontend_components/src/App.jsx - Auth state · Client-side session and JWT/auth state management.
frontend_components/src/context/AuthContext.js - Route guard · Prevents unauthenticated access to protected screens.
frontend_components/src/utils/ProtectedRoute.jsx - Login form · Collects credentials and starts the sign-in flow.
frontend_components/src/components/Auth/LoginForm.jsx - Register form · Collects registration data and creates new users.
frontend_components/src/components/Auth/RegisterForm.jsx - Profile view · Displays authenticated user data from the backend.
frontend_components/src/components/Profile/Profile.jsx - Shared chrome · Navbar and footer used across the app.
frontend_components/src/components/Layout/Navbar.jsx - Home page · Public landing page and entry screen.
frontend_components/src/components/Home/Home.jsx
Backend
Spring Boot API, security, and persistence for usuario management.
- Auth API · REST endpoints for login and registration.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Controller/AuthenticationController.java - User API · REST endpoints for user/profile operations.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Controller/UsuarioController.java - User service · Business contract for usuario operations.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Service/UsuarioService.java - Service impl · Implements authentication and user business logic.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Service/impl/UsuarioServiceImpl.java - User repo · Spring Data JPA boundary to the database.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Repository/UsuarioRepository.java - Usuario · Persistent user aggregate stored in SQL Server.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Model/Usuario.java - JWT security · Security configuration, JWT filter chain, and token utilities.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/config/security/WebSecurityConfig.java - Auth DTOs · Login and registration payloads plus JWT request/response models.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/Model/dto/LoginDTO.java - Error handling · Centralized API failure handling.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/config/GlobalException.java - Runtime config · Externalized settings such as database and JWT secret.
Backen_Modules/src/main/resources/application.properties - Spring Boot app · Backend application bootstrap and runtime entry point.
Backen_Modules/src/main/java/com/DEMO/Backen_Modules/BackenModulesApplication.java
Cross-cutting
Shared request/response and auth boundary concepts.
- API calls · Frontend-to-backend requests for login, registration, and profile data.
Connections 27
- React app → Home page: renders · The React app composes the landing page.
- React app → Login form: routes to · Public auth navigation reaches the login screen.
- React app → Register form: routes to · Public auth navigation reaches the registration screen.
- React app → Profile view: routes to · Protected navigation reaches the profile screen.
- React app → Shared chrome: wraps · Shared header/footer frame the UI.
- Auth state → Route guard: feeds · Route guard checks client auth state.
- Login form → Auth state: updates · Successful login stores session/JWT state.
- Register form → Auth state: updates · Registration can update auth state after signup.
- Login form → API calls: calls · Sends credentials to backend auth endpoints.
- Register form → API calls: calls · Sends registration data to backend endpoints.
- Profile view → API calls: calls · Fetches authenticated user/profile data.
- API calls → Auth API: auth requests · Login and registration requests enter the auth controller.
- API calls → User API: profile requests · Authenticated user data requests enter the user controller.
- Auth API → User service: delegates · Controllers rely on the service contract.
- User API → User service: delegates · Controllers rely on the service contract.
- User service → Service impl: implemented by · Concrete business logic lives in the implementation.
- Service impl → User repo: persists via · Service reads and writes through the repository boundary.
- User repo → Usuario: maps · Repository operates on the usuario entity.
- JWT security → Auth API: secures · JWT configuration protects controller access.
- JWT security → User API: secures · JWT configuration protects user endpoints.
- JWT security → Runtime config: reads · Security settings come from externalized properties.
- Spring Boot app → JWT security: boots · Application startup wires security and web configuration.
- Spring Boot app → Error handling: includes · Application exposes centralized exception handling.
- Auth API → Auth DTOs: uses · Auth endpoints exchange dedicated request/response payloads.
- User API → Auth DTOs: uses · User flow shares DTO boundary for API payloads.
- Error handling → Auth API: handles · Cross-cutting error handling applies to API failures.
- Error handling → User API: handles · Cross-cutting error handling applies to API failures.