WorkHub is a SaaS platform where multiple tenants
manage projects and tasks
--- Sending a request... ---
Request → JwtFilter (check token) → SecurityConfig (are you allowed here?) → DTO (here we shape the request from JSON to DTO) → Controller (here's what this endpoint actually does) → Service (here's the business logic) → Repository (here's the database query)
--- Receiving a response... --- Repository (here the db returns the response Entity) → Service (here the entity is made into DTO) → Controller (here just returns DTO as JSON) → Response (SON)
docker-compose up -d
press the green run button
*in case of an error of when running: org.postgresql.util.PSQLException: FATAL: database "workhub" does not exist
just add the database manually
createdb -U postgres workhub
and add your postgres password when prompted
send in requests using curl commands or postgres (check section 4)
the base endpoint for the application is "http://localhost:8082" or the port (8082 here) could be configured differently (check your application-properties)
base is "http://localhost:8082/auth"
POST http://localhost:8082/auth/login
body: { "email": "your-email.com", "password": "your-password" }
ex: { "email" : "[email protected]", "password" : "password123" }
Note: check Database seeder file for a test email and password
GET http://localhost:8082/auth/me
base is "http://localhost:8082/projects"
GET http://localhost:8082/projects
auth: Type: Bearer Token (paste the JWT token you received after login)
POST http://localhost:8082/projects
auth: Type: Bearer Token (paste the JWT token you received after login)
body: { "name": "New Project Name" }
GET http://localhost:8082/projects/{vlid-project-id}
ex: http://localhost:8082/projects/1
auth: Type: Bearer Token (paste the JWT token you received after login)
Note: make sure the project id is for the specific tenant
POST http://localhost:8082/projects/{valid-project-id}/generate-report
ex: http://localhost:8082/projects/2/generate-report
auth: Type: Bearer Token (paste the JWT token you received after login)
Note: make sure the project id is for the specific tenant
base is "http://localhost:8082/projects/{valid-project-id}"
Not implemented
POST http://localhost:8082/projects/{valid-project-id}/tasks
ex: http://localhost:8082/projects/1/tasks
auth: Type: Bearer Token (paste the JWT token you received after login)
body: { "taskName": "New Task" }
PATCH http://localhost:8082/projects/tasks/{valid-task-id}
ex: http://localhost:8082/projects/tasks/1
auth: Type: Bearer Token (paste the JWT token you received after login)
body: { "status": "Completed" }
Note: Valid statuses are "Completed" and "Deleted"
GET http://localhost:8082/projects/{invalid-string-id} ex: http://localhost:8082/projects/abc auth: Type: Bearer Token (paste the JWT token you received after login)
body: (No body required)
POST
auth: Type: Bearer Token (paste the JWT token you received after login)
body: { "name": "" }
POST http://localhost:8082/projects/with-tasks?simulateFailure=true
auth: Type: Bearer Token (paste the JWT token you received after login)
body: { "name": "rollback test" }
GET http://localhost:8082/projects
auth: Type: Bearer Token (paste the JWT token you received after login)
body: (No body required)
docker build -t workhub:latest .
kubectl apply -f k8s/secret.yaml kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/postgres_deployment.yaml kubectl apply -f k8s/postgres_service.yaml kubectl apply -f k8s/kafka_deployment.yaml kubectl apply -f k8s/kafka_service.yaml
kubectl apply -f k8s/workhub_deployment.yaml kubectl apply -f k8s/workhub_service.yaml
ok so requests go to the workhub service which sends to workhub deployment which sends to kafka and postgres service which send to their deployments
docker save workhub:latest -o workhub.tar docker cp workhub.tar desktop-control-plane:/workhub.tar docker exec desktop-control-plane ctr -n k8s.io images import /workhub.tar
kubectl rollout restart deployment workhub
kubectl port-forward deployment/workhub 8082:8082
Terraform is like script for all the kubectl commands (docker build still needs to be done though) However Terraform is better than if you wrote a .bat or .sh script with all those kubectl commands, bec a script would try to create everything every time you ran it (leading to "Already Exists" errors).
terraform init terraform validate terraform plan terraform apply
terraform destroy
//to 3a8l on postman: kubectl port-forward deployment/workhub 8082:8082