We would need two APIs, one of type GET and the other of type POST.
classDiagram
class url {
id int PK (auto increment)
longURL string Index
string shortURL Index
}
flowchart TD
client["Client"]
loadBalancer["Load Balancer"]
apiGateway["API Gateway"]
fetchService["Fetch Service"]
shorteningService["Shortening Service"]
database["Database"]
cache["Cache"]
client --> loadBalancer
loadBalancer --> apiGateway
apiGateway --> fetchService
apiGateway --> shorteningService
fetchService --> database
fetchService --> cache
shorteningService --> database
sequenceDiagram Client->>+Server: Do you have the resource for me? Server->>+Cache: Do you have this resource for me? Cache->>-Server: Yes, here you goo. Server-->>-Client: 302 Redirect Server-->+Database: Do you have the request for me? Database-->>-Server: Yes, here you go Server-->>Client: 302 Redirect/404 Error