Email-based authentication system with JWT support and email OTP verification.
- Backend: Spring Boot (Java 21, Spring Security, JPA, PostgreSQL, JavaMail)
- Frontend: React + Vite + Tailwind CSS
-
Backend
- Controller layer: src/main/java/com/authsystem/authsystem/Controller
- Service layer: src/main/java/com/authsystem/authsystem/Service
- Repository layer: src/main/java/com/authsystem/authsystem/UserRepository
- Entity models: src/main/java/com/authsystem/authsystem/Entity
- DTOs: src/main/java/com/authsystem/authsystem/dto
- Security & config:
- JWT util and filter: src/main/java/com/authsystem/authsystem/util and src/main/java/com/authsystem/authsystem/Config/JwtAuthenticationFilter.java
- Security config: src/main/java/com/authsystem/authsystem/Config/SecurityConfig.java
- Email service: src/main/java/com/authsystem/authsystem/Service/EmailService.java
- Application properties: src/main/resources/application.properties
- Build: pom.xml, mvnw, mvnw.cmd
-
Frontend (linked)
- App entry: Frontend/src/main.jsx
- Routes / components:
- Frontend/src/App.jsx
- Frontend/src/Register.jsx
- Frontend/src/Login.jsx
- Frontend/src/Profile.jsx
- API helper: Frontend/src/api/api.js
- Project config: Frontend/package.json, Frontend/vite.config.js
- Controllers handle HTTP endpoints (register, login, send-otp, verify-otp, me).
- Services contain business logic (user management, JWT generation, OTP generation/sending).
- Repositories persist entities (UserEntity) via Spring Data JPA.
- Security layer validates JWT from HttpOnly cookie, populates SecurityContext, and configures CORS/CSRF/session policies.
- Util components include JwtUtil for token creation/validation.
- EmailService sends OTPs and manages OTP lifecycle/expiry.
- Backend: configure PostgreSQL, SMTP, and JWT secret in Backend/src/main/resources/application.properties.
- Frontend: set VITE_DB_URL in Frontend/.env (example: VITE_DB_URL=http://localhost:8080). Frontend uses fetch with credentials: "include".
-
Start PostgreSQL and create DB
authsystem. Update credentials in Backend/src/main/resources/application.properties. -
Backend
- Windows:
- Backend\mvnw.cmd spring-boot:run
- Or build:
- mvn -f Backend/pom.xml clean package
- Windows:
-
Frontend
- cd Frontend
- npm install
- npm run dev
- Open http://localhost:5173
- POST /auth/register — register (name, email, password)
- POST /auth/login — login (sets HttpOnly cookie
jwt) - GET /auth/me — get authenticated user (reads cookie)
- POST /auth/send-otp — request OTP to email
- POST /auth/verify-otp — verify OTP (email, otp)
- CORS configured for http://localhost:5173 — update SecurityConfig if needed.
- For local non-HTTPS testing, adjust cookie secure settings.
- Ensure SMTP credentials are valid for OTP emails.
- Passwords hashed with BCrypt.
MIT License
Copyright (c) 2026
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
For implementation details, see the files linked above