This project consists of developing a RESTful service for efficient customer management. The company faces difficulties in adding, updating, deleting, and querying customer information quickly and securely. The proposed solution enables CRUD operations on the customer list through a uniform and easy-to-use interface.
- Clone the repository:
git clone https://github.com/user/customer-management.git cd customer-management - Build the project:
mvn clean install
- Set your environment variables:
export QUARKUS_PROFILE=dev export DATABASE_URL=jdbc:postgresql://localhost:5432/customer_management export DATABASE_USER=postgres....
- Run the application:
mvn quarkus:dev
-
Clone the repository:
git clone https://github.com/user/customer-management.git cd customer-management -
Make sure you have Docker installed on your system.
-
Run the deployment script:
./deploy.sh [dev|stg]where [dev|stg] is the environment you want to deploy to.
-
Access the application: Open your browser and navigate to http://localhost:8080/customers
-
Stop the application:
docker-compose down
The API exposes the following endpoints for customer management:
| Method | Endpoint | Description |
|---|---|---|
| POST | /customers |
Creates a new customer. |
| GET | /customers |
Retrieves all customers. |
| GET | /customers?country={country} |
Retrieves customers by country. |
| GET | /customers/{id} |
Retrieves a customer by ID. |
| PUT | /customers/{id} |
Updates an existing customer. |
| DELETE | /customers/{id} |
Deletes a customer by ID. |
This project adheres to Clean Architecture principles, ensuring a clear separation of concerns across application layers. Key design decisions and diagrams are provided to visualize project structure, dependencies, and component interactions.
-
Application Layer (application)
- Responsibility:
- Orchestrates business logic.
- Contains commands and queries, decoupled from data persistence details.
- Components:
- Commands: Write operations (e.g., CreateCustomerCommand, UpdateCustomerCommand) with handlers for execution.
- Queries: Read operations (e.g., GetCustomerQuery) with handlers to return data.
- Interaction: Interfaces with infrastructure services to complete operations without direct database knowledge.
- Responsibility:
-
Domain Layer (domain)
- Responsibility:
- Focuses on the business model, defining business objects and rules.
- Components:
- Entities: Core business concepts (e.g., Customer).
- Business Logic: Validations and entity-specific behaviors.
- Responsibility:
-
Interface Layer (interfaces)
- Responsibility:
- Exposes external interfaces for application interaction.
- Components:
- API REST: API resources mapping HTTP requests to application operations (e.g., CustomerResource).
- DTOs: Data Transfer Objects for inter-layer communication.
- Exceptions: Domain-specific exceptions for consistent error communication (e.g., CustomerCreationException).
- Responsibility:
-
Infrastructure Layer (infrastructure)
- Responsibility:
- Contains implementation details and external resource dependencies.
- Components:
- Repositories: Data persistence interface implementations (e.g., CustomerPanacheRepository).
- External Services: Third-party API integrations (e.g., CountryService).
- Exception Handling: Manages infrastructure-related exceptions.
- Responsibility:
-
Mediator Layer (mediator)
- Responsibility:
- Facilitates command/query communication without direct coupling.
- Components:
- Mediator: Orchestrates command/query execution for decoupled system communication.
- Responsibility:
-
Filters Layer (filters)
- Responsibility:
- Manages cross-cutting concerns like global exception handling and HTTP response manipulation.
- Components:
- Filters: Centralized management of logging and error handling (e.g., CustomerExceptionMapper, LoggingFilter).
- Responsibility:
- Complete customer management: Allows creation, updating, deletion, and retrieval of customers.
- Data validation: Implements validation mechanisms to ensure data integrity and reliability.
- API documentation: Uses OpenAPI and Swagger UI for automatic documentation.
- Efficient persistence: Employs Hibernate ORM with Panache to simplify interaction with the PostgreSQL database.
- Create a new customer.
- Retrieve all existing customers.
- Retrieve all customers belonging to a specific country.
- Retrieve a specific customer by their ID.
- Update an existing customer, allowing modifications to their email, address, phone, and country.
- Delete a customer by their ID.
- Quarkus: Framework for Java application development.
- Lombok (Guide): Generates repetitive code automatically.
- Hibernate Validator (Guide): Validates object properties and method parameters.
- SmallRye OpenAPI (Guide): Documents REST APIs using OpenAPI and Swagger UI.
- REST Jackson (Guide): JSON serialization support for Quarkus REST.
- Hibernate ORM with Panache (Guide): Simplifies persistence in Hibernate ORM.
- JDBC Driver - PostgreSQL (Guide): JDBC connector for PostgreSQL databases.
- Java 17 or higher
- Maven 3.8+
- Docker (optional, for local PostgreSQL database)
The API documentation is available in Swagger UI when the application is running:
http://localhost:8080/q/swagger-ui/
Contributions are welcome. To contribute, follow these steps:
- Fork the repository.
- Create a new branch (
feature/new-feature). - Make your changes and commit them.
- Submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.