Skip to content

An efficient, modular POS system built on the robust Spring Framework, designed to manage customers, items, and orders seamlessly.

License

Notifications You must be signed in to change notification settings

gayanukabulegoda/Spring-POS-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring POS API

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.

Features

  • 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.

Tech Stack

  • Java 17
  • Spring Framework
  • Hibernate ORM
  • Spring Data JPA
  • ModelMapper
  • Logback
  • MySQL

Project Structure

  • 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

Validation is implemented using Hibernate Validator annotations in the DTO classes to ensure data integrity and correctness.

Logging

Logging is configured using Logback. Logs are written to both the console and a file.

Custom Exceptions

Custom exceptions are created to handle specific error scenarios, providing meaningful error messages to the client.

Utilities

  • Mapping: Utility class for converting between DTOs and entities using ModelMapper.
  • AppUtil: Utility class for converting MultipartFile to Base64 string for image storage.

Configuration

Configuration files are used to set up the application context, data source, JPA, and transaction management.

Postman Documentation

For detailed API documentation and testing, please refer to the Postman Documentation.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Getting Started

Prerequisites

  • Java 17
  • MySQL
  • Maven

Installation

  1. Clone the repository:
    git clone https://github.com/gayanukabulegoda/Spring-POS-API.git
  2. Navigate to the project directory:
    cd Spring-POS-API
  3. 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;
    }
  4. Build the project using Maven:
    mvn clean install
  5. Deploy the WAR file to your preferred servlet container (e.g., Tomcat).

Usage

  • Access the API endpoints using your preferred API client (e.g., Postman).
  • Refer to the Postman documentation for detailed API usage.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.


© 2024 Gayanuka Bulegoda