For this api will be need two paths in the same domain,
POST shortener/url/
Response Status Code: 201
GET shortener/url/{Id}
Response Status Code: 301
The Client will fill up the form with the url that has to be shortened and will submit It.
Before the api there is a layer of ensurance and DNS management.
On the Server-side there is a gateway will evalute de token sent by front end calling the OAuth server.
The url shortener service is an Fargate published in a LoadBalance.
The IdManager service is an Fargate published in a LoadBalance will store da Ids in a DynamoDb Table.
The main DataBase will be for the URLs dictionary and other Data will be a DybamoDb.
For Read Access the most accessed url is stored in a redis cache.
The services are using .NET and and following the Clean Architecture, creating a possible expansion of It. The integration with other services will be made using Circuit and retry policy.
Every data inserted into the database will be available on cache for 5 minutes, after that time only the most accessed url will be there for a long term following some internal rules.
The Id Manager is a Fargate, but for cost optimization It can also be an Lambda built using .NET and AOT.
It will manage some ranges of Id, in order to avoid racing conditions, and will use the DynamoDb to manage when create the Id for each range.
Before each server get an Id, It will register Itself calling the GetId and sending some metadata about the running task, like Id, IP and name. Server A gets IDs 1–1000, Server B gets 1001–2000.