- Java (21)
- Apache Maven (3.8.7+)
- Docker
- PostgreSQL
- Makefile (optional)
Clone and access the directory
git@github.com:TechAbraao/contacts.git
cd ./contactsChange the .env.example file to .env. For example:
cp .env.example .envNow configure the necessary variables for the Docker container (minimal example):
## POSTGRESQL ##
POSTGRES_CONTAINER_NAME=contacts_postgres
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=secret
POSTGRES_DB=contacts_db
## PGADMIN ##
PGADMIN_CONTAINER_NAME=contacts_pgadmin
PGADMIN_PORT=8081
PGADMIN_EMAIL=admin@example.com
PGADMIN_PASSWORD=secretThe application is pre-configured to use environment variables. Below is the recommended configuration for your src/main/resources/application.yml (minimal example):
server:
port: 8080
spring:
datasource:
url: jdbc:postgresql://localhost:5432/contacts_db
username: postgres
password: secret
driver-class-name: org.postgresql.Driver
security:
user:
email: admin@example.com
name: admin
password: secretIf you have the Makefile (Linux/Unix system):
make startIf not, do it manually:
docker compose \
--env-file .env \
-f docker/compose/docker-compose.yml \
up -dmvn clean install
mvn spring-boot:runThe API will be available at:
http://localhost:8000/api/API Swagger Swagger available in:
http://localhost:8000/swagger-ui/index.htmlCheck out all the endpoints available in this project.
| Method | URL | Description | Authentication |
|---|---|---|---|
| POST | /api/auth/signup |
Register a new user | public |
| POST | /api/auth/signin |
Login and obtain JWT token | public |
| POST | /api/auth/signout |
Logout (invalidate token) | basicAuth or bearerAuth |
| Method | URL | Description | Authentication |
|---|---|---|---|
| GET | /api/users/me |
Get authenticated user data | basicAuth |
| GET | /api/users |
Get all Users | basicAuth |
| POST | /api/users |
Create a User | basicAuth |
| GET | /api/users/{userId} |
Get User by ID | basicAuth |
| DELETE | /api/users/{userId} |
Delete User by ID | basicAuth or bearerAuth |
| Method | URL | Description | Authentication |
|---|---|---|---|
| GET | /api/contacts |
List my contacts | basicAuth or bearerAuth |
| POST | /api/contacts |
Create a new contact | basicAuth or bearerAuth |
| GET | /api/contacts/{contactId} |
Get a specific contact | basicAuth or bearerAuth |
| PUT | /api/contacts/{contactId} |
Update a contact | basicAuth or bearerAuth |
| DELETE | /api/contacts/{contactId} |
Delete a contact | basicAuth or bearerAuth |