Friday, May 26, 2017

Today we discuss another design question - this time for an online retail store 
An online retail store allows customers to have a great shopping experience.  They are able to browse the inventory, select the items and their quantity for purchase, put them in a shopping cart and checkout with one of their payment methods. The orders they place are then fulfilled and shipped to their address. In the process they collect rewards and participate in various campaigns, loyalty programs and surveys. This shopping is enabled on a variety of devices such as desktop and handheld devices. The primary use case is for selecting an item and purchasing it on desktop. We can estimate the traffic to the website as over a million transactions a day under peak load or anniversaries and primarily in one geographic region. The number of web requests is orders of magnitude more than the transactions as customers browse the site for items. The The store must have a high availability and with performance criteria established with Service Level Agreements.
Clearly we  have a combination of many independent services to power the shopping experience. As the store grows its customer base, the demands on the system will be expected to increase over time. Consequently each component and service must scale and the more decoupled they are, the easier it is to make changes or upgrade with little or no disruption. Consequently a service oriented architecture or better yet a microservices architecture helps with such a modular organization. Some of the services involved include  The User Interface, the services and the storage layer can now be focused and specific to each of the service as the overall website provides a unified experience over these services. This website issues requests to each of the services and is also organized as a consolidation over these services. The site itself is designed as a Model View Controller with an object relational mapping and providing standard enterprise application blocks such as Logging, Caching, Exception etc.  The configuration and resources are also maintained in separate repositories. The API services also allow mobile optimized websites and the services themselves can be external monitored and mentioned via application gateway.
 Some of these services include:
1) Authentication services : provides access tokens based on one or more methods to acquire them, relying on
a) password b) client id and user id c) authentication code, d) client credentials. Refresh tokens are also provided to keep the customers signed in
2) Loyalty service : The loyalty service provides Licenses with a way to integrate their loyalty systems
3) Account service: such as to create US Store account and non-US Store account, to validate and recover credentials, to create account profiles and to update social profile data.
4) Card service: Provides customer's card information to keep track of their purchases. This gives information such as Card URL, Card details, Card balances, and the ability to reload a store card.
5) Payment methods : Enables collection of sums from the customer using a payment method such as a credit card or PayPal
6) Rewards service: provides rewards summary and history information based on application user, points needed for next level, points needed for next free reward, points needed for re-evaluation etc.
7) Barcode service: The barcode service generates Barcodes to communicate with in-store scanners and applications.
8) Content service: These are used to retrieve localized contents for any web client. Content is stored and retrieved in site core.
9) Transaction History service: These are used to retrieve the history data for a specified user, for all cards.
10) Device Relationship service: These are used to insert or update a device, to get reporting actions such as touch-to-pay to display the barcode for scanning and touch-when-done to report when completing the barcode for scanning.
11) Product service : to browse the offerings of the store. This may become a full fledged MDM with terabytes of data.
#codingexercise
Enter a two digit number, find the year closest to this year. 
Example input 99, return 1999; 
Input 15, return 2015. 
public int getClosestYear(int input, int pivot=50, int current2DigitYear){
if  (y < pivot+ current2DigitYear %100)
   return 2000+y;
else
   return 1900+y;
}
We can also work this by taking the remaining from the 100 to see if the offset needs to be 1900 or 2000.

No comments:

Post a Comment