Estimate the scale of the system you are going to design...
GET /route {
start_point
end_point
} - returns list os roads and estimates time to arrival.
We can represent map as graph , where nodes - road intersections and edges - roads with metrics (distance, speed limits, traffic data). Lets split graph on grid with layers, where layers represent : 1) local, small roads, 2 larger streets typically within a city, and 3 highways.
nodes table {
node_id,
lon,
lat
}
edges_table {
edge_id,
source_node_id,
target_node_id,
length_m,
speed_limit_kph,
road_class,
is_one_way,
traffic_factor,
last_updated_at
)
edge_profiles_table {
edge_id
car_cost
truck_cost
bike_cost
pedestrian_cost
}
Client (e.g. using a map app on a mobile phone) sends route() request to API Gateway.
API Gateway forwards the request to Routing Service.
Routing Service uses the grid data from Database to find the shortest paths and return.
Routing Service uses cache to store some already computed paths.
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...
Trade offs between Dijkstra and A* algorithms.
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?