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...
shotren url:- api/v1/url/short
(when user hit this this api end-point it goes to a shorten service which uses a id genration service which handle a unique horten code fro the sepecific url nad that process is being streamed to our analytic service to store certain meta data and intiat a doc of the url in mongod
redirect url:- api/v1/url/redirect {
when user call this api it oes bia a rate limiter then load babalancer which redirect thie call to redirect ervice where redirect service looks in redis if yes redirect or else look n databse and fetch and store in redis for further call delay avoiding aldo this have been connected to a async kafka to update the analytics like (clicks, location etc) in analytic for specific url
}
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.
so we've built a url shortner saas
when user hit the application or any of our api endpoint ->goes to the cdn/edge server near to their region (if redirect is then send to redirect_service from there only)
now all these request go via a rate limiter->loadbalancer->api gateway
rate limiter handles the no of request from a ip in a particular time period
load balancer handles the distributing the load /traffic to servers or gateway where capacity is not exceeded
then in api gateway the authentication, authorization and routing or creating proxy to other in micro services is don't to protect the system from being exposed to public
if api/v1/url/create
this have user token in header, long_url
which goes to shortener_Service which handles the the creating a shirt id for specific url
it uses a id_geberation_Service which is responsible for unique id generation at large scale making the system reliable and avoiind duplicates id
thenoption data is streamed to kafka to be stored in mongodb for other anlaytics purpose
also the reason we using kafka to handle the high traffic for handeling analytic service so no data is loss and service doesn't get lot of load which helps to go other services without hindering
now we've redirect service whihc handles only when edge doens't have this data so this serviceget data from redis and gives to user or redirect where if data not in redis it goes to db and et the data and redirect and also stores in redis for next response minimising latency
here we're usig db(sql) to map all the urls to their id for better fetchin gand saving space for large user data
also helps to perform acid transactions
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
here the main component are
3 so we're using mongo, postgresql, redis so we can scale it horizontal to handle more traffics
BUT WE CANT scale it more casue it's not rscy to hancle routing request to many node and may lead to data inconsistency