Idea - peterchu999/url-shorterner GitHub Wiki

Idea Log

would keep track of idea for new functionality, optimization and dx for next version. it also keep track of the issue that current version had and probably be fixed in future version

Version 2

Functionality Idea

  1. Keep track of client data (metric) when request for redirection, this data would be used as a metric for the shortUrl. the metric could compromised of:
  • number of user redirected (click)
  • origin / country / city (based on IP) list and percentage
  • device used to access (android, desktop, etc)
  1. Create a user before client could generate short link, for better privacy on metric
  2. Bulk create short url (learn about queue)

Optimization Idea

  1. Research on database replication for mongoDB to make sure the availability of the services
  2. Research k6 engine for testing API latency

Version 1

Functionality Idea

  1. Keep track of client data (metric) when request for redirection, this data would be used as a metric for the shortUrl. the metric could compromised of:
  • number of user redirected (click)
  • origin / country / city (based on IP) list and percentage
  • device used to access (android, desktop, etc)
  1. Custom short url, instead of waiting the system generating the shortUrl, create custom one
  • need to add logic to check short-url attribute from client, if it's not provided generate automatically
  1. Create a user before client could generate short link, for better privacy on metric

Optimization Idea

  1. Optimize short url redirection flow by:
  • cache store the long url on cache like redis for faster fetching
  • indexing the mongo db to perform faster search
  1. handle concurrent request (user request to generate shortUrl at the same time):
  • use redis to handle the conccurent request lock (need to research more)
  • implements queue on short url generation (need user profile so user could get the short url after it's inserted)
  1. Research on database replication for mongoDB to make sure the availability of the services

Issue

  1. race condition on create short url flow, if the race condition ever happen on current version, the latest user to create the short url would get an error because shortUrl need to be unique.
  2. if shortUrl not yet created, the page got 404 as response, suppose to redirect to home page or generation path
  3. if url_indexes were empty, it would be error