The Customer Reward Program is a simple SpringBoot based repository that allows businesses to implement a customer loyalty program based on recorded purchases. This system enables businesses to reward their customers with points for each purchase made, encouraging repeat business and fostering customer loyalty.
A customer receives 2 points for every dollar spent over $100 in each transaction, plus 1 point for every dollar spent between $50 and $100 in each transaction. (e.g. a $120 purchase = 2x$20 + 1x$50 = 90 points).
To run this application, you will need the following:
- Java Development Kit (JDK) 17 or higher
- Apache Maven
- Internet connection to download dependencies
- SpringBoot - 3.1.2
- Junit - 5
- OpenJDK - 17
- OpenAPI for Swagger page - 2.1.0
Follow these steps to get the application up and running on your local machine:
- Clone the repository: git clone https://github.com/neerajkmsharma/customer-reward-program.git
- Navigate to the project directory: cd customer-reward-program
- Build the project using Maven: mvn clean install
- Run the application: mvn customer-reward-program:run
The application should now be accessible at http://localhost:9090/swagger-ui/index.html
API end point - http://localhost:9090/customer-reward-program/api/v1/{customerId}/reward-points
-
The application follows a standard SpringBoot project structure:
-
Swagger page
-
H2 Database screenshot A. Table CUSTOMER_DETAIL B. TRANSACTION_DETAIL
-
src/main/java: Contains all Java source code, including controllers, models, repositories, services and etc.
-
src/main/resources: Contains application yaml.
-
src/test/java: Contains test classes for unit and integration testing.
-
pom.xml: The Maven configuration file for managing project dependencies.
The Customer Reward Program application showcases the following features:
- RESTful API endpoints for basic CRUD operations on entities.
- Dependency injection using Spring's @Autowired annotation.
- Persistence using Spring Data JPA with an embedded H2 database (can be easily switched to other databases).
- Custom exception handling using @RestControllerAdvice.
- Enabled Swagger page with OpenAPI
The application's default configuration can be found in the application.yaml file under the src/main/resources directory. Customize the properties as per your needs
None
Neeraj Kumar Sharma