Get api/getUrl/:shortcode
Get :shortCode // Redirects to the original URL
Post api/shortenUrl/
Client → Gateway -> API Server(Read Service/Write Service) → Cache (Redis) → URL Database
Create URL
Flow:
```
{
"shortUrl: "",
"shortCode": ""
}
```
Read URL
Flow:
Client connects to Gateway which will handle security and load balance
API server with rest endpoint for Get, Post and redirect
Redis for caching, we get url from redis, if we don't have it in redis, read from database and add to redis
Database, postgres for example, but I would switch to nosql db like mongodb, it has build in horizontal scalling, simple json, id and url
urls (
short_code VARCHAR PRIMARY KEY,
long_url TEXT NOT NULL,
created_at TIMESTAMP NOT NULL,
expires_at TIMESTAMP NULL,
status VARCHAR NOT NULL
)
Identifiers created using SHA-256 hash which can be truncated to a short length