When I was in Japan , I got an Interview call from one the Indeed.com for Engineering Manager position.
After TA Round recruiter told there will be 3 loop Interview focusing on System Design Interview , Behavioural and HR Round .
As I was not much aware of System Design Interview so I start preparing ,bought one subscription from AlgoExpert and start preparing the Interview.
Problem :
Design a feature in Indeed.com where an user can subscribe Jobs by adding his Email, Job Type and Skill .He should get daily email about relevant jobs.
That time I could not able to solve this problem as I was not aware of how to approach System Design Interview I directly jumped on DNS, Load balancers, Scaling etc without thinking about the Apis, Database design, and Notification System/Queue that will send the emails.
Sometimes interviewers asks you to design a component or a feature for existing system. System is already running and all the infra already there.
Now you dont need to worry about LoadBalancer, Sharding, Scalability etc.
In above case I have to design specific feature not the whole System , so I divided this problem in four parts.
User Experience
Api Design
Database Structure
Email Notification System:
In UX parts I would like to have a Input Text Component along with Skill ,Job Type DropDown and Subscribe button.
User will enter his Email ,Skill for which he want job and JobType or Role he will select and press Subscribe to get Email alerts about relevant Jobs..
Api Design
Api will be very simple for subscribe Job:
POST : /api/v1/getJobAlert
body :
{
"skillId": 123,
"roleId": 1001,
"email": "betterengineers.substack.com",
}
User Table:
user_id (Primary Key)
email
name
Job Table:
job_id (Primary Key)
job_title
job_type (e.g., Full-time, Part-time, Contract)
position
position
skill_id (Foreign Key to Company Table)
Subscription Table:
subscription_id (Primary Key)
user_id (Foreign Key to User Table)
company
job_type
job_position
last_notified (Date of last notification sent)
skills
Notification Table (Optional for scalability):
notification_id (Primary Key)
user_id
job_id
sent_date
Components
JobPosting Service
Subscription Service
Message Queue
Email Service
Job Posting Service :
Job Posting service will be responsible for Posting Jobs in the database . It will keep updating cache for most Recent Jobs added .
Subscription Service :
Subscription service will create the subscriptions for particular Job/Skills for Users .
It will store user_id
and job_type
in the table which will .
Subscription Service also create a worker which will keep checking subscription table and gather the relevant jobs for the users.
When a new job is posted or when a user subscribes to a new job type/position, the Subscription Service is triggered.
The Subscription Service fetches the user's preferences and uses a query to search the Job Database for jobs that match the user's criteria.
Caching for Efficiency:
To improve performance, user subscription preferences and recent job postings can be cached.
When a user’s subscription preferences or a new job posting triggers the service, the cache is checked first before querying the database.
This avoids unnecessary database calls and speeds up the matching process, especially when there are large volumes of users and job postings.
Message Queue :
When the Subscription Service identifies a new job posting that matches a user’s subscription preferences, it doesn't immediately send an email.
Instead, the service publishes a message to a Message Queue (e.g., RabbitMQ, Kafka, AWS SQS).
Message Queue:
The message queue acts as a buffer between the Subscription Service and the Email Service.
It decouples the process, allowing the Subscription Service to continue its operation without waiting for the Email Service to complete the notification process.
If you want to learn about Kafka read my Kafka blog Part 1 and Part 2 .
Email Service :
The Email Service is subscribed to the message queue and listens for new messages.
Once it retrieves a message from the queue, it processes the information to compose and send an email to the user.
This allows the Email Service to work asynchronously and at its own pace, handling high loads more effectively.
This design ensures that the system is scalable, efficient, and user-friendly, allowing users to stay updated on job opportunities tailored to their interests without overwhelming them with irrelevant information.
If you think I missed something feel free to leave a comment .
Thanks for reading.
What about "unsubscribe"? ;)