A Point of Sale (POS) RESTful API developed using Spring. It includes CRUD operations and transaction management for Customer, Item, Order, and OrderDetail entities. The project is seamlessly integrated with Hibernate for ORM and JPA for repository management.
- CRUD operations for Customer, Item, Order, and OrderDetail entities.
- Transaction management.
- Validation using Hibernate Validator.
- Logging using Logback.
- Custom exceptions and error messages.
- DTO and Entity mapping using ModelMapper.
- Utility for Base64 image conversion.
- Configuration files for application setup.
- Java 17
- Spring Framework
- Hibernate ORM
- Spring Data JPA
- ModelMapper
- Logback
- MySQL
- Entities: Customer, Item, Order, OrderDetail
- DTOs: CustomerDTO, ItemDTO, OrderDTO
- Repositories: CustomerRepository, ItemRepository, OrderRepository, OrderDetailRepository
- Services: CustomerService, ItemService, OrderService
- Controllers: CustomerController, ItemController, OrderController
- Utilities: Mapping, AppUtil
- Exceptions: Custom exceptions for handling specific error cases
- Configuration: WebAppConfig, WebAppRootConfig
Validation is implemented using Hibernate Validator annotations in the DTO classes to ensure data integrity and correctness.
Logging is configured using Logback. Logs are written to both the console and a file.
Custom exceptions are created to handle specific error scenarios, providing meaningful error messages to the client.
- Mapping: Utility class for converting between DTOs and entities using ModelMapper.
- AppUtil: Utility class for converting MultipartFile to Base64 string for image storage.
Configuration files are used to set up the application context, data source, JPA, and transaction management.
For detailed API documentation and testing, please refer to the Postman Documentation.
This project is licensed under the MIT License. See the LICENSE file for details.
- Java 17
- MySQL
- Maven
- Clone the repository:
git clone https://github.com/gayanukabulegoda/Spring-POS-API.git
- Navigate to the project directory:
cd Spring-POS-API
- Update the MySQL database configuration in
WebAppRootConfig.java
:@Bean public DataSource dataSource() { DriverManagerDataSource dmds = new DriverManagerDataSource(); dmds.setDriverClassName("com.mysql.cj.jdbc.Driver"); dmds.setUrl("jdbc:mysql://localhost:3306/spring_pos_api?createDatabaseIfNotExist=true"); dmds.setUsername("root"); dmds.setPassword("your_password"); return dmds; }
- Build the project using Maven:
mvn clean install
- Deploy the WAR file to your preferred servlet container (e.g., Tomcat).
- Access the API endpoints using your preferred API client (e.g., Postman).
- Refer to the Postman documentation for detailed API usage.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.
© 2024 Gayanuka Bulegoda