{"id":23066169,"url":"https://github.com/santialb/productproject","last_synced_at":"2025-08-11T21:33:28.218Z","repository":{"id":259175625,"uuid":"873807187","full_name":"santialb/ProductProject","owner":"santialb","description":"Product Project CRUD - SpringBoot","archived":false,"fork":false,"pushed_at":"2024-10-24T19:31:15.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-24T21:28:35.596Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/santialb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-16T18:49:01.000Z","updated_at":"2024-10-24T19:31:20.000Z","dependencies_parsed_at":"2024-12-16T05:11:28.844Z","dependency_job_id":"c41fabbb-dd12-4311-b7af-3af9db4d5b51","html_url":"https://github.com/santialb/ProductProject","commit_stats":null,"previous_names":["santialb/productproject"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santialb%2FProductProject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santialb%2FProductProject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santialb%2FProductProject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/santialb%2FProductProject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/santialb","download_url":"https://codeload.github.com/santialb/ProductProject/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970337,"owners_count":20862508,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T05:11:20.608Z","updated_at":"2025-04-03T08:49:56.674Z","avatar_url":"https://github.com/santialb.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Products Management API\n\nThis Spring Boot application provides a REST API for managing products.\nIt includes functionalities for creating, updating, deleting, and retrieving product information. The application interacts with a MySQL database and uses JPA for data persistence.\n\n## Table of Contents\n- [Technologies Used](#technologies-used)\n- [Project Structure](#project-structure)\n- [Endpoints](#endpoints)\n- [Database Configuration](#database-configuration)\n- [Unit Testing](#unit-testing)\n\n## Technologies Used\n- Java 17\n- Spring Boot 3.3.4\n- Spring Data JPA\n- Hibernate (JPA implementation)\n- MySQL\n- Maven\n- Lombok\n- Mockito\n\n## Project Structure\n```\n├── .gitignore\n├── HELP.md\n├── mvnw\n├── mvnw.cmd\n├── pom.xml\n├── src/\n│   ├── main/\n│   │   ├── java/\n│   │   │   └── com/\n│   │   │       └── example/\n│   │   │           └── nobsv2/\n│   │   │               ├── Command.java         # Command interface for create/update services\n│   │   │               ├── Query.java           # Query interface for get/search services\n│   │   │               ├── Nobsv2Application.java # Main application entry point\n│   │   │               ├── exceptions/          # Contains custom exception classes\n│   │   │               │   ├── ErrorMessages.java      # Enum for custom error messages\n│   │   │               │   ├── GlobalExceptionHandler.java # Centralized exception handling\n│   │   │               │   ├── ProductNotFoundException.java # Custom exception for product not found\n│   │   │               │   └── ProductNotValidException.java # Custom exception for validation errors\n│   │   │               ├── product/\n│   │   │               │   ├── ProductController.java  # REST Controller for product endpoints\n│   │   │               │   ├── ProductRepository.java  # Repository interface for product persistence\n│   │   │               │   ├── model/                  # Contains Product, ProductDTO, UpdateProductCommand, and ErrorResponse models\n│   │   │               │   └── services/               # Business logic services for product management\n│   │   │               │       ├── CreateProductService.java\n│   │   │               │       ├── DeleteProductService.java\n│   │   │               │       ├── GetProductService.java\n│   │   │               │       ├── GetProductsService.java\n│   │   │               │       ├── SearchProductService.java\n│   │   │               │       └── UpdateProductService.java\n│   │   │               └── validators/           # Product validation logic\n│   │   │                   └── ProductValidator.java\n│   │   └── resources/\n│   │       └── application.properties           # Application configuration (e.g., database connection)\n│   └── test/\n│       └── java/\n│           └── com/\n│               └── example/\n│                   └── nobsv2/\n│                       ├── CreateProductServiceTest.java\n│                       ├── DeleteProductServiceTest.java\n│                       ├── GetProductServiceTest.java\n│                       ├── GetProductsServiceTest.java\n│                       ├── SearchProductServiceTest.java\n│                       └── UpdateProductServiceTest.java\n└── target/\n```\n\n## Endpoints\nHere are the main REST API endpoints:\n\n| Method | URL                | Description                 |\n|--------|--------------------|-----------------------------|\n| POST   | `/product`          | Create a new product        |\n| GET    | `/products`         | Retrieve all products       |\n| GET    | `/product/{id}`     | Retrieve a product by ID    |\n| PUT    | `/product/{id}`     | Update an existing product  |\n| DELETE | `/product/{id}`     | Delete a product by ID      |\n| GET    | `/product/search`   | Search for products by name |\n\n### Example of Request/Response\n- **POST /product**\n  - Request Body:\n    ```json\n    {\n      \"name\": \"Laptop\",\n      \"description\": \"A powerful laptop\",\n      \"price\": 1500.00\n    }\n    ```\n  - Response Body:\n    ```json\n    {\n      \"id\": 1,\n      \"name\": \"Laptop\",\n      \"description\": \"A powerful laptop\"\n    }\n    ```\n\n- **GET /products**\n  - Response Body:\n    ```json\n    [\n      {\n        \"id\": 1,\n        \"name\": \"Laptop\",\n        \"description\": \"A powerful laptop\"\n      },\n      {\n        \"id\": 2,\n        \"name\": \"Phone\",\n        \"description\": \"A smartphone with a great camera\"\n      }\n    ]\n    ```\n\n## Database Configuration\nMake sure to set up your MySQL database and update the `application.properties` file with the correct credentials:\n\n```properties\nspring.datasource.url=jdbc:mysql://localhost:3306/nobsv2\nspring.datasource.username=root\nspring.datasource.password=yourpassword\nspring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver\n```\n## Unit Testing\nUnit tests are implemented for the service layer using Mockito. Tests include creating, updating, deleting, and retrieving products.\n\nHere are the test classes:\n\n- CreateProductServiceTest.java\n- DeleteProductServiceTest.java\n- GetProductServiceTest.java\n- GetProductsServiceTest.java\n- SearchProductServiceTest.java\n- UpdateProductServiceTest.java\n\nTo run the tests, use the following Maven command:\n```\n bash $ mvn test\n```\nExample Test Assertion:\n```\n assertEquals(ResponseEntity.status(HttpStatus.OK).body(expectedDTOs), response);\n```\nThis project is designed for efficient management of products, offering a comprehensive set of REST API operations along with robust validation and exception handling mechanisms.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantialb%2Fproductproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsantialb%2Fproductproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsantialb%2Fproductproject/lists"}