System Design ( Day - 28 )

Manoj KumarManoj Kumar
4 min read

System Design of E-Commerce

Requirements
1. Search the Products
2. Card → Add, Delete, Quantity
3. Payment
4. Delivery (requires Notifications)
5. Order Tracking

Architecture
While choosing the architecture, there are many things that has to be taken care off like, team size, and how fast do you need the MVP( minimum valuable product), if this MVP is the high priority then we can easily go for the Monolithic architecture, here the development would be fast enough to create a MVP, if we our priority is not scaling for now, then also we can go for the monolithic, or else, if we have big teams, and we want scalable product then we can go for the Micro-Services architecture.

Searching
We can do Select * on the Db for product, there is no problem with this but the performance is going to down when it comes to searching the description its not going to give the response quickly, for this thing we have to use the Elastic Search, through the elastic search we can reduce that query time, increase the response time.
We’ll have one service to add the products from the seller to the Database and the after adding the data into the database, we’ll add that same data into the Elastic Search, in which it uses NoSql,
Through this we can able to search the product with that productId that would be scalable.
When it comes to Monitoring
we’ll take a scenario, a user is trying to place an order, he searched for product, added to the card and added his address and chooses the online payment that E-com is using third party payment service like RazorPay or Stripe, then the user goes to the RazorPay interface and confirms his online payment the amount is deducted from his account, after that the stripe has to respond to the backend service that i have received the amount or something like that, but it didn’t happened, that payment stuck in Between, at that time the service will wait for another minute(it may be different) or so, after that it will notifies that issue to the related department or user who’s responsible for clearing that issue, so like this way the monitoring works to prevent any of the payment issues between the user and the payment service.

We can have another service which is for Health Check Service it will check like HeartBeats for every 5 seconds it that service gives 200 ok then it will think that that service is fine, if it is not responding for once, it may think that it would be glitch or something, again it will send that heart beat check request if it responds then everything would be fine, or else that health check service will run some scripts and then try to restart that service, then also that service is not working then it will alert or notifies to the slack or sends sms about the issue.
When it comes to Metrices we have to keep track of each requests and responses about their status, in which how many are missed how many are being served successfully, how many are falling, we can set a threshold for the fail requests, after reaching some limit we can hit an alert or notify someone.

Storing Images and Videos
We can use S3 for storing the images and videos, while the seller is adding the new product we have to give them some function to add images and videos it would be 30 seconds long, and that is stored in the S3 after storing that will give us link so that if we want to use it in the future then we can access it with that link, That link would be stored along with the Product details.

When it comes to payments we can integrate a third party payment service like RazorPay or Stripe or else we can build our payment service from scratch, and integrate with our application.

Order Tracking
After Successfully placing and order that order will goes to the Supplier or the Seller, after that the order will be packed and assign the Order Id to it, when it comes to the Delivery we can use the third party service for delivery, like Delivery, Ekart etc.. and then we’ll assign that Order Id to that, through them we can easily track our orders.

0
Subscribe to my newsletter

Read articles from Manoj Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Manoj Kumar
Manoj Kumar