As designated for my personal research AI-generated code, most of the codes are AI-generated. But feel free to fork, clone or whatever you want at your own risk. For questions or professional inquiries: Linkedin
- User registration with email/phone verification
- OTP-based email verification
- JWT authentication
- Rate limiting for OTP verification
- Secure password storage with BCrypt
- PostgreSQL database
- Docker support
- Java 17 or higher
- Docker and Docker Compose
- Gmail account (for sending OTP emails)
-
Update email configuration in
docker-compose.yml
:[email protected] SMTP_PASSWORD=your-app-password
Note: For Gmail, you'll need to generate an App Password. Go to Google Account > Security > 2-Step Verification > App Passwords
-
(Optional) Update other configuration in
docker-compose.yml
:- JWT secret
- Database credentials
- Port mappings
-
Build and start the containers:
docker-compose up --build
-
The API will be available at
http://localhost:8080
-
Register a new user:
POST /api/v1/auth/register Content-Type: application/json { "firstName": "John", "lastName": "Doe", "email": "[email protected]", "phoneNumber": "+1234567890", "password": "securepassword" }
-
Verify OTP:
POST /api/v1/auth/verify-otp Content-Type: application/json { "email": "[email protected]", "otp": "123456" }
POST /api/v1/auth/login
Content-Type: application/json
{
"email": "[email protected]",
"password": "securepassword"
}
This project uses Swagger UI for API documentation. The API documentation is automatically generated from the code and can be accessed through a web interface.
- Start the application
- Open your browser and navigate to: http://localhost:8080/swagger-ui/index.html
- The Swagger UI interface will display all available API endpoints grouped by their controllers.
- Each endpoint shows:
- HTTP method (GET, POST, PUT, DELETE)
- Path
- Description
- Request parameters
- Request body schema (if applicable)
- Response schema
- Authentication requirements
Most endpoints are protected and require authentication. To use these endpoints:
- First, use the authentication endpoints to get a JWT token:
- Register a new user (
/api/v1/auth/register
) - Login with credentials (
/api/v1/auth/authenticate
)
- Register a new user (
- Click the 'Authorize' button (🔒) at the top of the page
- In the authorization popup:
- Enter your JWT token in the format:
Bearer your-token-here
- Click 'Authorize'
- Enter your JWT token in the format:
- You can now access protected endpoints
- Click on any endpoint to expand it
- Click 'Try it out'
- Fill in the required parameters or request body
- Click 'Execute'
- The response will be displayed below
- Password Hashing: BCrypt is used for secure password storage
- JWT Authentication: Secure token-based authentication
- Rate Limiting: Prevents brute force attacks on OTP verification
- Input Validation: All user inputs are validated
- Email Verification: Two-step verification process
To run the application locally without Docker:
- Start a PostgreSQL instance
- Update
application.yml
with your database and email configurations - Run the application:
./gradlew bootRun
Run the tests using:
./gradlew test