This project is an example of a Hexagonal Architecture package structure using Java 21 in a contact book application.
- Introduction
- Technologies
- Getting Started
- Building and Running
- API Endpoints
- Available cURL Commands
- Contributing
- Creator
- License
The Contact Book Application is designed to demonstrate the principles of Hexagonal Architecture (also known as Ports and Adapters Architecture) using Java 21. The application allows users to register and retrieve contacts.
- Java 21: The latest long-term support (LTS) version of Java.
- Maven: A build automation tool used primarily for Java projects.
- Spring Boot: A framework that simplifies the development of Java applications.
- Java 21: Make sure you have JDK 21 installed. You can download it from the official website.
- Maven: Ensure you have Maven installed. You can download it from the official website.
-
Clone the repository:
git clone https://github.com/your-username/contact-book.git cd contact-book -
Build the project:
mvn clean install
You can run the application using the Maven Spring Boot plugin:
mvn spring-boot:runThe application will start and be accessible at http://localhost:8080.
URL: /api/contacts/register
Method: POST
Request Body:
{
"name": "João Paulo",
"email": "joao.paulo@email.com",
"phoneNumber": "1234567890"
}
Response: 200 OK
URL: /api/contacts
Method: GET
Response:
[
{
"id": 1,
"name": "João Paulo",
"email": "joao.paulo@email.com",
"phoneNumber": "1234567890"
}
]
curl -X POST http://localhost:8080/api/contacts/register \
-H "Content-Type: application/json" \
-d '{
"name": "João Paulo",
"email": "joao.paulo@email.com",
"phoneNumber": "1234567890"
}'
curl -X GET http://localhost:8080/api/contacts