Functional:
API design
Here's a breakdown of the essential REST
API for our Employee Swap System.
User service:
PUT /auth/login - authenticate a user
PUT /auth/logout - log out user
POST /auth/register - register new user:
{ "name": "name1"
"email":....
"phone": ...
"employe_id":
"position":
"department":
"manager_id"
}
Employee shift matching service:
PUT /shift_matching/v1/swap/{employee_id}/{shift_id} - try to confirm the shift swap for the {shift_id} by an employee {empoloyee_id} Return:
{ "swap_id"....
"status": IN_PROGRESS,APPROVED_BY_MANAGER,APPROVED_BY_OTHER_EMPLOYEE,CANCELED
"createdAt": ....
}
GET /shift_matching/v1/swap/{employee_id}/status/{swap_id} - return the swap status:
{ "swap_id"....
"status": IN_PROGRESS,APPROVED_BY_MANAGER,APPROVED_BY_EMPLOYEE,CANCELED
"createdAt": ....
}
GET /shift_matching/v1/shift/{employee_id}
return the available shifts for an employee
{[.
'shift_id':
'employee_id':
'start_time':
'end_time':
'last_swap_date':
'status':
]}
PUT /shift_matching/swap/manager/{manager_id}/approve/{swap_id} - a manager approves the suggested shift if both employees agree.
Employee Shift service:
GET /employee_shift/v1/shift/{employee_id}/shifts?startDate=..&endDate=..&offset=..&pageSize=.. - get the list of the shifts belonging to the employee:
{ "employee_id":...
"shifts":[
{ "shift_id":....
"startFrom":
"endTo":
'status':
'last_swap_date'
},
....
]
POST /employee_shift/v1/shift/{employee_id}
Persist new shift for an employee.
body:
{ 'shift_id'
'employee_id'
'start_date':
'end_date':
'status':
'last_swap_date':
}
PUT /employee_shift/v1/shift/{employee_id}
Update the shift information for an employee.
See the diagram from the high-level architecture.
API Gateway provides DDoS protection and TLS termination, and routes the requests to the right service nodes.
The user service:
Employee shift matching service:
IN_PROGRESS,APPROVED_BY_MANAGER,APPROVED_BY_OTHER_EMPLOYEE,CANCELED
Employee shift service:
The client application:
Kafka:
Postgres:
Redis:
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Employee shift matching service:
This is essential service and it's used to match the given employee shift. For that the service the Redis structures to hold the employee shift start time for every employee. When someone requests to swap the two employees shift, the service query the Redist startTime from the Redis, verifies that's shifts are available and update the employee shift in Redis. Further the other employee should approve it
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...