Client-server Model
Learning objectives
- Knows what web application architecture means.
- Knows what the client-server model is.
We've seen concepts such as service and views in the code, used a database, and written web applications. We haven't really discussed web application architecture -- that is -- the way how our applications are organized and how different parts of our applications interact with each others. Understanding basic web application architectures helps in designing web applications as well as in discussing and reasoning about the applications.
The first architecture that we visit is the Client-server model (or client-server architecture), which is at the core of all web applications. In client-server model, the server is responsible for hosting and providing resources and services to one or more clients.

In practice, the client-server model is a distributed model where clients communicate with servers through a computer network such as the internet. When considering from the application point of view, clients are typically dependent on the servers -- clients ask for services or resources from servers. On the other hand, while servers share their resources, clients do not.
The HTTP protocol on which all of our web applications build is based on the client-server model. Each HTTP request is sent to a server, which processes the request and then provides a response. The request could ask for a resource such as a static image or a page, or, the request could ask for dynamically generated content that the server then would create based on the request.

The exact content that is being requested is, however, abstracted away in the HTTP protocol. When working with HTTP, each request is made to a path with a request method. The server then receives the request and determines how to respond based on the path and the request method -- the path and the request method often, if not always, map to specific functionality on the server.
While the previous example outlined the basic HTTP request where a browser is the client and the web server is the server, the client-server model is present also elsewhere. When working with web applications, for example, the server can also act as a client: when the web server connects to a database server, asking for resources, the web server is a client, and the database server is the server.