This project provides a RESTful service for managing a device database. The service supports operations for adding, retrieving, updating, deleting, and searching devices. Devices are associated with brands, and both entities are represented in the system.
deviceName
: The name of the device.brand
: The brand associated with the device.createdAt
: The time when the device was created.
name
: The name of the brand.devices
: A list of devices associated with the brand.
- Add Device: Adds a new device to the database.
- Get Device by Identifier: Retrieves a device by its unique identifier.
- List All Devices: Lists all devices in the database.
- Update Device: Updates an existing device. Supports both full and partial updates.
- Delete Device: Deletes a device from the database.
- Search Device by Brand: Searches for devices based on the brand name.
- Soft Delete: Devices are not permanently deleted from the database but marked as deleted.
- Optimistic Locking: Ensures data consistency in concurrent transactions.
- Transactional Management: Operations are wrapped in transactions to ensure atomicity.
- Controller Advice: Provides centralized exception handling.
- Unit Tests & Integration Tests: Ensures the reliability and functionality of the service.
- Docker Configuration: Includes Docker configuration for containerized deployment.
- Test Containers: Used for running integration tests in isolated environments.
- MapStruct: Used for mapping between DTOs and entities.
- Lombok: Used for reducing boilerplate code.
- Spring Data JPA: Used for data access and persistence.
- Flyway: Used for database migration.
-
Clone the Repository
git clone https://github.com/BeratYesbek/device-managment.git cd device-managment
-
Run
docker-compose up --build
You can access the postman collection under the postman
directory.:
- POST /devices: Add a new device.
- GET /devices/{id}: Get a device by its identifier.
- GET /devices: List all devices.
- PUT /devices/{id}: Update a device by its identifier.
- DELETE /devices/{id}: Delete a device by its identifier.
- GET /devices/search: Search devices by brand name.