https://github.com/pablosilvab/demo-backend-spring-boot
Backend build with Spring Boot
https://github.com/pablosilvab/demo-backend-spring-boot
heroku java maven spring spring-boot springboot
Last synced: 2 months ago
JSON representation
Backend build with Spring Boot
- Host: GitHub
- URL: https://github.com/pablosilvab/demo-backend-spring-boot
- Owner: pablosilvab
- Created: 2020-08-04T02:56:13.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-04-17T03:18:59.000Z (about 3 years ago)
- Last Synced: 2025-01-10T21:21:29.741Z (over 1 year ago)
- Topics: heroku, java, maven, spring, spring-boot, springboot
- Language: Java
- Homepage:
- Size: 130 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Demo Spring Boot API
This project is a **REST API** for managing products, built using **Spring Boot** and **Java 17**.
## 🚀 Technologies Used
- **Java 21**
- **Spring Boot 3.4.3**
- **Spring Data JPA** (for database interaction)
- **Spring Validation** (for request validation)
- **MapStruct 1.6.0** (for object mapping)
- **Lombok** (to reduce boilerplate code)
- **Swagger** (for API documentation)
- **Docker** (for containerization)
## 📌 Features
This API provides the following endpoints:
| Method | Endpoint | Description |
|--------|------------------------------|------------------------------|
| GET | `/api/v1/products` | Retrieve all products |
| GET | `/api/v1/products/{id}` | Retrieve a product by ID |
| POST | `/api/v1/products` | Create a new product |
| PUT | `/api/v1/products/{id}` | Update an existing product |
| DELETE | `/api/v1/products/{id}` | Delete a product |
## 🛠️ Setup and Usage
### 1️⃣ Clone the repository
```bash
git clone https://github.com/your-username/demo-backend-spring-boot.git
cd demo-backend-spring-boot
```
### 2️⃣ Run with Maven
```bash
mvn spring-boot:run
```
### 3️⃣ Run with Docker
#### Build the Docker image
```bash
docker build -t demo-backend-spring-boot .
```
#### Run Docker services
```bash
docker-compose up -d
```
#### Push Docker image
```bash
docker tag demo-backend-spring-boot pablon27/demo-backend-spring-boot:1.0.0
docker push pablon27/demo-backend-spring-boot:1.0.0
```
### 4️⃣ API Usage Example
#### Create a Product (POST `/api/v1/products`)
```json
{
"name": "SoundBar",
"description": "High-quality sound system",
"price": 15000,
"stock": 50
}
```
#### Get a Product by ID (GET `/api/v1/products/1`)
```json
{
"id": 1,
"name": "SoundBar",
"description": "High-quality sound system",
"price": 15000,
"stock": 50
}
```
## 📄 API Documentation
You can explore and test the API using **Swagger UI**:
```
http://localhost:8080/swagger-ui/index.html
```
## ✅ License
This project is open-source and available under the [MIT License](LICENSE).