List the key functional requirements for the system (Ask the AI for hints if stuck)...
List the key non-functional requirements (performance, scalability, reliability, etc.)...
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
POST /tags/create
body { tag_name, tag_description}
assign tag to a contnet
POST /tags/{tag_id}/content/{content_id}
GET /contents/tags/{tag_id}
POST /tags/update/{tag_id}
GET /content/suggests/tags
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Load Balancer, directs the load and implements rate limiter to block the bots.
API Gateway redirects the routes to read and write service to scale them independently. It also implements OAuth/JWT for authentication/authorization.
Read Server - Has all the read api implementaton "GET /contents/tags/{tag_id}" "GET /content/suggests/tags" etc.
For search service, it uses elasticSearch
Write Server - Implements all the write operations "POST /tags/create" "POST /tags/{tag_id}/content/{content_id}" "POST /tags/update/{tag_id}"
Suggestion Service - It uses web crawlers and search for the keywords based on which it provides suggestions for a content.
Redis Cache - Read Server hits redis cache first and the TTL will be 0 everytime there is a write operation, default TTL, will be 10 mins.
Database, we will use DynamoDB for high scale reads.
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
{
PK: tag#tag_id
SK: metadata
creator:
updator:
createdAt:
}
{
PK: item#itemId
SK: tag_id+itemId
creator:
updator:
createdAt:
tags: [{tag_id1}]
}
{
PK: alias_name
SK: tag_id
aliases :["name1", "name2"]
}
Dynamodb selection to handle high read
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
For idempotent tag assignment, we will create {tag_id+itemId} as Sort Key.
Since the Elastic search is using SQS, if it goes down, the SQS will store the messages for 14 days and once elasticsearch comes back up, the messages will be processed, meanwhile, we will disable the search functionality till it is down.