This Spring Boot application allows importing product and discount data from CSV files into a relational database. It supports multiple market, tracks product price history over time, and avoids duplicate discount entries within overlapping time periods.
In addition, the application includes user authentication with role-based access, and two key features for analyzing discount data.
-
CSV Import Functionality
Easily import product and discount data from multiple CSV files with different import dates. -
Product Management
Ensures that each product is unique using a combination ofproduct_codeandstore_name. -
Duplicate Discount Prevention
When importing discount data, the system checks for overlapping date ranges and avoids inserting duplicates. -
Date-Aware Logic
Correctly maps imported data to specific dates for accurate historical records.
-
Top Discounts per Store
Returns the products with the highest discount for each store on a given date. -
Today's Discounts
Returns the list of products that received a new discount today.
Both of these endpoints require the user to be authenticated.
- The application uses a simple authentication system with
UserandRoleentities. - Users can have multiple roles – implemented via a Many-to-Many relationship.
- Access to key endpoints (e.g., top discounts, today’s discounts) is restricted to authenticated users only.
- Java 17
- Spring Boot
- Spring Security
- Spring Data JPA
- PostgreSQL
- Apache Commons CSV
- Lombok
- MapStruct (optional)
- User uploads a CSV file containing product or discount data.
- Backend parses the file and:
- Checks if a product with the same
code + storealready exists. - Adds or updates the product and saves the current price to the history table.
- For discounts, validates against existing records to prevent duplicates in the same time frame.
- Checks if a product with the same
- Authenticated users can then access endpoints to analyze current and historical discount data.