Skip to content

Commit 2fa5258

Browse files
Create README.md
1 parent 9e00d50 commit 2fa5258

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Spring IOC, Beans, and JPA: Product Catalog System
2+
3+
This repository contains a Spring Boot project that implements a Product Catalog System using Spring IOC, Beans, and Spring Data JPA. The project allows users to add products to a catalog and display products by category in a tabular format on a web page.
4+
5+
## Project Structure
6+
7+
- **src/main/java/com/example/demo/**
8+
- **entity/Product.java**: The JPA entity class for the Product with attributes `name`, `price`, and `category`.
9+
- **repository/ProductRepository.java**: Spring Data JPA repository interface with a method to fetch products by category.
10+
- **service/ProductService.java**: Service class to handle business logic for adding and retrieving products.
11+
- **controller/ProductController.java**: Controller class to handle HTTP requests and render HTML pages.
12+
- **src/main/resources/templates/**
13+
- **index.html**: The homepage with options to "Add Product" or "Display Product".
14+
- **add-product.html**: HTML form to add a new product (name, price, category).
15+
- **display-products.html**: HTML page to display all products in a tabular format.
16+
- **src/main/resources/application.properties**: Configuration file for the database (e.g., H2 in-memory database).
17+
- **pom.xml**: Maven configuration file with dependencies for Spring Boot, Spring Data JPA, Thymeleaf, and H2 database.
18+
- **screenshots/**: Contains screenshots of the project (e.g., homepage.png, add-product.png, display-products.png).
19+
20+
## Task Description
21+
22+
### Q1: Product Catalog System
23+
This task involves creating a web-based Product Catalog System with the following features:
24+
- **Homepage**:
25+
- A RESTful endpoint (`/`) displays an HTML page with two options:
26+
1. Add Product
27+
2. Display Product
28+
- **Add Product**:
29+
- Clicking "Add Product" navigates to `/add-product`, displaying a form to input:
30+
- Product Name
31+
- Price
32+
- Category
33+
- Submitting the form saves the product to the database using Spring Data JPA.
34+
- **Display Product**:
35+
- Clicking "Display Product" navigates to `/display-products`, showing all products in a table.
36+
- Includes a filter to fetch products by a specific category using a repository method.
37+
- **Backend**:
38+
- Uses Spring Data JPA to create an entity (`Product`), repository (`ProductRepository`), and service (`ProductService`).
39+
- Stores product information in a database (H2 in-memory database by default).
40+
41+
## How to Run
42+
43+
1. **Clone the Repository**:
44+
```bash
45+
git clone https://github.com/thesoulseizure/Spring-IOC-Beans.git
46+
```
47+
2. **Navigate to the Project Directory**:
48+
```bash
49+
cd Spring-IOC-Beans
50+
```
51+
3. **Build the Project**:
52+
- Ensure you have Maven installed.
53+
```bash
54+
mvn clean install
55+
```
56+
4. **Run the Application**:
57+
```bash
58+
mvn spring-boot:run
59+
```
60+
5. **Access the Application**:
61+
- Open a browser and navigate to `http://localhost:8080`.
62+
- The homepage will display options to add or display products.
63+
64+
## Requirements
65+
66+
- **Java**: JDK 17 or higher.
67+
- **Maven**: For dependency management and building the project.
68+
- **Database**: H2 in-memory database (configured by default; can be changed in `application.properties`).
69+
- **Browser**: To access the web application.
70+
71+
## Screenshots
72+
73+
The repository includes screenshots in the `screenshots/` directory:
74+
- `homepage.png`: Shows the homepage with "Add Product" and "Display Product" options.
75+
- `add-product.png`: Displays the form to add a new product.
76+
- `display-products.png`: Shows the product catalog in a tabular format.
77+
78+
## Technologies Used
79+
80+
- **Spring Boot**: For creating the web application.
81+
- **Spring IOC and Beans**: For dependency injection and bean management.
82+
- **Spring Data JPA**: For database operations.
83+
- **Thymeleaf**: For server-side rendering of HTML templates.
84+
- **H2 Database**: In-memory database for development.
85+
- **Maven**: For project build and dependency management.

0 commit comments

Comments
 (0)