An open API service indexing awesome lists of open source software.

https://github.com/maria-leiliane/quarkus-client-address-api

This project is a REST API built with The solution provides a complete set of endpoints to manage clients and their addresses, following a clean layered architecture, with features like exception handling, validation (CPF/CNPJ), encryption, and pagination.
https://github.com/maria-leiliane/quarkus-client-address-api

api-rest clean-architecture docker docker-compose java microservice quarkus women-in-tech

Last synced: 2 days ago
JSON representation

This project is a REST API built with The solution provides a complete set of endpoints to manage clients and their addresses, following a clean layered architecture, with features like exception handling, validation (CPF/CNPJ), encryption, and pagination.

Awesome Lists containing this project

README

          

# πŸš€ REST API for Clients and Addresses

This project is a **REST API** built with **Quarkus**, a Supersonic Subatomic Java Framework.
The solution provides a complete set of endpoints to manage **clients** and their **addresses**, following a **clean layered architecture**, with features like **exception handling, validation (CPF/CNPJ), encryption, and pagination**.

---

## πŸ› οΈ Key Technologies

* **Quarkus** β†’ Modern Java framework for cloud-native applications.
* **JDBI 3** β†’ SQL persistence library with lightweight abstractions.
* **PostgreSQL** β†’ Relational database for reliable data storage.
* **Flyway** β†’ Schema version control with migration scripts.
* **JUnit 5** β†’ Unit and integration testing framework.
* **Jackson** β†’ JSON serialization/deserialization.
* **Gradle** β†’ Build automation tool.
* **Docker** β†’ Containerization for consistent environments.

---

## πŸ“‚ Project Structure

* **Controller** β†’ Handles HTTP requests and maps them to services.
* **Service** β†’ Core business logic, validation, and transaction orchestration.
* **Repository** β†’ Encapsulates persistence and database interaction.
* **Entity** β†’ Database schema representation.
* **DTOs** β†’ Transfer data between layers, isolating domain models.
* **Exception** β†’ Centralized custom exception handling (consistent error responses).
* **Flyway Migrations** β†’ `src/main/resources/db/migration` for schema versioning.

---

## πŸ”’ Features

* βœ… **Custom exception handling** β†’ Unified error responses.
* βœ… **Password encryption** β†’ Using `BcryptUtil`.
* βœ… **Validation for CPF and CNPJ** β†’ Ensures domain integrity.
* βœ… **Pagination & filtering** β†’ For efficient client listing.
* βœ… **Main address logic** β†’ Enforces one main address per client.

---

## βš™οΈ Setup and Execution

### 1. Clone the repository

```bash
git clone git@github.com:Maria-Leiliane/quarkus-client-address-api.git
cd quarkus-client-address-api
```

Create the database local: clientdb

### 2. Configure the Database

Edit `application.properties`:

```properties
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=youruser
quarkus.datasource.password=yourpassword
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/clientdb
quarkus.flyway.migrate-at-start=true
```

### 3. Run in Dev Mode (with live coding)

```bash
./gradlew quarkusDev
```

> Dev UI: [http://localhost:8080](http://localhost:8080)

For test we have the doc: [http://localhost:8080/q/swagger-ui/](http://localhost:8080/q/swagger-ui/)
Other options: Import the `client-address-api.json` file and lets test it.

### 5. Run with Docker (In Development)

### 6. Run unit tests

```bash
./gradlew test
```

---

## πŸ“Š API Endpoints

### **Clients**

* `GET /clients` β†’ List clients (pagination + filters).
* `GET /clients/{id}` β†’ Retrieve client by ID.
* `POST /clients` β†’ Create new client (with encrypted password).
* `PATCH /clients/{id}` β†’ Partial update.
* `DELETE /clients/{id}` β†’ Remove client.

### **Addresses** *(sub-resource of Client)*

* `GET /clients/{id}/addresses` β†’ List client’s addresses.
* `POST /clients/{id}/addresses` β†’ Add new address.
* `DELETE /clients/{id}/addresses/{addressId}` β†’ Remove client’s address.

---