a User table, and a URL table.
User:
UserId int
UserName str 32
UserEmail str 128
Password str 256
ShortUrl:
ShortURLID int
ShortURL str 8
OriginalURL str 500
User table contains everything related to the User and the URL table contain the mapping between ShortURL and Original URL.
There is a load-balancer that redirect to API components.
API query a Cache and the Database.
The cache is handled by a redis
The database is handled by pgbouncer / patroni / haproxy and postgres with both a master and a replica.
A garbage collector handle removing the data from the db once the TTL is passed every hour. Every hour it would delete 200 * 3600 rows.
APIs:
Apis are stateless and can scale horizontally if needed.
Cache:
Cache is handled by redis an in-memory and fast KV store. it can be scaled by using a redis cluster if needed.
Database component is handled by :