Problem
User registration in many APIs is binary: either the user exists and is active, or they don't exist. This project explores a more realistic flow where the user can remain in PENDING state after initial registration, with a short-lived partial token to complete the onboarding process.
Solution
API with two registration phases controlled by state (PENDING → ACTIVE) and differentiated JWT tokens. A partial token (15 min, single use) covers the activation flow; the full token enables all operations. Spring Security validates the token type on each endpoint.
Architecture
- Single-use partial token — stored in the database, invalidated when consumed or expired; prevents replay attacks in the activation flow
- MapStruct — type-safe mapping between DTOs and entities without manual reflection
- Flyway — versioned migrations for the MySQL schema
- Spring AI — module prepared for OpenAI integration; architecture ready to add AI assistance without refactoring
- OpenAPI / Swagger UI — auto-generated documentation for all endpoints
- Integration tests — coverage of the partial token repository with a dedicated database profile for testing
CR
CRUD-Test · API Usuarios con JWT
Java 21 · Spring Boot · MySQL · Flyway · JWT · Spring AI