Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
Here are a few APIs:
For employees to start shift swaps:
POST v1/request_shift_swap {
request_employee_id: UUID,
current_shift_id: UUID,
swap_shift_id: UUID,
swap_employee_id: UUID,
}
For employees to respond to shift swap:
POST v1/employee_respond_shift_swap {
request_employee_id: UUID,
current_shift_id: UUID,
swap_shift_id: UUID,
swap_employee_id: UUID,
is_approve: Boolean
}
For managers to respond to shift swap:
POST v1/manager_respond_shift_swap {
request_employee_id: UUID,
current_shift_id: UUID,
swap_shift_id: UUID,
swap_employee_id: UUID,
is_approve: Boolean
}
For employees to see their current shifts:
GET v1/view_shifts {
current_employee_id: UUID
}
For employees to view recommended shifts for swapping:
GET v1/view_swap_recommendations {
current_employee_id: UUID
}
For employees to authenticate and log in:
POST v1/login {
user_name: String,
company_email: String,
hashed_password: String
}
For notifications, we won't use any APIs. Instead, we will use an event-driven approach.
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
In this system, we have 2 relational databases, that separately stores information about shift and employee themselves. Data models are like:
table employees {
employee_id: UUID,
employee_name: String,
employee_start_date: Date,
employee_title_name: String,
...
}
table shifts {
shift_id: UUID,
shift_employee_id: UUID,
shift_start_time: Timestamp,
shift_end_time: Timestamp,
...
}
For the relational databases, we don't need caching layer, sharding or replicas in this case, since neither the data volume nor the data size is large.
All requests from employee clients are sent to the API gateway before they reach the servers. This way, we can handle authentication and rate limiting. An employee needs to log in with their username and password first before they can make any requests.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
In this system, we have 2 relational databases, that separately stores information about shift and employee themselves. Data models are like:
table employees {
employee_id: UUID,
employee_name: String,
employee_start_date: Date,
employee_title_name: String,
...
}
table shifts {
shift_id: UUID,
shift_employee_id: UUID,
shift_start_time: Timestamp,
shift_end_time: Timestamp,
...
}
For the relational databases, we don't need caching layer, sharding or replicas in this case, since neither the data volume nor the data size is large.
All requests from employee clients are sent to the API gateway before they reach the servers. This way, we can handle authentication and rate limiting. An employee needs to log in with their username and password first before they can make any requests.