- This project provides a Spring Boot API for managing user authentication and task management functionalities. It also includes advanced logging and security features.
- User Authentication:
- User Registration: Register users with an email and password.
- User Login: Authenticate users with email and password, generating access and refresh tokens
- Token Refresh: Refresh expired access tokens using refresh tokens
- User Logout: Invalidate tokens to log users out
- Task Management :
- Create Tasks: Accessible only to ADMIN users
- Retrieve Tasks: Paginated task list retrieval, accessible to both ADMIN and USER roles
- Retrieve Tasks: Paginated task list retrieval, accessible to both ADMIN and USER roles
- Retrieve Specific Task: Search by task name or ID, accessible to both ADMIN and USER role
- Update Tasks: Modify an existing task by ID, accessible only to ADMIN users
- Delete Tasks: Remove tasks by ID, accessible only to ADMIN users
- Security :
- User Roles: ADMIN and USER roles implemented using Spring Security
- JWT Authentication: Secure endpoints with JSON Web Tokens
- Logging :
- Custom Logging Aspect: Logs details of REST controller method calls and exceptions, including
- HTTP request and response details
- Python :
- setup-couchbase image used in Docker is handled with Kubernetes process to defnie cluster, scope, collection and indexes
Endpoints Summary
Method | Url | Description | Request Body | Path Variable | Response |
---|---|---|---|---|---|
POST | /api/v1/authentication/user/register | Register for Admin or User | RegisterRequest | CustomResponse<Void> | |
POST | /api/v1/authentication/user/login | Login for Admin or User | LoginRequest | CustomResponse<TokenResponse> | |
POST | /api/v1/authentication/user/refresh-token | Refresh Token for Admin or User | TokenRefreshRequest | CustomResponse<TokenResponse> | |
POST | /api/v1/authentication/user/logout | Logout for Admin or User | TokenInvalidateRequest | CustomResponse<Void> | |
POST | api/v1/tasks | Create a new Task | SaveTaskRequest | CustomResponse<String> | |
GET | api/v1/tasks | Get all Tasks | TaskPagingRequest | CustomResponse<CustomPagingResponse<TaskResponse>> | |
POST | api/v1/tasks/getByName | Get Task by name | GetTaskByNameRequest | CustomResponse<TaskResponse> | |
GET | api/v1/tasks/{id} | Get Task by ID | UUID | CustomResponse<TaskResponse> | |
PUT | api/v1/tasks/{id} | Update a Task | UpdateTaskRequest | UUID | CustomResponse<TaskResponse> |
DELETE | api/v1/tasks/{id} | Delete a Task | UUID | CustomResponse<String> |
- Java 21
- Spring Boot 3.0
- Restful API
- Mapstruct
- Open Api (Swagger)
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- CI/CD (Github Actions)
- Postman
- TestContainer
- Couchbase
- Prometheus
- Grafana
- Kubernetes
- Python
Import postman collection under postman_collection folder
COUCHBASE_USERNAME={COUCHBASE_USERNAME}
COUCHBASE_PASSWORD={COUCHBASE_PASSWORD}
COUCHBASE_BUCKET=todo_list
COUCHBASE_HOST=127.0.0.1
http://localhost:2323/swagger-ui/index.html
To build and run the application with Maven
, please follow the directions shown below;
$ cd todowithcouchbase
$ mvn clean install
$ mvn spring-boot:run
The application can be built and run by the Docker
engine. The Dockerfile
has multistage build, so you do not need to build and run separately.
Please follow directions shown below in order to build and run the application with Docker Compose file;
$ cd todowithcouchbase
$ docker-compose up -d
If you change anything in the project and run it on Docker, you can also use this command shown below
$ cd todowithcouchbase
$ docker-compose up --build
To monitor the application, you can use the following tools:
-
Prometheus:
Open in your browser at http://localhost:9090
Prometheus collects and stores application metrics. -
Grafana:
Open in your browser at http://localhost:3000
Grafana provides a dashboard for visualizing the metrics.
Default credentials:- Username:
admin
- Password:
admin
- Username:
-
Define prometheus data source url, use this link shown below
http://prometheus:9090
To build and run the application with Maven
, please follow the directions shown below;
- Start Minikube
$ minikube start
- Open Minikube Dashboard
$ minikube dashboard
- To deploy the application on Kubernetes, apply the Kubernetes configuration file underneath k8s folder
$ kubectl apply -f k8s
- To open Prometheus, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service prometheus-service
- To open Grafana, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service grafana-service
- Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090
https://hub.docker.com/repository/docker/noyandocker/todowithcouchbase/general
https://hub.docker.com/repository/docker/noyandocker/setup-couchbase/general