Understanding How the Web Works

Understanding How the Web Works

Dipesh Chaulagain
Dipesh Chaulagain

A. How does web work ?

1. Fundamentals of web

The functioning of the web involves a complex interplay of various technologies and protocols that work together to enable the transfer of information between clients (such as web browsers) and servers. Here’s a simplified overview of how the web works:

  1. Client-Server Model:
    • The web operates on a client-server model, where clients (typically web browsers) request resources from servers, and servers respond to those requests.
    • Clients initiate requests for web pages, files, or data, and servers process those requests and send back the requested resources.
  2. Uniform Resource Locators (URLs):
    • Web addresses, known as Uniform Resource Locators (URLs), are used to specify the location of resources on the web.
    • A URL typically consists of several components, including the protocol (e.g., HTTP or HTTPS), domain name, path, and optional query parameters.
  3. HTTP Protocol:
    • The Hypertext Transfer Protocol (HTTP) is the foundation of data communication on the web. It defines how messages are formatted and transmitted between clients and servers.
    • HTTP operates over a connectionless TCP/IP network, with clients sending requests to servers and servers responding with status codes and data.
  4. DNS Resolution:
    • When a user enters a URL in a web browser, the browser needs to resolve the domain name to an IP address using the Domain Name System (DNS).
    • DNS translates human-readable domain names (e.g., www.example.com) into numerical IP addresses (e.g., 192.0.2.1) that computers use to communicate over the Internet.
  5. HTTP Request-Response Cycle:
    • When a user clicks on a link or enters a URL in a browser, the browser sends an HTTP request to the server specified in the URL.
    • The HTTP request includes information such as the request method (e.g., GET, POST), headers, and optional request body (for methods like POST).
    • The server processes the request, generates an appropriate response, and sends it back to the client.
    • The HTTP response includes a status code (indicating the success or failure of the request), headers, and the requested content (e.g., HTML, CSS, JavaScript).
  6. Content Rendering:
    • Once the client receives the response from the server, it processes the content and renders it in the browser window.
    • HTML content is parsed and rendered into a structured document (DOM), CSS styles are applied to the document, and JavaScript code is executed to add interactivity and dynamic behavior.
  7. Stateless Communication:
    • HTTP is a stateless protocol, meaning that each request from a client to a server is independent and unrelated to previous requests.
    • To maintain state between requests (e.g., user sessions, shopping carts), web applications often use techniques like cookies, sessions, or client-side storage.
  8. Secure Communication (HTTPS):
    • To ensure the security and privacy of data transmitted over the web, the HTTPS protocol (HTTP Secure) is used, which encrypts communication between clients and servers using Transport Layer Security (TLS) or its predecessor, Secure Sockets Layer (SSL).

Overall, the web operates through a combination of protocols, technologies, and standards that enable seamless communication and interaction between clients and servers, facilitating the exchange of information and services across the Internet.

2. 3 tier architecture

The 3-tier architecture is a software architecture pattern used in the development of applications, particularly web-based applications, to separate functionality into three distinct layers or tiers. Each tier serves a specific purpose and encapsulates different aspects of the application’s functionality. The three tiers typically consist of the presentation tier, the application tier (also known as the business logic or processing tier), and the data tier (also known as the data access tier). Here’s an overview of each tier:

  1. Presentation Tier:
    • The presentation tier, also known as the client tier, is the topmost layer of the architecture that interacts directly with users. It is responsible for presenting information to users and collecting user input.
    • In web applications, the presentation tier often consists of the user interface (UI) components, such as web pages, forms, and user controls, rendered in a web browser.
    • The presentation tier communicates with the application tier to retrieve data and perform business logic operations but does not directly interact with the data storage.
  2. Application Tier:
    • The application tier, also known as the business logic or processing tier, is the middle layer of the architecture that contains the core logic and functionality of the application.
    • This tier is responsible for implementing the business rules, processing user requests, and orchestrating interactions between different components of the application.
    • It encapsulates the application’s business logic, workflow management, and application services, such as authentication, authorization, and validation.
    • The application tier communicates with both the presentation tier (for handling user requests and providing responses) and the data tier (for accessing and manipulating data).
  3. Data Tier:
    • The data tier, also known as the data access tier, is the bottom layer of the architecture that manages data storage and retrieval.
    • It is responsible for storing and retrieving data from persistent storage systems, such as databases, file systems, or external APIs.
    • The data tier abstracts the underlying data storage mechanisms and provides a standardized interface for accessing and manipulating data.
    • It ensures data integrity, security, and scalability by implementing features such as transactions, indexing, and data validation.

Key Characteristics of 3-Tier Architecture:

  1. Modularity and Scalability:
    • The 3-tier architecture promotes modularity by separating concerns into distinct layers, making it easier to manage and scale the application.
    • Each tier can be developed, deployed, and scaled independently, allowing for better maintainability and scalability of the application.
  2. Flexibility and Reusability:
    • The separation of concerns into presentation, application, and data tiers enables components to be reused across different parts of the application or even in other applications.
    • It allows for flexibility in technology choices and implementation details within each tier, as long as they adhere to the defined interfaces and contracts.
  3. Security and Maintainability:
    • By encapsulating business logic and data access functionality into separate tiers, the architecture enhances security by enforcing access controls and reducing the risk of data exposure.
    • It also improves maintainability by facilitating code organization, debugging, and testing, as changes in one tier are less likely to impact other tiers.

The 3-tier architecture provides a structured and scalable approach to designing and developing applications, facilitating separation of concerns, modularity, and maintainability, while also enabling flexibility and reusability of components.