bastion

Understanding Web Applications

Build this skill

Identify the frontend, backend, database and web server in a web application and trace one request and response between them.

What happens in the second after you tap "Order"

Every month Mrs. Lata Gokhale opens the Tulsi Health app on her phone, picks her blood-pressure tablets, taps Order, and about a second later sees "Order confirmed". In that second her phone has sent a message to a computer in a data centre, that computer has checked her details, saved the order and sent a reply. The screen she sees is only the visible tip of a web application: a program that runs partly on her phone and mostly on computers she never sees. To understand how such programs are attacked and defended, you first need a clear picture of their parts and of how those parts talk to each other.

Websites and web applications

A website, in the simplest sense, is a set of pages that show the same information to everyone. Tulsi Health's "Our stores" page, with the addresses and opening hours of all 14 pharmacies, looks the same to every visitor. You read it, and nothing about it changes because of who you are. A web application is a website that does work for you: it lets you log in, remembers who you are, takes what you type, and responds differently to each person. Mrs. Gokhale's order history, her saved address and her uploaded prescriptions exist only for her.

The difference matters for security. A notice board outside a shop can be scribbled on, but there is nothing private behind it. A bank counter takes forms, checks identities and hands over money, so it needs far more care. Most of what people casually call websites today, from college result portals to UPI apps, are really web applications, and each one has a counter with private information kept behind it.

Website (a brochure)Same pages for everyoneYou only readNo login neededLittle private data behind itWeb application (a service)Different for each personTakes what you typeLogins and accountsStores private data

A brochure site shows; a web application takes input, remembers people and keeps private records. That extra work is what attackers aim at.

Frontend, backend and database: a restaurant in three rooms

A good way to picture a web application is a restaurant. The menu and the waiter are what you deal with directly: you read the choices, say what you want, and the waiter writes it down and carries it away. The kitchen is where the real work happens, out of sight, following the restaurant's own rules about what can be cooked and how. The store room behind the kitchen holds the rice, dal and vegetables, and the kitchen fetches from it and puts things back.

A web application has the same three rooms. The frontend is the part you see and touch: the screens, buttons and boxes of the Tulsi Health app, drawn on your phone or in your browser, the program such as Chrome or Firefox that you use to open web pages. The backend is the program running on Tulsi Health's own computers that receives requests, applies the rules (is this medicine in stock? does it need a prescription?) and decides what to do. The database is the organised store of information that the backend reads and writes: customers, addresses, orders and prescriptions.

Frontend Backend Database RESTAURANT MENU Menu and waiter you see it, you talk to it Kitchen cooks by the house rules Store room keeps the stock in order TULSI HEALTH APP Screens and buttons runs on the customer's phone Application code runs on Tulsi Health's servers Customers and orders stored for the backend to use

The menu and waiter, the kitchen and the store room match the frontend, the backend and the database. Only the first runs where the customer can touch it.

The analogy also shows who is in control of each room. You can scribble anything you like on the menu at your table, but the kitchen decides what actually gets cooked. In the same way, the frontend runs on the customer's own device, where the customer is in charge, while the backend and database run on computers that Tulsi Health controls. Keep that split in mind, because almost every rule of web security comes back to it.

Web servers: the computers that answer

A server is simply a computer whose job is to serve other computers: it waits for requests and answers them, day and night, without anyone sitting in front of it. A web server is the program on that computer that listens for messages from browsers and apps and sends back pages or data. The Tulsi Health app's backend runs on servers rented in the cloud, which means in a large data centre owned by a cloud company, rather than in a cupboard at the Kothrud head office.

Every device on the internet has an IP address, a number that works like a postal address so that messages can find it. People do not remember numbers, so we use names such as tulsihealth.in, and a lookup service turns the name into the number, much as your phone finds a friend's number when you tap their name in your contacts. When Mrs. Gokhale's app wants to reach Tulsi Health, it looks up the server's address this way and sends its message there.

How the browser and the server talk

The browser and the server talk in a simple pattern: one request, then one response. The phone asks for something ("show me the medicines page", "save this order"), and the server answers ("here is the page", "order 4521 saved"). The agreed rules for these messages are called HTTP. Its protected form, HTTPS, scrambles every message so that nobody along the way, such as a stranger on the same café Wi-Fi, can read or change it, and the padlock in a browser's address bar means HTTPS is in use.

Each request carries a few pieces. There is an address, called a URL, such as tulsihealth.in/orders. There is the kind of action wanted, usually either "fetch something for me" or "here is something to save". Sometimes there is data the user typed, such as the medicine name and quantity. The server reads the request, does the work, and sends back a response with a status (it worked, it failed, or you are not allowed) and the content.

Phone appWeb serverDatabaseRequest: place this order1Save the order2Saved as 45213Response: confirmed4

Mrs. Gokhale sees only the first and last steps. Everything in between happens on computers she never touches.

The parts of a web application

Put together, a typical web application has a handful of components, and each has a place in the restaurant picture. Some of them belong to other companies, the way a restaurant buys its vegetables from a supplier rather than growing them.

Component In the restaurant In the Tulsi Health app
Frontend: screens, buttons, forms Menu and waiter Medicine list, order form, Order button
Web server The service counter Receives every request from customers' phones
Backend: application code Kitchen and its rules Checks stock, prescription rule, delivery area
Database Store room Customers, orders, prescriptions
Outside services Vegetable supplier Payment gateway for UPI and cards, SMS for login codes

Each component is both something that does a job and something that can be attacked. The frontend can be changed by whoever holds the phone. The connection can be listened to if HTTPS is missing. The backend's rules can have gaps, and the database holds the prize: the records of 2.4 lakh customers. Security people start every review by drawing exactly this picture and asking what could go wrong at each piece and each arrow between them.

Try placing the pieces of the Tulsi Health app into the three rooms below. A quick test helps: if the customer sees or touches it, it is frontend; if it decides or applies a rule, it is backend; if it remembers something for later, it is database.

Follow your curiosity.

↑ ↓ to explore · Enter to open · Escape to close