This project is a Gym Management System built using Java and Spring Boot. It allows users to manage gym memberships, including user registration with unique phone numbers and email addresses, and invoice management.
To run it locally just pull it from docker hub in the CLI->
docker pull iamrishi47/gym-appLink to docker hub - https://hub.docker.com/r/iamrishi47/gym-app
- User registration with validation for unique phone numbers and email addresses.
- Custom exception handling for duplicate phone numbers and email addresses.
- Invoice management with validation to prevent duplicate invoices for the same user.
- RESTful API endpoints for user and invoice management.
- Pagination support for retrieving invoices.
- Java
- Spring Boot
- Spring Data JPA
- Hibernate
- Maven
- Lombok
- Java 11 or higher
- Maven
- An IDE (e.g., IntelliJ IDEA)
-
Clone the repository:
git clone https://github.com/Heisen47/gym-management-system.git
-
Navigate to the project directory:
cd gym-management-system -
Install the dependencies:
mvn install
-
Build the project:
mvn clean package
-
Run the application:
mvn spring-boot:run
http://localhost:8080/swagger-ui/index.htmlPOST /auth/login: Authenticate a user and generate a JWT token.
Request Body:
{
"username": "admin@example.com",
"password": "password123"
}Response:
{
"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expiryDate": "2023-10-02T10:00:00Z",
"roles": ["ROLE_ADMIN"]
}POST /admin/register: Register a new admin.
Request Body:
{
"email": "admin@example.com",
"password": "password123",
"mobile": "1234567890",
"name": "Admin Name"
}Response:
{
"message": "Admin registered successfully"
}GET /users: Retrieve all users.
Response:
[
{
"id": 1,
"name": "John Doe",
"email": "john.doe@example.com",
"phoneNumber": "1234567890",
"membership": true
}
]POST /users: Add a new user.
Request Body:
{
"name": "John Doe",
"email": "john.doe@example.com",
"phoneNumber": "1234567890",
"membership": true
}Response:
{
"id": 1,
"name": "John Doe",
"email": "john.doe@example.com",
"phoneNumber": "1234567890",
"membership": true
}POST /admin/invoice: Create a new invoice.
Request Body:
{
"invoiceAmount": "100.00",
"invoiceDate": "2023-10-01T10:00:00Z",
"invoicedBy": "Admin",
"payment": {
"paymentId": 1
},
"product": "Gym Membership",
"user": {
"userId": 1
}
}Response:
{
"invoiceId": 1,
"invoiceAmount": "100.00",
"invoiceDate": "2023-10-01T10:00:00Z",
"invoicedBy": "Admin",
"payment": {
"paymentId": 1
},
"product": "Gym Membership",
"user": {
"userId": 1
}
}GET /admin/invoice/{userId}/latest: Retrieve the latest invoice for a user.
Response:
{
"invoiceId": 1,
"invoiceAmount": "100.00",
"invoiceDate": "2023-10-01T10:00:00Z",
"invoicedBy": "Admin",
"payment": {
"paymentId": 1
},
"product": "Gym Membership",
"user": {
"userId": 1
}
}GET /admin/invoice/{userId}/paginated: Retrieve paginated invoices for a user. Requires pagination parameters (e.g., ?page=0&size=10).
Response:
{
"content": [
{
"invoiceId": 1,
"invoiceAmount": "100.00",
"invoiceDate": "2023-10-01T10:00:00Z",
"invoicedBy": "Admin",
"payment": {
"paymentId": 1
},
"product": "Gym Membership",
"user": {
"userId": 1
}
}
],
"pageable": {
"pageNumber": 0,
"pageSize": 10
},
"totalElements": 1,
"totalPages": 1
}The application handles duplicate phone numbers, email addresses, and invoices by throwing custom exceptions and returning appropriate HTTP status codes.
DuplicatePhoneNumberExceptionDuplicateEmailExceptionInvalidInvoiceDataException
The GlobalExceptionHandler class handles these exceptions and returns appropriate HTTP status codes.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries, please contact Heisen47 on GitHub.