KHCA

From a Simple Click to a Global Digital Commerce Ecosystem

Part 2 – Inside Amazon’s Frontend: How Every Click Becomes an Action

Inside Amazon Part 2 showing frontend architecture, HTML, CSS, JavaScript, React, APIs, CDN and AWS cloud technology
Discover the frontend technologies powering modern e-commerce shopping experiences.

Table of Contents

1. Introduction: What Happens When You Open Amazon?

Imagine that you open the Amazon website on your computer. You see a search bar, product images, prices, categories, offers and your shopping cart.

You search for a laptop. Amazon displays hundreds of products. You click one laptop, select a seller, add it to your cart and continue shopping.

For a normal user, this looks like a simple activity. But behind this experience, many frontend technologies work together.

Every button you click, every product image you see and every search result displayed on the screen is managed through different frontend components and technologies.

The frontend is responsible for everything the user can see and interact with. It receives user actions, communicates with the backend, processes responses and updates the screen.

In modern e-commerce platforms like Amazon, frontend development involves several important technologies, including HTML, CSS, JavaScript, TypeScript, React, APIs and browser rendering.

These technologies work together to create a responsive, interactive and user-friendly shopping experience.

The frontend is the communication bridge between the user and the application’s backend systems.

In this part, we will understand how this bridge works. We will explore Amazon frontend architecture step by step, starting from basic web technologies and moving towards advanced concepts such as component architecture, API communication, authentication, performance optimisation and frontend security.

By the end of this article, you will understand how a large e-commerce website manages its user interface and communicates with backend systems.

2. What Is Frontend Development in Amazon’s E-commerce Architecture?

Frontend development means building the user-facing part of a website or application. It focuses on the visual elements, layout, buttons, menus and interactive features that users see and use.

In an e-commerce website like Amazon, the frontend provides the complete shopping interface. It allows customers to search for products, view product details, select sellers, add items to their cart and complete purchases.

For an e-commerce website, the frontend includes:

Example: Understanding a Product Card

Consider a product card displayed on an e-commerce website:

Example Laptop – 15.6-inch

This small card may contain text, images, buttons, prices, ratings and availability information. The frontend arranges all these elements and makes them interactive.

For example, when a customer clicks the Add to Cart button, the frontend captures that action and communicates with the backend through an API. The backend processes the request and sends a response, which the frontend uses to update the shopping cart on the screen.

This is how frontend development connects the visual interface with the application’s business logic.

3. Main Technologies Used in Amazon Frontend Development

Amazon frontend technologies including HTML, CSS, JavaScript, TypeScript and React
Discover the five key frontend technologies used to build modern e-commerce user interfaces.

Frontend development is not based on one programming language. Different technologies have different responsibilities. Together, they help developers build modern, interactive and responsive websites.

In large e-commerce platforms like Amazon, frontend architecture requires multiple technologies to manage webpage structure, visual design, user interactions and communication with backend systems.

Let’s understand the five important frontend technologies and their roles in website development.

3.1 HTML – Structure of the Website

HTML stands for HyperText Markup Language.

HTML defines the structure of a webpage. It creates headings, paragraphs, images, buttons, forms and links.

For example, HTML creates the structure of a product card containing a product name, price and Add to Cart button.

In an e-commerce website, HTML provides the basic structure for product listings, navigation menus, search boxes, login forms and shopping cart sections.

3.2 CSS – Design and Layout

CSS stands for Cascading Style Sheets.

CSS controls colours, fonts, spacing, borders, animations and responsive layouts.

Without CSS, a webpage would mostly display its content without the visual design that users expect from a modern website.

In e-commerce frontend development, CSS helps create attractive product cards, organised layouts, navigation menus and mobile-friendly shopping pages.

It also allows developers to make websites responsive so that they work properly on desktops, tablets and smartphones.

3.3 JavaScript – Functionality

JavaScript makes a website interactive.

It handles:

For example, when a customer clicks Add to Cart, JavaScript can capture that event and send a request to the backend.

JavaScript can also update the shopping cart count, display messages, validate user input and dynamically show product information without reloading the entire webpage.

This makes JavaScript an important part of modern e-commerce frontend architecture.

3.4 TypeScript – Safer JavaScript Development

TypeScript adds static type checking to JavaScript.

It helps developers detect many coding mistakes before running the application.

For example, a developer can define that a product price must be a number rather than a text value.

This becomes especially useful in large applications where developers work with complex product data, customer information, API responses and reusable components.

TypeScript helps make code easier to maintain and understand as an application grows.

3.5 React – Building User Interfaces

React is a JavaScript library for building user interfaces using reusable components.

It allows developers to create separate components such as:

For example, developers can create one reusable Product Card component and use it to display hundreds of products with different names, prices, images and ratings.

This component-based approach makes frontend development more organised and easier to maintain.

Important: These are common frontend technologies. They help us understand how a large e-commerce frontend can be built. We should not assume that every part of Amazon’s current website uses exactly this technology stack.

How Do These Frontend Technologies Work Together?

Each technology has a different responsibility:

TechnologyMain Responsibility
HTMLCreates webpage structure
CSSControls design and layout
JavaScriptAdds functionality and interactivity
TypeScriptAdds static type checking
ReactBuilds reusable user interface components

When these technologies work together, developers can build a complete frontend application that displays products, handles customer interactions and communicates with backend services.

Understanding these technologies is the first step towards learning how large e-commerce platforms manage their frontend architecture.

4. How HTML, CSS and JavaScript Work Together in Amazon Frontend Development

HTML, CSS and JavaScript are the three fundamental technologies used in frontend web development. Each technology performs a different task, but they work together to create interactive and user-friendly websites.

Let’s understand this with a simple e-commerce product card example.

Suppose we want to create a product card with a button.

Step 1: HTML Creates the Structure

HTML defines the basic structure of the product card. It creates the product heading, price information and Add to Cart button.

<div class="product-card">
  <h2>Example Laptop</h2>
  <p>Price: ₹49,999</p>
  <button id="cartButton">
    Add to Cart
  </button>
</div>

In this example:

Step 2: CSS Makes It Attractive

CSS controls the appearance and layout of the product card. It adds spacing, borders, rounded corners and button styling.

.product-card {
  width: 280px;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-family: Arial;
}

.product-card button {
  background: #ffd814;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 5px;
}

In this example:

Step 3: JavaScript Adds Functionality

JavaScript makes the product card interactive. It detects when the customer clicks the Add to Cart button and performs an action.

document
  .getElementById("cartButton")
  .addEventListener("click", function () {
    alert("Product added to cart!");
  });

In this example:

What Happens When These Three Technologies Work Together?

Now the user can see the product card and click the button. JavaScript responds to the click.

The complete process is:

  1. HTML creates the product card structure.
  2. CSS controls its appearance and layout.
  3. JavaScript handles the customer’s button click.
  4. The browser displays the updated interactive experience.

This is the basic foundation of an interactive e-commerce frontend.

How Is This Used in a Large E-commerce Website?

In a real e-commerce application, the process can become more advanced. When a customer clicks Add to Cart, JavaScript may send an API request to the backend. The backend validates the product information and processes the cart operation. The frontend then updates the cart count or displays a confirmation message based on the backend response.

This is how basic frontend technologies become part of a larger e-commerce architecture.

5. How Does a Browser Display a Website? Understanding the Browser Rendering Process

Browser rendering process showing HTML DOM CSSOM render tree layout paint and compositing
Understand how a browser converts HTML, CSS and JavaScript into a visible webpage.

When you enter an address such as www.amazon.in, your browser does much more than simply display a page.

It follows a series of steps to download, process and display the website’s content. This process is known as browser rendering.

The browser takes HTML, CSS and JavaScript files and converts them into the visual webpage that users can see and interact with.

Let’s understand how this browser rendering process works step by step.

Step 1: HTML Is Downloaded

The browser requests the webpage and receives HTML content from a server.

This HTML contains the basic structure of the webpage, including headings, paragraphs, images, buttons and other elements.

Step 2: DOM Is Created

DOM stands for Document Object Model.

The browser converts HTML into a tree-like structure.

For example:

<body>
  <h1>Welcome to Amazon</h1>
  <button>Shop Now</button>
</body>

The browser creates a document structure containing the heading and button.

This structure is called the DOM tree. JavaScript can access and modify DOM elements to make the webpage interactive.

Step 3: CSS Is Processed

The browser reads CSS rules and understands how each element should look.

CSS provides information about colours, fonts, spacing, borders, dimensions and layouts.

The browser uses this styling information to determine the visual appearance of webpage elements.

Step 4: Render Tree Is Created

The browser combines the visible DOM elements and their styling information.

This creates the Render Tree, which contains the elements that need to be displayed on the screen along with their visual styling information.

Step 5: Layout

The browser calculates the size and position of each element.

For example, it determines:

This process is also known as Layout or Reflow.

Step 6: Paint and Compositing

The browser draws text, images, backgrounds and other visual elements. It then combines the necessary layers to display the final page.

Painting creates the visual parts of the webpage, while compositing combines the required layers for display.

This complete process is called the browser rendering pipeline.

What Is the JavaScript Engine?

A JavaScript engine executes JavaScript code in the browser.

It allows websites to respond to user actions, process JavaScript instructions and update webpage content dynamically.

For example:

When a user clicks a button, JavaScript can respond to the event and update the webpage.

In a large e-commerce website, JavaScript can handle product interactions, search suggestions, shopping cart updates and other dynamic user interface features.

Why Is Browser Rendering Important for Amazon Frontend Architecture?

A large e-commerce website may display thousands of product images, prices, buttons and other interface elements.

The browser must process and display these elements efficiently to provide a smooth shopping experience.

Understanding the browser rendering pipeline helps frontend developers identify performance problems, optimise webpage loading and build responsive user interfaces.

It is an important concept for understanding how modern websites deliver fast and interactive experiences.

6. How Does a Large Website Manage Thousands of Components?

Imagine that Amazon has to display thousands of product cards, search suggestions, navigation menus and customer account sections.

Writing every element separately would make development difficult.

This is why modern frontend development uses Component-Based Architecture.

A component is a small, reusable part of the user interface.

For example, an e-commerce website may have:

A product card can be reused for different products by passing different data to it.

Example Using React

function ProductCard({ name, price }) {
  return (
    <div className="product-card">
      <h2>{name}</h2>
      <p>₹{price}</p>
      <button>Add to Cart</button>
    </div>
  );
}

function App() {
  return (
    <div>
      <ProductCard
        name="Laptop"
        price="49999"
      />

      <ProductCard
        name="Keyboard"
        price="999"
      />
    </div>
  );
}

Here, ProductCard is created once but reused for different products.

The actual product information can come from an API rather than being written directly in the code.

Why Are Components Useful?

  1. Code can be reused.
  2. Development becomes easier.
  3. Changes can be made in one place.
  4. Different teams can work on different components.
  5. Testing and maintenance become simpler.

7. How Does Amazon Identify a Product When You Click It? Understanding Product IDs, ASIN and Seller IDs

	Amazon product identification showing Product ID, ASIN, Seller ID and product lookup process
Understand how Amazon identifies products and sellers using ASIN, Product IDs and Seller IDs.

This is one of the most important concepts in e-commerce application development.

Suppose you search for a laptop and see three different laptops with similar names.

You click the second laptop.

How does the system know which product you selected?

Does it identify the product by its name or image?

Usually, a properly designed e-commerce application uses unique identifiers rather than depending on product names.

These identifiers help the frontend and backend identify products, sellers, inventory items and purchase offers accurately.

Understanding Product Identifiers in Amazon’s E-commerce Architecture

Different identifiers can be used for different purposes.

IdentifierMeaning
Product IDUnique internal identifier for a product
ASINAmazon Standard Identification Number
SKUStock Keeping Unit, often used to identify a particular seller’s stock item
Offer IDIdentifier for a specific purchase offer, where supported
Seller IDIdentifies the seller

ASIN is an Amazon-specific product identifier. SKU is commonly used in inventory and seller systems. These identifiers are not interchangeable.

Each identifier serves a different purpose in an e-commerce system. Understanding their differences helps developers design better product catalogues, inventory systems and seller management applications.

Example: One Product, Multiple Sellers

Imagine that three sellers offer the same laptop model.

Example Laptop Model X

SellerPriceDelivery
Seller A₹49,9992 days
Seller B₹48,9994 days
Seller C₹50,4993 days

Notice that the product is the same, but the sellers, prices and delivery estimates are different.

Therefore, an e-commerce system may need to identify two things:

  1. Which product did the customer select?
  2. Which seller’s offer is being considered for purchase?

This distinction is important because a product represents the item in the catalogue, while an offer represents a seller’s specific purchasing option for that product.

How the Product Click Works

When a customer clicks a product, the frontend and backend work together to retrieve the correct product information.

  1. Customer clicks a product.
  2. Frontend reads the product identifier.
  3. Frontend sends an API request.
  4. Backend retrieves product information.
  5. Frontend displays product details.

For example, the frontend may send:

GET /api/products/PROD1001

The backend receives the product ID and retrieves the corresponding product information.

Example of Product Data

A backend API might return data like this:

{
  "productId": "PROD1001",
  "name": "Example Laptop",
  "brand": "Example Brand",
  "price": 49999,
  "currency": "INR",
  "offers": [
    {
      "sellerId": "SELLER01",
      "price": 49999
    },
    {
      "sellerId": "SELLER02",
      "price": 48999
    }
  ]
}

This is an educational example of an e-commerce API response, not an actual Amazon API response.

The frontend receives the information and displays it to the customer.

Why Are Product Identifiers Important?

Product identifiers help an e-commerce application:

Important: The frontend should not be trusted to decide the final product price. The backend must validate the selected product, seller offer, current price, stock availability and applicable discounts before processing an order. A customer changing the displayed price in the browser must not change the actual purchase price.

Understanding product IDs, ASIN, SKU and seller IDs is an important part of learning how large e-commerce platforms organise product catalogues and process customer purchases.

8. How Does Amazon Frontend Architecture Communicate With the Backend Through APIs?

The frontend cannot independently know everything about the business.

For example, it cannot safely decide:

It needs information from backend services.

This communication usually happens through APIs (Application Programming Interfaces).

In a large e-commerce application, the frontend sends requests to backend services to retrieve information or perform operations. The backend processes these requests, communicates with databases or other services and sends responses back to the frontend.

What Is an API?

API stands for Application Programming Interface.

An API allows two software systems to communicate with each other through defined rules.

For example:

  1. Frontend asks for product details.
  2. Backend processes the request.
  3. Backend returns product information.
  4. Frontend displays the response.

Think of an API as a communication channel between the frontend and backend. It defines how a request should be sent and what kind of response the application can receive.

What Is HTTP?

HTTP stands for Hypertext Transfer Protocol.

It is a protocol used for communication between clients and servers.

When a browser or frontend application communicates with a backend API, HTTP methods describe the type of operation being requested.

Common HTTP methods:

MethodPurposeExample
GETRetrieve dataGet product details
POSTCreate or submit dataAdd an item to cart
PUTReplace a resourceUpdate an address
PATCHPartially update dataChange delivery preference
DELETEDelete a resourceRemove a cart item

These methods help developers organise API operations and define how the frontend interacts with backend resources.

Example: Product Details API

Suppose a customer clicks a laptop on an e-commerce website. The frontend needs to retrieve the product details from the backend.

Request:

GET /api/products/PROD1001

Possible response:

HTTP/1.1 200 OK
Content-Type: application/json
{
  "productId": "PROD1001",
  "name": "Example Laptop",
  "price": 49999,
  "availability": "IN_STOCK"
}

The frontend reads this JSON response and updates the product page.

For example, it can display the product name, price and stock availability using the information received from the backend.

Important HTTP Status Codes

When the backend receives an API request, it sends an HTTP status code to indicate the result.

Status CodeMeaning
200Request successful
201Resource created
400Invalid request
401Authentication required
403Access not allowed
404Resource not found
409Conflict
500Server error
503Service unavailable

For example, if a product does not exist, the backend may return 404 Not Found.

If a user is not logged in and tries to access a protected page, the backend may return 401 Unauthorized.

How Does This Communication Work in an E-commerce Website?

Consider a customer opening a laptop product page.

The communication process can be understood as follows:

  1. The browser displays the product page.
  2. The frontend sends a GET request to the product API.
  3. The backend receives the request.
  4. The backend retrieves the required product information.
  5. The backend sends a JSON response with an appropriate status code.
  6. The frontend processes the response and displays the product details.

This request-and-response process is a fundamental part of modern web application architecture.

Why Is Frontend-Backend Communication Important?

Without backend communication, a frontend application cannot reliably access live product information, customer accounts, inventory records, payment results or order status.

APIs connect the user interface with the business logic and data managed by backend systems.

Understanding APIs, HTTP methods, JSON responses and status codes is essential for students who want to learn full-stack development and understand how large e-commerce platforms work.

9. What Happens When a User Clicks Add to Cart in Amazon Frontend Architecture?

Let’s continue with our laptop example.

The user clicks Add to Cart.

The frontend first captures the click event and prepares a request.

In a modern e-commerce application, this action involves communication between the browser, frontend JavaScript and backend services.

A simplified example:

async function addToCart(productId) {
  try {
    const response = await fetch(
      "/api/cart/items",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          productId: productId,
          quantity: 1
        })
      }
    );

    if (!response.ok) {
      throw new Error("Unable to add product");
    }

    const result = await response.json();

    console.log(result.message);

  } catch (error) {
    console.error(error.message);
  }
}

addToCart("PROD1001");

Understanding the JavaScript Code

Let’s understand what happens in this example:

This is a simplified example of how frontend JavaScript communicates with a shopping cart API.

What Happens Behind the Scenes?

When the customer clicks Add to Cart, several operations take place between the frontend and backend.

  1. User clicks the button.
  2. JavaScript captures the click.
  3. Frontend sends a POST request.
  4. Backend identifies the customer or session.
  5. Backend checks the product and offer.
  6. Backend validates the request and applicable rules.
  7. Backend updates the cart.
  8. Backend returns a response.
  9. Frontend updates the cart icon or displays a confirmation.

Understanding the Backend Processing

The backend performs important checks before updating the shopping cart.

For example, it may verify:

After processing the request, the backend sends a response to the frontend.

The frontend uses that response to update the shopping cart count or display a confirmation message.

Does Adding a Product to the Cart Reserve Stock?

The actual stock reservation and order confirmation processes can involve additional backend services. Adding something to the cart does not necessarily mean that stock has been reserved.

This distinction is important in e-commerce system design.

A product can be present in a customer’s shopping cart without being permanently reserved for that customer. Inventory validation and reservation rules are handled by backend systems according to the application’s business logic.

Why Is the Add to Cart Process Important?

The Add to Cart operation demonstrates how different parts of an e-commerce application work together:

This simple button demonstrates an important concept in Amazon frontend architecture: a user interface action can trigger multiple backend operations through API communication.

10. How Does Amazon Know Which Customer Is Logged In? Authentication, Sessions, Cookies and Tokens

Suppose you log in to Amazon using your email address and password.

You open a product, add it to your cart and then move to another page.

How does the website know that the same customer is still using it?

The answer involves Authentication, Sessions, Cookies and Tokens.

These technologies help modern e-commerce websites maintain user identity across multiple pages and API requests.

Without proper authentication and session management, a website would not be able to securely manage customer accounts, shopping carts, order history and personal information.

Authentication vs Authorisation

These two terms have different meanings.

For example, a customer can view their own orders, but they should not be able to view another customer’s private order details.

Authentication confirms the customer’s identity, while authorisation controls access to protected resources.

What Is a Session?

A session represents an authenticated user’s interaction with an application.

After successful login, a server may create a session and provide a session identifier to the browser.

The browser sends the appropriate session information with later requests.

The backend uses this information to identify the user’s session and determine whether the request belongs to an authenticated customer.

For example, when a customer moves from the homepage to a product page and then to the shopping cart, the application can maintain the customer’s login session.

What Are Cookies?

Cookies are small pieces of data stored by the browser for a website.

They can help maintain login sessions and remember certain user preferences.

For example, a simplified cookie might look like:

Set-Cookie: session_id=abc123; HttpOnly; Secure; SameSite=Lax

This is an illustrative example, not an actual Amazon cookie.

Important cookie attributes:

AttributePurpose
HttpOnlyPrevents JavaScript from reading the cookie
SecureSends the cookie only over secure HTTPS connections
SameSiteControls when the browser sends cookies in cross-site requests
Expires / Max-AgeControls cookie lifetime

These attributes help developers protect session cookies and reduce certain security risks.

What Are Access Tokens?

Some applications use tokens to authenticate API requests.

For example, an application might send:

Authorization: Bearer ACCESS_TOKEN

The backend validates the token and determines whether the request is authorised.

Tokens can be used in different ways depending on the application architecture.

For example, an application may use access tokens with a defined expiry time and a separate refresh mechanism to maintain authentication.

The exact token management approach depends on the application’s security requirements and architecture.

Cookies vs Local Storage vs Session Storage

Web browsers provide different storage mechanisms for managing website data.

FeatureCookiesLocal StorageSession Storage
StorageBrowserBrowserBrowser tab/session
Automatically sent with HTTP requestsYes, when matching cookie rulesNoNo
Typical useSession managementPreferences and non-sensitive dataTemporary page state
JavaScript accessDepends on HttpOnlyYesYes

Each storage mechanism has a different purpose.

Cookies can be automatically included in matching HTTP requests, while Local Storage and Session Storage require JavaScript to read their values and send them when needed.

Security lesson: Never store passwords or sensitive authentication information in ordinary browser storage. Authentication design requires careful protection against token theft, cross-site scripting and other attacks.

How Does This Work in Amazon Frontend Architecture?

Consider a customer who logs in and adds a laptop to the shopping cart.

The simplified process is:

  1. Customer enters login credentials.
  2. The authentication system verifies the credentials.
  3. The application establishes an authenticated session or issues an appropriate authentication token.
  4. The browser includes the required authentication information with subsequent requests.
  5. Backend services verify the customer’s identity and permissions.
  6. The application provides access to the customer’s authorised information.

This is how authentication and session management help an e-commerce application maintain customer identity across different pages and operations.

Understanding these concepts is important for frontend developers because login screens, protected pages, shopping carts and customer account sections all depend on secure communication between the frontend and backend.

11. How Does Amazon Load Product Images So Quickly? CDN and Image Optimisation Explained

Imagine Amazon displays 100 products on one page.

Each product may have several images. Downloading all images at their original size could make the page very slow.

Large websites therefore use image optimisation and content delivery techniques to improve website performance and provide a faster shopping experience.

In modern e-commerce frontend architecture, techniques such as Content Delivery Networks (CDNs), image compression, caching and lazy loading help deliver product images efficiently.

What Is a CDN?

CDN stands for Content Delivery Network.

A CDN distributes content through servers located in different geographical regions.

For example, a customer in India may receive an image from a nearby CDN location instead of downloading it from a distant origin server.

This can reduce network latency and improve image loading speed.

A simplified image delivery process:

  1. Browser requests an image.
  2. CDN checks whether it has a cached copy.
  3. If available, CDN sends the image.
  4. If not available, it may retrieve it from the origin server.
  5. The image is cached according to the configured rules.

This process helps reduce repeated requests to the origin server and improves content delivery for users in different locations.

What Is Lazy Loading?

Lazy loading means loading images when they are needed rather than loading every image immediately.

For example, consider a product listing page containing 100 products. The customer initially sees only the first few products. There is no need to download every image immediately if most products are far below the visible screen area.

Example:

<img
  src="laptop.jpg"
  alt="Example laptop"
  loading="lazy"
/>

When the customer scrolls towards the image, the browser can load it.

This reduces unnecessary network usage, especially on long product pages.

Other Image Optimisation Techniques

Large e-commerce websites can use several techniques to improve product image delivery:

Why Is Image Optimisation Important for Amazon Frontend Architecture?

Product images are an important part of the online shopping experience. Customers use them to understand product appearance, design and features.

If images take too long to load, the shopping experience becomes frustrating.

CDNs, lazy loading, caching and image compression help frontend developers improve page performance while reducing unnecessary network requests.

For students, understanding these techniques is important because image optimisation is a fundamental part of building fast and scalable e-commerce websites.

12. How Does Amazon Frontend Architecture Work on Mobile Phones? Responsive Web Design Explained

A customer may open Amazon on:

The screen size and user interaction methods are different.

A desktop computer has a large display, while a mobile phone has a smaller screen. Users may interact through a mouse and keyboard on a computer, but they generally use touch gestures on mobile devices.

A good frontend must adapt to these devices and provide a consistent shopping experience.

This is called Responsive Web Design.

What Is Responsive Design?

Responsive design allows the same website to adjust its layout according to the screen size.

For example, an e-commerce website may display four product columns on a desktop but only one or two columns on a mobile phone.

DesktopMobile
Four product columnsOne or two product columns
Full navigation menuCompact navigation
Large search barSmaller search interface
Mouse interactionTouch interaction

Responsive design uses flexible layouts, CSS Grid, Flexbox, media queries and appropriately sized images to adapt the interface.

It is important because customers should be able to search for products, view product details, add items to their cart and complete purchases comfortably on different devices.

Example Using CSS Media Queries

CSS media queries allow developers to apply different styles according to screen characteristics such as viewport width.

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

@media (max-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

The browser changes the number of columns based on the screen width.

How does this code work?

  1. Default CSS: The product grid displays four columns.
  2. At 768px or below: The media query changes the layout to two columns.
  3. At 480px or below: The layout changes to one column.

Here, repeat(4, 1fr) creates four equal-width columns, while gap: 20px adds spacing between products.

The @media rule applies CSS only when the specified screen condition is satisfied.

What About Android and iOS Apps?

A mobile app is not simply a website opened on a phone.

Native Android and iOS applications can use platform-specific development technologies. Developers can also use cross-platform frameworks to build applications for multiple operating systems.

PlatformCommon Technologies
AndroidKotlin, Java
iOSSwift
Cross-platformReact Native, Flutter

These are common industry technologies. They should not be interpreted as a confirmed list of technologies used by every Amazon mobile application.

Responsive Website vs Native Mobile Application

A responsive website runs inside a web browser and adjusts its layout according to the device.

A native mobile application is developed for a specific operating system and can use platform features through its native APIs.

For example:

Both approaches can communicate with backend services through APIs. However, their user interfaces, deployment methods and access to device features may differ.

Why Is Mobile Compatibility Important in E-commerce?

Customers may browse products using a laptop during the day and use a mobile phone later.

A mobile-friendly frontend should provide:

For frontend developers, responsive design is not just about making a website smaller. It is about adapting the user experience to different devices and interaction methods.

13. How Does Amazon Make Its Frontend Fast? 6 Website Performance Optimisation Techniques

A slow shopping website can frustrate customers.

Imagine that a customer clicks a product but waits ten seconds for the page to load. The customer may leave the website.

Frontend performance is therefore an important part of e-commerce development.

For large e-commerce platforms, frontend performance involves more than reducing page loading time. Developers must optimise JavaScript, CSS, images, API requests, browser rendering and the overall user experience.

Here are six important techniques used in modern frontend development to improve website performance.

1. Code Splitting

Instead of downloading the entire application at once, the application can load only the required code for a particular page or feature.

For example, a shopping website may have separate features for:

A customer viewing a product page may not need the complete checkout application code immediately.

Code splitting divides the application into smaller JavaScript bundles. The browser can download the required bundles when needed.

Benefits of code splitting:

2. Lazy Loading

Images and other resources can be loaded when they are needed.

For example, if a page contains 100 product images, the browser does not necessarily need to load all images immediately.

Images below the visible screen area can be loaded as the customer scrolls towards them.

Example:

<img
  src="laptop.jpg"
  alt="Example laptop"
  loading="lazy"
/>

Lazy loading helps reduce unnecessary network usage and can improve the initial page loading experience.

3. Caching

Frequently requested content can be stored temporarily to avoid downloading it again.

For example, a website may cache:

When the browser or CDN has a valid cached copy, it may reuse that copy instead of downloading the resource again from the origin server.

Benefits of caching:

Developers must configure caching rules carefully. Frequently changing information, such as stock availability and order status, may require different caching strategies from static images or CSS files.

4. Minification

Unnecessary spaces and characters can be removed from JavaScript and CSS files to reduce their size.

For example, readable JavaScript code:

function calculateTotal(price, quantity) {
  return price * quantity;
}

A minified version:

function calculateTotal(a,b){return a*b}

Both examples perform the same calculation.

Minification reduces file size and can help the browser download resources faster. Production build tools can also perform bundling and other optimisations.

5. API Optimisation

The frontend should avoid unnecessary API calls and should request only the data required for the current screen.

Imagine that a product listing page needs only:

It may not need to download every technical specification, customer review and order history for every product.

A well-designed API response can provide the information required by the frontend without transferring unnecessary data.

Common API optimisation techniques include:

API optimisation improves the communication between frontend applications and backend services.

6. Skeleton Loading

A temporary placeholder can be displayed while the actual content is loading.

For example, when a customer opens a product listing page, grey placeholder blocks may appear where product images, names and prices will eventually be displayed.

Once the actual API response arrives, the placeholders are replaced with real product information.

This technique is called Skeleton Loading.

Why is it useful?

What Are Core Web Vitals?

Core Web Vitals are Google’s measurements of important aspects of user experience.

They help developers understand how quickly a webpage loads, how well it responds to user interactions and whether its layout remains visually stable.

MetricWhat It Measures
LCPHow quickly the main content appears
INPHow responsive the page is to user interactions
CLSHow much the page layout unexpectedly shifts

Understanding the three metrics:

A good frontend developer should understand these metrics and know how to identify performance problems.

How Can Developers Measure Frontend Performance?

Developers can use tools such as:

  1. Google PageSpeed Insights: Analyses webpage performance and provides optimisation suggestions.
  2. Chrome DevTools: Helps inspect network requests, JavaScript execution, rendering and performance.
  3. Lighthouse: Audits performance, accessibility, SEO and other aspects of a webpage.

These tools help developers identify issues such as large images, slow API responses, excessive JavaScript and layout shifts.

Why Is Frontend Performance Important for E-commerce?

A fast website provides a smoother shopping experience. Customers can browse products, open product details, compare prices and interact with the shopping cart more comfortably.

For students learning frontend development, these techniques are important because building a website is not enough. Developers must also make sure that it performs efficiently under different network conditions and on different devices.

Remember: A good frontend is not only visually attractive. It should also be fast, responsive, accessible and reliable.

asurements and use tools such as Chrome DevTools and PageSpeed Insights to identify performance problems.

14. Frontend Security in Amazon Architecture: How Do We Protect Customers?

An e-commerce website handles sensitive activities such as login, payment, addresses and personal information.

Frontend security is therefore very important.

However, frontend security alone is not enough. The backend must also validate and protect all important operations.

For example, a shopping website may display a product price, accept a login form and send an order request. Attackers may try to manipulate these interactions, steal information or perform unwanted actions.

Let’s understand five important frontend security risks and how developers can protect users.

1. Cross-Site Scripting (XSS)

XSS occurs when an attacker manages to execute harmful scripts in another user’s browser.

Example: An application displays untrusted user input as executable HTML instead of safely displaying it as text.

Imagine a shopping website allows customers to submit product reviews. If the application handles the review content unsafely, an attacker may try to insert a malicious JavaScript script into the review.

When another customer opens that review, the script may execute in their browser.

Protection includes:

Developers should use safe framework rendering methods and avoid inserting untrusted content directly into the page as executable HTML.

2. Cross-Site Request Forgery (CSRF)

CSRF tricks an authenticated user’s browser into sending an unwanted request to a website.

For example, imagine a customer is already logged in to a shopping website. The attacker may try to make the customer’s browser send an unwanted request using the customer’s existing authenticated session.

The customer may not realise that the request has been triggered.

Protection can include:

A CSRF token is a unique value that the server expects with a protected request. It helps the server distinguish legitimate application requests from unauthorised cross-site requests.

3. Clickjacking

An attacker may attempt to hide a genuine website inside another page and trick a user into clicking something unexpected.

For example, an attacker may place an invisible or disguised website element over a visible button. The customer thinks they are clicking one thing but may actually interact with another page.

Security headers such as Content Security Policy’s frame-ancestors directive can help prevent this.

For example:

Content-Security-Policy: frame-ancestors 'self';

This example allows the page to be embedded only by pages from the same origin. A stricter policy can prevent embedding altogether:

Content-Security-Policy: frame-ancestors 'none';

The appropriate policy depends on whether the application needs to be embedded inside other websites.

4. Insecure API Requests

Sensitive information should not be sent through unencrypted connections.

HTTPS protects communication between the browser and server using TLS.

Without proper transport encryption, information travelling across a network may be exposed to interception or modification.

For example, a shopping application may exchange:

Using HTTPS helps protect data while it travels between the browser and backend server.

Important: HTTPS protects communication in transit. It does not automatically protect an application from every security vulnerability. Authentication, authorisation, secure session management and server-side validation are also necessary.

5. Trusting Frontend Prices

Suppose a product costs ₹49,999.

A malicious user might modify the displayed price using browser developer tools.

That does not mean the real product price should change.

The backend must retrieve and verify the actual price before accepting the order.

For example, the frontend might send this request:

{
  "productId": "P101",
  "quantity": 1,
  "price": 1
}

The backend must not blindly accept the submitted price of ₹1.

Instead, it should:

  1. Identify the requested product.
  2. Retrieve the trusted price from the server-side product or offer records.
  3. Check product availability.
  4. Calculate the order amount using trusted server-side data.
  5. Apply valid discounts and business rules.
  6. Continue with the order and payment process using the verified amount.

This is an important example of why frontend validation alone cannot protect an e-commerce application.

Important Development Rule: Never Trust the Browser for Important Business Decisions

Validate prices, stock, permissions, discounts and payment status on the server.

The browser is controlled by the user. Developers cannot assume that information submitted by the frontend is genuine.

For example:

InformationWhat the backend should verify
Product priceRetrieve the trusted price from server-side records
Stock quantityCheck current inventory availability
User permissionsVerify the user’s identity and access rights
DiscountValidate the coupon and applicable business rules
Payment statusVerify payment confirmation through a trusted payment process

Why Is Frontend Security Important in Amazon-Style E-commerce Applications?

A secure frontend helps protect customer interactions, but security must be implemented across the complete application.

Developers should understand:

Remember: Frontend validation improves the user experience, but backend validation protects the application’s business logic and data.

15. Complete Amazon Frontend Architecture: From Customer Click to Screen Update

Let’s connect the concepts we have learned.

Suppose a customer opens a product page and adds a laptop to the cart.

What happens behind the scenes?

The browser displays the product information, frontend components handle the customer’s interaction, an API request communicates with the backend, and the response is used to update the screen.

The following is a simplified teaching architecture. It is not a claim about Amazon’s private internal implementation.

Main Components of Frontend Architecture

ComponentResponsibility
Browser / Mobile AppDisplays the user interface
HTML / CSSStructure and design
JavaScript / TypeScriptInteraction and application logic
UI ComponentsProduct cards, cart and menus
API ClientSends requests to backend
Authentication LayerMaintains user identity
CDNDelivers cached static content
Backend APIsProcess business requests
DatabaseStores persistent information

Understanding Each Component

1. Browser / Mobile App

The browser or mobile application is the customer’s entry point.

It displays the shopping interface and allows customers to search for products, view details, select quantities and interact with the shopping cart.

2. HTML / CSS

HTML defines the structure of the webpage, while CSS controls its appearance.

For example, HTML creates a product card containing the product name, image and price. CSS controls its layout, colours, spacing and responsiveness.

3. JavaScript / TypeScript

JavaScript and TypeScript handle frontend interaction and application logic.

For example, when a customer clicks the Add to Cart button, JavaScript can handle the click event and initiate an API request.

TypeScript adds static type checking to JavaScript, helping developers identify certain errors during development.

4. UI Components

UI components are reusable parts of the application.

Examples include:

Component-based architecture makes large frontend applications easier to develop, test and maintain.

5. API Client

The API client handles communication between the frontend and backend.

It sends HTTP requests and processes responses, including JSON data and error information.

For example, when the customer adds a laptop to the cart, the API client may send a POST request containing the product ID and quantity.

6. Authentication Layer

The authentication layer helps maintain the customer’s identity across application requests.

It works with the application’s session or token mechanism so that backend services can identify the customer and check access permissions.

7. CDN

A Content Delivery Network distributes static resources such as product images, CSS files, JavaScript bundles and fonts through geographically distributed servers.

It can help reduce loading time and improve content delivery.

8. Backend APIs

Backend APIs receive requests from the frontend and process business operations.

For an Add to Cart request, the backend may verify the customer, product, seller offer, quantity and applicable business rules.

9. Database

The database stores persistent application information.

Depending on the application design, this may include customer records, product information, seller offers, cart data and order records.

The backend communicates with the database to retrieve or update information.

Overall Communication Flow

Customer
   |
   v
Website / Mobile App
   |
   v
Frontend Components
   |
   v
API Request
   |
   v
Backend Services
   |
   v
Database / Other Services
   |
   v
API Response
   |
   v
Frontend Updates Screen

This is the basic communication cycle behind many modern web applications.

Step-by-Step: What Happens When a Customer Clicks Add to Cart?

Let’s understand the complete process using a laptop as an example.

Step 1: Customer opens the product page

The browser loads the webpage structure, styles, JavaScript files and required product information.

Step 2: Frontend displays the product

The product component displays the laptop image, name, price and available actions.

Step 3: Customer clicks Add to Cart

JavaScript detects the click event and starts the cart operation.

Step 4: API client sends a request

The frontend sends a request to the backend. A simplified example is:

POST /api/cart/items
Content-Type: application/json

Request body:

{
  "productId": "P101",
  "quantity": 1
}

This is an illustrative API endpoint, not an actual Amazon endpoint.

Step 5: Backend processes the request

The backend identifies the customer, validates the product and checks the relevant business rules.

Step 6: Database or other services are accessed

The backend retrieves or updates the required cart information.

Step 7: Backend sends an API response

For example:

{
  "success": true,
  "message": "Product added to cart",
  "cartCount": 1
}

This is an illustrative response.

Step 8: Frontend updates the screen

JavaScript processes the response and updates the shopping cart count or displays a confirmation message.

The customer can now see that the product has been added to the cart.

Why Is This Architecture Important?

A modern e-commerce application is not just a collection of HTML pages. It is a combination of frontend components, browser technologies, APIs, backend services, databases and content delivery systems.

Understanding how these components communicate helps developers:

Key Learning: Every click on a modern shopping website may initiate a series of interactions between frontend components, APIs, backend services and databases. Understanding this complete flow is an important foundation for learning full-stack development and system design.

16. Practical Project for Students: Build Your Own Mini Amazon Frontend – KHCA Mini Shopping Store

Now let’s apply these concepts by building a small e-commerce frontend.

Until now, we have studied frontend architecture, HTML, CSS, JavaScript, React, APIs, authentication, CDN, performance and security.

Now it is time to apply this knowledge through a practical project.

Project Name: KHCA Mini Shopping Store

The objective is to develop a small online shopping website where customers can browse products, view product information, add products to a cart and calculate the total amount.

This project will help students understand how frontend technologies work together in a real-world e-commerce application.

Technologies Required for the Project

We will start with basic frontend technologies and gradually introduce backend development.

TechnologyPurpose
HTMLWebpage structure
CSSDesign and responsive layout
JavaScriptFunctionality
JSONSample product data
Fetch APIBackend communication (in the next development stage)

Understanding the technologies:

Features to Develop

Build the following eight features step by step.

1. Homepage with Navigation and Search

Create a homepage containing:

2. Product Listing Page

Display available products using product cards.

Each card can contain:

3. Product Detail Page

When a customer selects a product, display its detailed information.

For example, a laptop detail page can show the product name, price, available stock, description and product image.

4. Add to Cart Button

When the customer clicks Add to Cart, JavaScript should identify the selected product and add it to the shopping cart.

5. Shopping Cart with Quantity

Display the products selected by the customer.

The cart should show the product name, price, quantity and subtotal.

6. Remove Product Option

Allow customers to remove unwanted products from the shopping cart.

7. Automatic Total Price Calculation

Calculate the total amount automatically whenever the customer adds, removes or changes the quantity of a product.

For example:

ProductPriceQuantitySubtotal
Laptop₹49,9991₹49,999
Keyboard₹9992₹1,998
Wireless Mouse₹5991₹599
Total₹52,596

8. Mobile-Friendly Design

Make the website responsive so that customers can use it on desktop computers, laptops, tablets and mobile phones.

Sample Product Data

We will initially store product information in a JavaScript array.

const products = [
  {
    id: "P101",
    name: "Laptop",
    price: 49999,
    stock: 10
  },
  {
    id: "P102",
    name: "Keyboard",
    price: 999,
    stock: 25
  },
  {
    id: "P103",
    name: "Wireless Mouse",
    price: 599,
    stock: 40
  }
];

Understanding this product data:

The products variable contains an array of JavaScript objects.

Each object represents one product. JavaScript can use this data to generate product cards dynamically.

For example, instead of writing separate HTML for every product, developers can use a loop to display all products from the array.

Student Challenge

Create a product listing page using the above data.

When a customer clicks Add to Cart:

Example:

Suppose a customer clicks Add to Cart for the Laptop three times.

The cart should display:

ProductQuantityPriceSubtotal
Laptop3₹49,999₹1,49,997

The application should maintain one cart entry for the laptop and update its quantity to three.

This is an important programming concept because developers must manage application state correctly.

Suggested Project Development Stages

To make the project easier for beginners, divide the development into stages.

StageDevelopment TaskExpected Result
Stage 1Create HTML structureBasic shopping webpage
Stage 2Apply CSSAttractive product layout
Stage 3Add JavaScript product dataDynamic product listing
Stage 4Implement Add to CartWorking shopping cart
Stage 5Add quantity and remove optionsCart management
Stage 6Calculate total priceAutomatic billing
Stage 7Add responsive designMobile-friendly website
Stage 8Connect backend APIsFull-stack application

Future Development: Connect a Backend and Database

Initially, this project can work using JavaScript and sample product data.

However, a real e-commerce application needs backend services and persistent storage.

Later, connect this frontend to a FastAPI or Java Spring Boot backend and a database.

A possible learning architecture is:

KHCA Mini Shopping Store
          |
          v
    HTML / CSS / JS
          |
          v
       Fetch API
          |
          v
    Backend Application
       /          \
      v            v
   FastAPI     Spring Boot
       \          /
        v        v
        Database

This is a learning architecture. In an actual implementation, you would choose one backend framework rather than running both frameworks for the same application.

The backend can manage product information, customer accounts, cart operations, stock validation and order processing.

A database can store information permanently so that the data is not lost when the browser is closed.

What Will Students Learn From This Project?

After completing the KHCA Mini Shopping Store, students will understand:

  1. How HTML creates a webpage structure.
  2. How CSS creates responsive layouts.
  3. How JavaScript handles user interactions.
  4. How arrays and objects represent product data.
  5. How to manage shopping cart state.
  6. How to calculate quantities and totals.
  7. How frontend applications communicate with backend APIs.
  8. How a database stores application information.
  9. How to organise a small full-stack application.

This project also creates a foundation for learning React, FastAPI, Java Spring Boot, database management and system design.

Final Learning Goal: Don’t just copy an e-commerce website design. Understand how every feature works, write the code yourself, test different situations and gradually convert your frontend project into a full-stack shopping application.

This will help you understand how a real full-stack application works.

17. Test Your Knowledge – MCQs

Q1. Which technology is mainly responsible for the structure of a webpage?

A. CSS
B. HTML
C. JavaScript
D. SQL

Answer: B. HTML

Q2. Which technology makes a webpage interactive?

A. HTML
B. CSS
C. JavaScript
D. MySQL

Answer: C. JavaScript

Q3. What does DOM stand for?

A. Data Object Method
B. Document Object Model
C. Digital Output Machine
D. Document Operation Method

Answer: B. Document Object Model

Q4. What is the main purpose of an API?

A. Design images
B. Connect software systems
C. Store passwords in the browser
D. Create CSS animations

Answer: B. Connect software systems

Q5. Which HTTP method is commonly used to retrieve product information?

A. POST
B. DELETE
C. GET
D. PATCH

Answer: C. GET

Q6. What is a CDN used for?

A. Writing Java code
B. Distributing content closer to users
C. Creating database tables
D. Encrypting passwords

Answer: B. Distributing content closer to users

Q7. What is the purpose of lazy loading?

A. Load everything immediately
B. Delay loading until resources are needed
C. Delete unused files
D. Disable JavaScript

Answer: B. Delay loading until resources are needed

Q8. Which identifier is specific to Amazon’s product catalogue?

A. ASIN
B. CSS
C. HTML
D. HTTP

Answer: A. ASIN

Q9. What does HttpOnly do for a cookie?

A. Makes it public
B. Prevents JavaScript from reading it
C. Deletes it automatically
D. Encrypts the database

Answer: B. Prevents JavaScript from reading it

Q10. Where should the final product price be validated?

A. Only in HTML
B. Only in CSS
C. On the backend
D. Only in browser storage

Answer: C. On the backend

18. Interview Questions for Beginners

  1. What is the difference between frontend and backend?
  2. Explain the roles of HTML, CSS and JavaScript.
  3. What is the DOM?
  4. What is React and why are components useful?
  5. What is an API?
  6. Explain GET and POST requests.
  7. What is JSON?
  8. What is the difference between cookies and local storage?
  9. What is a CDN?
  10. Why should product prices be validated on the backend?

19. Important Technical Terms

TermSimple Meaning
FrontendUser-facing part of an application
DOMTree-like representation of a webpage
ComponentReusable UI element
APICommunication interface between systems
JSONData exchange format
HTTPWeb communication protocol
CookieSmall browser-stored data
SessionInformation representing a user’s interaction
CDNDistributed content delivery network
Lazy LoadingLoading resources when needed
Responsive DesignLayout that adapts to screen sizes
XSSAttack involving harmful scripts in webpages
CSRFAttack that tricks a browser into sending unwanted requests

20. References and Further Learning

These resources will help students understand the technologies in more depth.

  1. MDN Web Docs – Learn Web Development: https://developer.mozilla.org/en-US/docs/Learn_web_development
  2. React – Official React Learning Guide: https://react.dev/learn
  3. TypeScript – Official Documentation: https://www.typescriptlang.org/docs/
  4. OWASP – OWASP Top 10: https://owasp.org/www-project-top-ten/
  5. web.dev – Web Performance Learning: https://web.dev/learn/performance/
  6. Amazon – About Amazon: https://www.aboutamazon.com/

Conclusion of Part 2

We have now understood that a modern e-commerce frontend is much more than a collection of HTML pages.

It is a complete user interaction system involving:

But one important question remains:

When the frontend sends a request to the backend, what happens inside the server?

How does the server identify the customer, retrieve product details, check seller offers, verify stock and communicate with different databases and services?

That is where we enter the next major topic.

https://khca.info/