PUT endpoint -> takes in long URL as an argument -> returns short URL.
GET endpoint -> takes in short URL as an argument -> returns long URL
REST layer -> PUT(string longUrl) -> synchronous operation -> Business layer
Business layer -> Use 66 characters (a-z, A-Z, 0-9, -, _, ., ~) -> base 66 encoding
idea 1: use hash function to do base 66 encoding
pros: fast, deterministic
cons: collisions prone
idea 2: create a randomized string of 10 characters
pros: no collission. if collision detected, create another randomized string.
cons: extra logic
Data layer: Since system will be read intensive, choose database like SQL optimized for high reads.
will store long URL as key and short URL as value.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.