This is a simple product catalog application built using React for the frontend and Spring Boot for the backend. The application allows users to view a list of products, filter them by category, search by name, and sort them by price.
- Display a list of products
- Filter products by category
- Search for products by name
- Sort products by price (ascending or descending)
- Fetch data from a Spring Boot backend API
- React
- Vite
- Bootstrap (for styling)
- Spring Boot
- Spring Data JPA
- Hibernate
- MySQL (or any relational database)
- Node.js & npm installed
- Java (JDK 11 or later) installed
- A database (MySQL/PostgreSQL) configured
- Clone the repository:
git clone https://github.com/your-repo-url.git cd backend
- Configure the database in
application.properties
:spring.datasource.url=jdbc:mysql://localhost:3306/product_db spring.datasource.username=root spring.datasource.password=yourpassword
- Run the Spring Boot application:
mvn spring-boot:run
- Navigate to the frontend directory:
cd frontend
- Install dependencies:
npm install
- Start the React application:
npm run dev
GET /api/products/all
→ Fetch all productsGET /api/products/category/{categoryId}
→ Fetch products by category
GET /api/categories
→ Fetch all categories
- Select a category from the dropdown to filter products.
- Use the search bar to find specific products by name.
- Change the sorting option to sort by price.
- Ensure the backend is running.
- Check if there are products linked to category ID
1
in the database. - Open browser console (F12) and check for API errors.
- Run
npm run dev
in the frontend directory to restart the development server.