This is a RestAPI for a restaurant management system. It allows users to manage menus, tables, and transactions. The API is secured with JWT authentication and authorization.
Warung Makan Bahari is a renowned restaurant in Indonesia, with branches spread across several islands. The API provides a comprehensive solution for managing various aspects of the restaurant's operations.
- User registration.
- User login.
- JWT authentication.
- Menu management.
- Table management.
- Transaction management.
- Exception handling.
- Email verification.
- Java 17
- Spring Boot
- Spring IoC
- Spring Data JPA
- Spring Security
- Spring Validation
- Java Mail Sender
- JWT
- AuthO
- PostgreSQL
- IText PDF
- Swagger OpenAPI
- Lombok
- Maven
The project is structured into several folders:
config
: Contains the configuration classes for beans.constant
: Contains the constant classes for the API.controller
: Contains the REST controllers for the API.dto
: Contains the data transfer objects for the API.entity
: Contains the JPA entities for the database.repository
: Contains the JPA repositories for the entities.scheduler
: Contains the scheduler classes for manage the schedule task.security
: Contains the classes for JWT authentication and authorization.service
: Contains the service classes for the API.specification
: Contains the specification classes for filter the data.util
: Contains the utility classes for helpers function.validation
: Contains the validation classes for make a custom annotation.
- Clone the repository.
- Create a PostgreSQL database.
- Update the
application.properties
file with your database configuration. - Run the application.
mvn spring-boot:run
- Open your browser and navigate to
http://localhost:8080/swagger-ui/index.html
to view the API documentation. - You can log in with the default admin account:
- Email:
[email protected]
- Password:
password
- Email:
The API exposes the following endpoints:
GET /api/auth/login
: Logs in a user and returns a JWT token.{ "email": "string", "password": "string" }
POST /api/auth/register
: Registers a new user.{ "name": "string", "phone": "string", "address": "string" }
POST /api/auth/register/admin
: Registers a new admin user.{ "name": "string", "phone": "string", "address": "string" }
GET /api/auth/verify-account
: Verify the email account with otp.GET /api/auth/validate-token
: Validates a JWT token.GET /api/auth/regenerate-top
: Regenerate the otp for verify the email account.
GET /api/customerss
: Returns a list of all customers.GET /api/customers/{id}
: Returns a customer by ID.PUT /api/customers
: Updates a customer.{ "id": "string", "customerName": "string", "phoneNumber": " string" }
DELETE /api/customers/{id}
: Deletes a customer by ID.
GET /api/menus
: Returns a list of all menus.GET /api/menus/{id}
: Returns a menu by ID.POST /api/menus
: Creates a new menu.{ "menuName": "string", "price": "string", "image": "multipart/form-data" }
PUT /api/menus
: Updates a menu by ID.{ "id": "string", "menuName": "string", "price": "string", "image": "multipart/form-data" }
DELETE /api/menus/{id}
: Deletes a menu by ID.
GET /api/tables
: Returns a list of all tables.GET /api/tables/{id}
: Returns a table by ID.POST /api/tables
: Creates a new table.{ "tableName": "string" }
PUT /api/tables
: Updates a table by ID.{ "id": "string", "tableName": "string" }
DELETE /api/tables/{id}
: Deletes a table by ID.
GET /api/trans-types
: Returns a list of all trans types.GET /api/trans-type/{id}
: Return a trans type by id,PUT /api/trans-types
: Updates trans type.{ "id": "string", "description": "string" }
GET /api/bills
: Returns a list of all transactions.POST /api/bills
: Creates a new transaction.{ "customerId": "string", "tableId": "string", "billDetailRequests": [ { "menuId": "string", "qty": 1 } ] }
POST /api/bills/status
: Update the status of transaction.
GET /api/menus/images/{imageId}
: Returns download the image by image id.