the service will be rate limited using the token bucket algorithm and throttle by endpoints:
The main endpoints (cf API design) free user will have a limit of 100 req/hour and premium 200/hour,if user is reaching the limit to many
time, a notification will be sent to the user by mail.
API Gateaway: Entry point of the service managing auth,rate limiting,load balacing and routing to either the write or read service
AUTH: User will be authenticated with technology like JWT/OAUTH2
Write Service:
Shorten URL:From a long URL return a unique shortened URL, have some restriction : 20 URL generation/per user/30minute
Read Service:
Free plan: 30 links max generated and 300 click tracked and one custom domains
paid plan: unlimited
Performance: The service should respond to shortening requests
General constraint :
Scalability: The system should be able to scale horizontally to handle increased load and volume of URLs without significant degradation in performance.
Availability: The service should have an uptime of 99.9%, ensuring it is available to users most of the time.
Data Consistency: The mapping between shortened URLs and original URLs must be consistent, especially during concurrent access.
Security: The service should implement mechanisms for protecting against malicious use, such as preventing spam or URL abuse.
Maintainability: The codebase should be modular and organized to facilitate maintenance and future feature additions.
Usability: The user interface for shortening URLs should be user-friendly, providing an intuitive experience.
Monitoring: Monitor those metrics:
Analystics:
The app will collect usage statics which will be shown to the user
dashboard.
usage statics :
Track how many times each short URL has been accessed.
Overview: The URL Shortener API service consists of three primary components:
POST /api/auth/login: Authenticate a user and provide access tokens.POST /api/auth/logout: End user session and invalidate tokens.POST /api/auth/signup: Register a new user account.GET /api/analytics/url/{id}: Retrieve analytics for a specific shortened URL.POST /api/shorten: Create a new shortened URL.GET /api/users/{id}/urls: Retrieve all URLs associated with the user.DELETE /api/shorten/urls/{id}: Delete a specific shortened URL.PUT /api/shorten/urls/{id}: Update a specific shortened URL or its alias.Overall Design Considerations:
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...