Thanks to visit codestin.com
Credit goes to github.com

Skip to content

HabibaMekay/WorkHub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1.0- What is WorkHub

WorkHub is a SaaS platform where multiple tenants
manage projects and tasks

2.0- How the project works internally:

--- 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)

3.0: How to run locally

3.1: start db on docker

    docker-compose up -d

3.2: run the project

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

3.2: send requests

send in requests using curl commands or postgres (check section 4)

4.0: Endpoints

the base endpoint for the application is "http://localhost:8082" or the port (8082 here) could be configured differently (check your application-properties)

4.1: Authentication

base is "http://localhost:8082/auth"

4.1.1: Login

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

4.1.2: Get Active JWT

GET http://localhost:8082/auth/me

4.2: Projects

base is "http://localhost:8082/projects"

4.2.1: get all projects

GET http://localhost:8082/projects

auth: Type: Bearer Token (paste the JWT token you received after login)

4.2.2: add project

POST http://localhost:8082/projects

auth: Type: Bearer Token (paste the JWT token you received after login)

body: { "name": "New Project Name" }

4.2.3: get project by id

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

4.2.4: generate projects report

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

4.3: Tasks

base is "http://localhost:8082/projects/{valid-project-id}"

4.3.1: get all tasks

Not implemented

4.3.2: add task

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" }

4.3.3: update 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"

4.4: Consistent errors

4.4.1: test consistent errors (invalid url parameter)

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)

4.4.2: test consistent errors (empty project name)

POST

auth: Type: Bearer Token (paste the JWT token you received after login)

body: { "name": "" }

4.5: Transaction

4.5.1: test transaction rollback (simulate failure)

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" }

4.5.2: test transaction rollback (verify database state)

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

About

WorkHub is a SaaS platform where multiple tenants manage projects and tasks

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors