Chapter 12: Technology Stacks — LAMP, LEMP, MEAN, MERN
12.1 What is a "stack" and why does it matter?
In short: A technology stack is the set of tools chosen to build, run and operate an application. Named stacks describe common pieces; the actual deployment can include additional roles and services.
For Mauli Dairy, compare the tools that display a catalog, handle its requests and store its product data. A label such as LAMP or MERN helps describe common tools. The rendering mode, infrastructure and operations still need decisions.
Mauli Dairy साठी catalog दाखवणे, requests हाताळणे आणि product data ठेवणे यासाठी कोणती साधने लागतात ते पहा. LAMP किंवा MERN हे सामान्य tools सांगतात. Rendering, hosting आणि इतर निर्णय वेगळे घ्यावे लागतात.
Mauli Dairy के लिए catalog दिखाने, requests संभालने और product data रखने वाले औज़ार देखें। LAMP और MERN सामान्य tools बताते हैं। Rendering, hosting और दूसरे deployment निर्णय अलग से लेने होते हैं।
A stack describes the technology choices supporting an application. Trace the user interface, HTTP listener, application runtime and data storage that are actually present. Common stack names use different abbreviations and leave some deployment components unnamed.
| Stack | Components | Language | Database type | Typical use |
|---|---|---|---|---|
| LAMP | Linux, Apache, MySQL/MariaDB, PHP | PHP | Relational (SQL) | WordPress, Moodle, classic web apps |
| LEMP | Linux, Nginx (Engine-x), MySQL/MariaDB, PHP | PHP | Relational (SQL) | PHP applications, including deployments using Laravel |
| MEAN | MongoDB, Express, Angular, Node.js | JavaScript / TypeScript | Document (NoSQL) | Application interfaces, including dashboards |
| MERN | MongoDB, Express, React, Node.js | JavaScript or TypeScript with the appropriate tooling | Document (NoSQL) | React application interfaces and Node APIs |
Ravindra Bagale's Tip
Compare the named pieces first. LAMP and LEMP identify different usual web servers, and MEAN and MERN use different front-end tools. The remaining runtime, build, hosting and data choices can still differ from project to project.
Ravindra Bagale's Tip – मराठी
नावातले घटक आधी तुलना करा. LAMP आणि LEMP मध्ये नेहमी वापरले जाणारे web server वेगळे असतात. MEAN आणि MERN मध्ये frontend tools वेगळे आहेत. प्रत्यक्ष project मध्ये build, runtime, hosting आणि data choices स्वतंत्र असू शकतात.
Ravindra Bagale's Tip – हिंदी
नाम में बताए गए हिस्सों की तुलना करें। LAMP और LEMP के आम web server अलग हैं। MEAN और MERN में frontend tools अलग हैं। किसी प्रोजेक्ट का build, runtime, hosting और data design इसके अलावा तय होता है।
Lab
For Mauli Dairy, compare two plausible designs using the required user actions, data and operating skills. Then run the private lab to see how one API contract can work with two storage adapters.
Start with what the customer needs the site to do
Mauli Dairy wants a small website that displays a product catalog. A buyer opens the catalog on a phone, chooses a pack of paneer, and wants to see the current price and whether the item can be ordered. The shop manager updates availability from a separate tool. The buyers should see new information without someone editing every page by hand. Before choosing a framework, draw this simple workflow. One part presents the information. Another decides what the buyer is allowed to see. Another stores the product data so it survives changes to a browser tab or a process restart. The work that connects those parts is the reason we name the stack.
A technology stack is the set of technologies chosen to build, run and operate a system. A named stack is shorthand for a recognizable combination, such as a web server, an application runtime and a data system, or a collection of front-end and back-end pieces. Its name can omit services that the design uses. For example, MEAN names a database, application pieces and a user interface framework, but does not specify the operating system or the internet-facing reverse proxy. A deployment might add DNS, certificates, a content delivery network, backups and monitoring. The useful question is which piece plays each role in the actual application.
Choosing a name does not automatically finish the design. Two businesses can both use PHP and a relational database. One delivers pages rendered at the server, while another returns JSON to an independent browser interface. Two teams using React can deploy differently, because their builds and rendering modes vary. A small website might have no database for its public pages at all. A static set of hours and contact information can be delivered as files until the business truly needs editable shared state. Begin with the problem, then use known combinations as examples of how teams solve that problem.
The examples in this lesson keep the same buyer-facing request while switching one storage implementation. A small Python application reads from a CSV file in one local process and SQLite in another. The two API responses match on the known product and on expected errors. A local data-specific failure makes a separate point about health. This is a deliberately small model of roles and interfaces. It does not implement MEAN, MERN, LAMP or LEMP. The following lessons can add those technologies after the boundaries make sense.
Match each role to something a request needs
The client is the program making a request. In ordinary use it might be a browser or phone app. In the local lab curl is the client, so you can inspect the request and response messages directly. A front end is the part of the application presented to or running for the user. A browser displays a web page built from HTML, styles, scripts and other media. Some sites prepare finished HTML at the server. Some give the browser code that later fetches data and renders a screen. Some use a mixture. These choices affect what gets built and where it runs.
A web server accepts and handles HTTP connections. It can serve static content, make routing decisions or forward a request to another program as a reverse proxy. Nginx and Apache can fill that role. A small application runtime can also start its own HTTP listener, as Node or Python can in a test. The word web server is often used both for the listener's software and for the host machine, which can conceal the distinction. On a real deployment, write the address and process that accepted each connection instead of relying on the word server alone.
The application runtime executes application code. PHP can execute through PHP-FPM or another supported integration. Node.js executes JavaScript outside the browser. Python can execute application code through an appropriate server setup. The back end is the part responsible for server-side behavior such as validating inputs, enforcing application access and converting data into responses. A framework supplies building blocks and conventions for that code. Express can route Node requests, for instance. A runtime runs the code, a framework helps organize the application, and a reverse proxy can direct requests toward it. Those names describe separate responsibilities even if one process fills more than one role in a demo.
A database manages stored data and provides ways to query or update it consistently. A relational database typically organizes data into tables, with rows and columns and relationships that the design can constrain. A document database such as MongoDB organizes BSON documents in collections and supports its own query and indexing model. A document can have nested fields, and that does not mean data shape or validation is optional in an application. Different storage systems support different design choices for relationships, queries and operations. A file can hold facts for a small exercise, while a database provides additional machinery when data access and guarantees become more demanding.
An operating system supplies services such as file access, processes, permissions and networking. Linux is an operating-system family. Multiple components can run as different services on one host. They can also run in containers or on independently managed infrastructure. A container packages a process with an isolated environment and expected dependencies. It does not automatically supply persistence, correct routing or a valid backup strategy. Name where each process and its data actually live. An acronym does not decide the deployment layout or how the services are kept available.
| Question | Example component | Observable result |
|---|---|---|
| Which user-facing route was chosen? | Browser interface and HTTP listener | Known address, request path and status |
| How does the request reach the code that decides what to return? | Web server and backend route | Selected handler and matching log |
| Which facts describe the selected product? | Application validation and a storage adapter | Normalized ID, price and availability fields |
| Where do those facts survive? | Persistent file or appropriate database | Independent lookup or restore evidence |
| How do the buyer and manager receive different permissions? | Application access and deployment policy | Expected allowed and denied actions |
In the diagram you draw, show the arrows as requests or data access rather than writing four boxes with no connections. A browser should not receive database credentials or reach a private store simply because it renders product data. The browser calls a known HTTP interface. The back end checks inputs and access and uses the storage connection within its authorized environment. A price is part of its public output, while the credential used to get the price stays on the server. Public build options and backend secrets are not interchangeable fields in a deployment checklist.
Trace one product request with the exact values
Consider the buyer's request for the paneer item identified by P10. The browser can send a GET to a product route such as /api/product?sku=P10. The web server or application listener accepts the request. The router chooses the product lookup because of the path and method. The app reads the query value, checks it belongs to the supported identifier shape and asks the storage adapter for that exact product. An adapter is a small interface layer that translates between one part of a program and the system it uses. For the local demo the adapter returns the same fields from a CSV row or from an SQLite row.
A successful response has HTTP 200 and a JSON object with a code, product name, price in paise and remaining stock. JSON is a representation format that supports objects, arrays, strings, numbers, Booleans and null. The application and client agree that price is an integer in paise. If the value is 6500, a display can format that as 65 rupees. The unit belongs to the contract. Its name and value type are more precise than returning a value called price with no stated interpretation. A consumer can then display the value correctly without asking whether the database used text or an integer.
An API, or application programming interface, is an agreed way for one program to request a capability or data from another. Here the interface includes the HTTP method, query rules, response codes, media type and fields. For a well-formed code that is missing, the service sends 404 and a known error object. For a missing or invalid input, it sends 400. If the application's selected store is temporarily unavailable, the same process sends 503. These differences tell the caller what kind of problem occurred. End users can see an unavailable message instead of being misled into thinking the shop intentionally removed the product.
A JSON response alone does not establish that an interface meets every restriction of a REST architecture. Treat the demonstrated interaction as a small HTTP API and explain its behavior. In a complete client, timeout handling, acceptable states and compatibility matter in addition to parsing the response. If a different backend changed the price from paise to rupees without changing the field name, both implementations could return 200 and valid JSON while breaking that contract. Changing internal storage is easier only when callers can continue using the same meaningful interface and operational requirements are met.
Write the evidence at each step before reading the lab. For a valid lookup expect a good status and a decoded object with exact values. For an input that fails validation expect a stable error without a pointless storage query. For a well-formed missing product expect a distinct not-found result. When one store is absent, expect the application to remain a running process while its catalog operation fails. A direct application liveness probe and a real business request answer different questions. That insight helps when debugging a larger stack, where a load balancer can show a green target even while a critical operation is broken if its check does not cover that dependency.
Compare the named families without treating them as deployment rules
Learn LAMP and LEMP by tracing one ordinary request. In a common LAMP installation, Linux hosts Apache, a PHP runtime and a relational data system such as MySQL or MariaDB. The Apache process can serve public assets and route dynamic requests to the PHP configuration appropriate to that installation. A PHP application might check a product code, query the relational store and generate HTML or JSON. LEMP uses Nginx as its usual front web server and commonly routes execution work through FastCGI to PHP-FPM. The front server differences matter to routing and configuration. They do not dictate whether the business uses a browser-side interface or one server-rendered page.
In MEAN, MongoDB provides a document data system, Express helps the application handle its HTTP routes, Angular helps build the user interface, and Node.js runs server-side JavaScript. In MERN, React is used for the user interface in that familiar combination. Angular and React can be part of more than one rendering and deployment style. React's documentation recommends considering a framework for a new application, while a controlled learning example can build an explicitly client-side version. Angular supports client, server and pre-rendered strategies depending on configuration. Distribute the actual build artifacts and any required runtime processes. The acronym cannot establish that every route is a set of files ready to copy to Nginx.
Changing from one family to another often changes more than its best-known letter. Two PHP deployments can use different module and process arrangements. React and Angular can bring different build and routing conventions, and a service can have additional workers or a managed relational or document store. TypeScript can be used in modern front-end or Node projects even when the popular acronym does not mention it. Choose supported software versions, and inspect the application build and runtime instructions. For this lesson the comparisons describe common roles, not assumptions about every team using a particular stack.
| Name | Named components | What to find in a real project |
|---|---|---|
| LAMP | Linux, Apache, MySQL or MariaDB in common usage, PHP in this course | The active Apache site, PHP handler, actual schema and placement of the database |
| LEMP | Linux, Nginx, MySQL or MariaDB in common usage, PHP in this course | The selected Nginx route, FastCGI configuration and PHP-FPM pool |
| MEAN | MongoDB, Express, Angular, Node.js | The actual Angular build/render modes, backend API, database model and front-door deployment |
| MERN | MongoDB, Express, React, Node.js | The React tooling and runtime choices, API contract and operational environment |
For the dairy, a deliberately simple first requirement could be a public catalog edited once daily and a private inventory tool. An existing PHP team might confidently operate a relational store and choose to render product details at the server. A team already running an Express API and a browser app could use their existing deployment skills. Neither label alone makes a site faster or easier. Measure how it serves actual customers, supports required changes, protects the private paths and can be recovered. Compare the responsibilities of a particular project rather than using “enterprise” and “startup” as technical arguments.
Run two local implementations of one catalog contract
Use Bash, curl and Python 3 with its built-in HTTP server, CSV and SQLite modules. The exercise runs as a regular user inside a disposable shell. Its two child processes listen on local ports 18902 and 18903 and its files stay in a generated directory. Choose two unused high ports and update all corresponding references if either is occupied. You do not need an AWS account, database server installation, browser framework or public access. The lab makes only a read-only catalog API. It intentionally changes the availability of one synthetic file after a successful test.
The first block writes the same two products to a CSV file and an SQLite database. A comma-separated-values file stores tabular records as text. SQLite keeps structured data in an embedded database file. The table defines an identifier and required fields with nonnegative price and stock checks. The program reads the same logical values from both. In a full data design you would choose constraints, query patterns and transactions for actual business operations. Here two known rows suffice to test the contract. The temporary copies are generated from a common list to remove data differences from the initial comparison.
if [ "$(id -u)" -eq 0 ]; then
printf 'Use a regular practice account.\n' >&2
exit 1
fi
stack_lab=$(mktemp -d /tmp/rb-stack-contract.XXXXXX) || exit 1
csv_pid=
sql_pid=
stack_cleanup() {
local child
for child in "$csv_pid" "$sql_pid"; do
if [ -n "$child" ] && kill -0 "$child" 2>/dev/null; then
kill "$child"
wait "$child" 2>/dev/null || :
fi
done
case "$stack_lab" in
/tmp/rb-stack-contract.??????) rm -r -- "$stack_lab" ;;
esac
}
trap stack_cleanup EXIT
python3 - "$stack_lab" <<'PY'
from contextlib import closing
import csv
from pathlib import Path
import socket
import sqlite3
import sys
base = Path(sys.argv[1])
for port in (18902, 18903):
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as candidate:
candidate.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
candidate.bind(("127.0.0.1", port))
products = [("P10", "Paneer pack", 6500, 12), ("M20", "Milk packet", 3300, 0)]
with (base / "products.csv").open("w", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow(("sku", "name", "price_paise", "stock"))
writer.writerows(products)
with closing(sqlite3.connect(base / "products.db")) as conn:
conn.execute("""
CREATE TABLE products (
sku TEXT PRIMARY KEY NOT NULL,
name TEXT NOT NULL,
price_paise INTEGER NOT NULL CHECK (price_paise >= 0),
stock INTEGER NOT NULL CHECK (stock >= 0)
)
""")
conn.executemany("INSERT INTO products VALUES (?, ?, ?, ?)", products)
conn.commit()
PY
test "$?" -eq 0 || exit 1
The socket check briefly tries the intended bind and then releases it. If another process already owns either endpoint, stop the setup and pick a different unused pair. The data setup uses a fixed table and attaches each value to a placeholder. This is a parameterized query, where data are given to the driver separately from the instruction to execute. The same principle is used when finding a requested product. The CSV adapter converts numeric fields into integers because the file format stores text. Without that conversion, the two data sources could accidentally give callers incompatible field types.
Write the application once and pass its storage choice when starting each instance. The application has the same validation and response rules under either option. It opens SQLite in read-only mode so a missing database will not silently create an empty file. The exception handling returns a defined unavailable response instead of exposing an internal error to the caller. The process-only liveness path does not query the store. The exact identifier lookup performs that part of the work. Keep the dependency difference visible when diagnosing the lab.
cat > "$stack_lab/catalog.py" <<'PY'
from contextlib import closing
import csv
from http.server import BaseHTTPRequestHandler, HTTPServer
import json
from pathlib import Path
import re
import sqlite3
import sys
from urllib.parse import parse_qs, urlsplit
base = Path(__file__).parent
adapter, port = sys.argv[1], int(sys.argv[2])
if adapter not in {"csv", "sqlite"}:
raise SystemExit("Choose csv or sqlite")
def fetch_product(code):
if adapter == "csv":
with (base / "products.csv").open(newline="", encoding="utf-8") as file:
return next((
(row["sku"], row["name"], int(row["price_paise"]), int(row["stock"]))
for row in csv.DictReader(file) if row["sku"] == code
), None)
uri = (base / "products.db").resolve().as_uri() + "?mode=ro"
with closing(sqlite3.connect(uri, uri=True)) as conn:
return conn.execute(
"SELECT sku, name, price_paise, stock FROM products WHERE sku = ?", (code,)
).fetchone()
class Catalog(BaseHTTPRequestHandler):
def send_json(self, status, result):
body = (json.dumps(result) + "\n").encode("utf-8")
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(body)))
self.end_headers()
self.wfile.write(body)
def do_GET(self):
route = urlsplit(self.path)
if route.path == "/health/live":
self.send_json(200, {"status": "running"})
return
if route.path != "/api/product":
self.send_json(404, {"error": "route-not-found"})
return
values = parse_qs(route.query, keep_blank_values=True).get("sku", [])
if len(values) != 1 or re.fullmatch(r"[A-Z][0-9]{2}", values[0]) is None:
self.send_json(400, {"error": "one-valid-sku-required"})
return
try:
row = fetch_product(values[0])
except (OSError, ValueError, KeyError, csv.Error, sqlite3.Error) as exc:
print(f"{adapter} storage lookup failed: {type(exc).__name__}", flush=True)
self.send_json(503, {"error": "catalog-unavailable"})
return
if row is None:
self.send_json(404, {"error": "product-not-found"})
return
self.send_json(200, dict(zip(("sku", "name", "price_paise", "stock"), row)))
def log_message(self, fmt, *args):
return
with HTTPServer(("127.0.0.1", port), Catalog) as server:
server.serve_forever()
PY
python3 "$stack_lab/catalog.py" csv 18902 > "$stack_lab/csv.log" 2>&1 &
csv_pid=$!
python3 "$stack_lab/catalog.py" sqlite 18903 > "$stack_lab/sqlite.log" 2>&1 &
sql_pid=$!
wait_local() {
local child=$1 local_port=$2 body=''
for attempt in 1 2 3 4 5 6 7 8 9 10; do
if ! kill -0 "$child" 2>/dev/null; then return 1; fi
body=$(curl --noproxy '*' --max-time 1 -fsS \
"http://127.0.0.1:$local_port/health/live" 2>/dev/null) || :
if [ "$body" = '{"status": "running"}' ]; then return 0; fi
sleep 0.2
done
return 1
}
if ! wait_local "$csv_pid" 18902 || ! wait_local "$sql_pid" 18903; then
cat "$stack_lab/csv.log" "$stack_lab/sqlite.log" >&2
exit 1
fi
The miniature server fulfills both its runtime and its web listener role. It is useful for a known private example and is not a production web server setup. Each process uses the same source file. Its first invocation argument chooses which adapter dispatch executes. The second sets the loopback port. The wait checks prove each child is running and positively answers its separate local route. Those checks leave the product store untested. Next send an actual query and compare both success and expected negative formats.
Compare results, then break only one storage dependency
Use a helper that records status separately from the response. Save each response under a filename keyed to its local port so comparisons do not overwrite the first body. The helper also checks that an expected JSON media type arrived. HTTP status and content type describe different aspects of the contract. For the successful response, compare the expected keys and values after parsing. For an error compare the documented object where useful. An empty product stock in a successful result is a real data value. It is different from a missing product or an unavailable store.
request_catalog() {
local local_port=$1 route=$2 expect=$3 status
status=$(curl --noproxy '*' --max-time 5 -sS \
-o "$stack_lab/reply-$local_port.json" -D "$stack_lab/headers-$local_port" \
-w '%{http_code}' "http://127.0.0.1:$local_port$route") || return 1
printf '%s %s HTTP %s\n' "$local_port" "$route" "$status"
cat "$stack_lab/reply-$local_port.json" || return 1
[ "$status" = "$expect" ] &&
grep -Eiq '^Content-Type: application/json' "$stack_lab/headers-$local_port"
}
compare_contract() {
local path=$1 expected=$2
request_catalog 18902 "$path" "$expected" &&
request_catalog 18903 "$path" "$expected" &&
cmp "$stack_lab/reply-18902.json" "$stack_lab/reply-18903.json"
}
compare_contract '/api/product?sku=P10' 200 || exit 1
python3 - "$stack_lab/reply-18903.json" <<'PY'
import json
from pathlib import Path
import sys
result = json.loads(Path(sys.argv[1]).read_text())
assert result == {"sku": "P10", "name": "Paneer pack", "price_paise": 6500, "stock": 12}
print("Verified the product code, price unit and stock.")
PY
test "$?" -eq 0 || exit 1
compare_contract '/api/product?sku=M20' 200 || exit 1
compare_contract '/api/product?sku=Z99' 404 || exit 1
compare_contract '/api/product?sku=bad' 400 || exit 1
compare_contract '/api/product?sku=P10&sku=M20' 400 || exit 1
Each of these paired responses should agree. The local site identifies P10 as paneer pack with 6500 paise and stock 12. M20 is in the store but has quantity zero. It is appropriate to return a product and show it as unavailable to order rather than return 404 just because stock is zero. The code Z99 follows the allowed format but is absent. This is different from an invalid value or an ambiguous repeated query parameter. A client can handle those outcomes intentionally. In the controlled exercise the raw JSON bytes match as well because one server implementation writes both responses. A robust independent app compatibility check should normally compare parsed fields and meanings rather than require arbitrary field ordering or spaces.
Make the SQLite store unavailable for just one implementation. The move operates only inside the generated directory and saves the original file there. The next SQLite lookup should fail its read-only open and return 503 while its liveness route still returns 200. The CSV site should continue serving the same product. This is a model of a dependency failure. It is not a suggestion to rename real database files. The result shows why measuring a process-only signal cannot prove the real catalog is ready. Restore the synthetic file before checking both again.
mv "$stack_lab/products.db" "$stack_lab/held-products.db" || exit 1
request_catalog 18903 /health/live 200 || exit 1
request_catalog 18903 '/api/product?sku=P10' 503 || exit 1
grep -Fq 'catalog-unavailable' "$stack_lab/reply-18903.json" || exit 1
request_catalog 18902 '/api/product?sku=P10' 200 || exit 1
test ! -e "$stack_lab/products.db" || exit 1
grep -F 'sqlite storage lookup failed' "$stack_lab/sqlite.log"
mv "$stack_lab/held-products.db" "$stack_lab/products.db" || exit 1
compare_contract '/api/product?sku=P10' 200 || exit 1
Verify the stored row independently of the HTTP request. The last check opens the restored database with read-only access and selects the intended record. The CSV and SQLite server probes support compatibility, while the direct persistence query confirms the input facts used by one adapter. If a different first or second body appeared, inspect its own adapter and stored data before changing the client. The fixture does not simulate writing inventory concurrently, migrating real records, or operating a managed database. Those designs require their own checks.
python3 - "$stack_lab/products.db" <<'PY'
from contextlib import closing
from pathlib import Path
import sqlite3
import sys
uri = Path(sys.argv[1]).resolve().as_uri() + "?mode=ro"
with closing(sqlite3.connect(uri, uri=True)) as conn:
row = conn.execute(
"SELECT sku, name, price_paise, stock FROM products WHERE sku = ?", ("P10",)
).fetchone()
assert row == ("P10", "Paneer pack", 6500, 12)
print(row)
PY
test "$?" -eq 0 || exit 1
Save a few lines of output if you are completing a class report. Keep successful and expected error responses distinct, including the liveness check during the data failure. Then stop the two tracked private children and remove their generated directory. If you exit earlier, the registered cleanup procedure still handles the port owners it started. No system or cloud service should be left behind by this local task.
stack_cleanup
trap - EXIT
test ! -e "$stack_lab" && printf 'Local stack contract lab removed.\n'
Choose a design from its requirements and operating costs
Begin with the particular workflow. A simple brochure might be edited by preparing a new set of HTML and assets. A public catalog with changes managed at several shops may need persistent shared state and an editing system. A buyer placing an order introduces concurrency and stronger consistency requirements, because two buyers can try to purchase the last unit. A reporting tool may need efficient queries over past transactions. The stack should support these operations reliably. The CSV demo was chosen to teach the interface, not to recommend editing a shared CSV file as a shop's full order database.
Ask how the business data fit operations. If the dairy needs actual orders, buyers, stock reservations and audit history, model how those facts relate and what must change together. Consider whether the database can enforce key uniqueness, update rules and transaction boundaries you need. If a product is typically retrieved with nested attributes as a unit, a document model can be a candidate. Relational systems can also represent structured or nested-adjacent data, and MongoDB supports more than one relationship pattern and can support transactions in applicable deployments. A choice should be tied to concrete query, update and failure needs rather than a claim that one model is automatically faster.
Then consider how the application reaches users. A shop page may benefit from prepared HTML and public caching. An interactive stock dashboard can fetch data and update part of the screen without requesting an entire new page. A product category page could be prepared at build time or assembled on demand. The choice affects deployment, observable loading and how URLs are handled. You still need to verify that direct links, missing assets and API routes address the right component. An ever-present success body from the front-end shell can conceal a missing application route. Inspect response type and actual values rather than assuming a familiar framework name establishes the correct behavior.
Compare operational responsibilities. Someone has to update the runtime and dependencies, configure TLS and access, restore data from backup and observe failures. A managed data service can shift some of the infrastructure work while retaining responsibilities such as appropriate access, monitoring and recovery choices. A new framework can be attractive yet add skills the team must learn to manage during a real incident. List the capabilities the organization already operates, launch and maintenance effort, and the people who will respond to a problem. A stack can be a reasonable choice for the same project in one team and a poor choice in another.
For a compact written comparison, make two honest proposals. One could use the team's PHP and relational experience to ship a catalog with an approved server-rendered route. Another could use an existing API and browser stack if its owners can support build artifacts and private database operations. Discuss one strength, one cost, one possible failure and the recovery plan for each. Give concrete technical reasons such as reuse of known hosting and the need for a consistent order update. Avoid choosing from an acronym solely because it sounds newer or appears near an unrelated headline.
Decide what runs in the browser and what stays on the server
In a real version of the fixture, the page could call its local API at the relative path /api/product?sku=P10. A front service can deliver the page and direct that API path to the backend under the same browser origin. An origin for ordinary HTTP URLs is identified by its scheme, hostname and port. If the UI instead uses another hostname or port for its API, the browser sees a different origin. The application owners then need to decide whether that design should allow the UI to read that response and how the backend will recognize properly authorized users. The two choices are distinct.
Cross-Origin Resource Sharing, or CORS, is a browser protocol that governs sharing responses across origins and the preflight approval phase for some requests. It does not give a caller a login identity and does not make an exposed server private. Some requests can reach an API without a browser letting the calling script read the result. Command-line tools also do not enforce the browser's CORS restrictions the same way. Use the required user and operation-level access checks at the backend. Verify intended cross-origin calls in a real browser for a deployment that supports them, after confirming the server's actual route and data contract.
Plan a compatible configuration for development and production. A browser bundle can include a public relative API base or a deliberately published service URL. Variables that a front-end build injects into files sent to the client are visible as part of those files. Such a variable must not contain a database credential or private application key. Keep the backend's approved environment or secret mechanism separate. If a trainee says they saved the credentials in a front-end environment file, ask whether any of its values were compiled into the browser bundle before making a statement about privacy. The local lab can teach what the API returns while its private file paths stay within the application process.
Identify which layer failed before replacing it
Suppose a browser opens the site's static layout but its product card stays empty. The public page could have loaded from a web server or cache while its API request failed. Look at the selected API URL, status, type and returned body. An HTML shell instead of JSON suggests the route may have gone to a front-end fallback rather than its intended handler. A missing or malformed product code can trigger the application validation branch. A valid request yielding a well-formed temporary-unavailable error points at an acknowledged service problem. Check the application and its data dependency with the same request rather than rebuilding the front end first.
The failure fixture shows a listener answering alongside an unusable data path. Liveness means the process can answer a simple request. Readiness means it is considered able to accept relevant work under the deployment's test. Its exact meaning depends on the check you define. A readiness test for a critical product read could probe a safe representative storage operation. A shallow process signal may instead be appropriate for deciding whether the process needs to be restarted. These checks can legitimately disagree during reconnect, startup or dependency failure. Decide which one should control traffic and which one should trigger recovery. A health route that deliberately avoids all dependencies cannot certify a successful catalog.
In a deployment behind a proxy, compare the selected boundary. A user can load HTML from a static route and then hit a gateway when the browser requests product data. If a proxy cannot connect to its intended service, the user may receive an edge-generated error and the app may have no matching request record. If the app accepted the request and could not open storage, its own log should carry the failure. The symptoms can look similar in the browser. Use the selected route and logs to identify whether the failing link is browser-to-edge, edge-to-app, or app-to-store. Keep private logs and credential details within the approved environment.
Distinguish a schema or contract change from a connection problem. An operator could accidentally change the stock field from number zero to string zero. A browser that simply parses the result into an object may not catch the difference immediately. A client comparing quantities could behave unexpectedly. Test expected types and values in addition to status and syntax. If the response contract needs a new field or unit, decide what existing callers can handle and plan a compatible change or a deliberate interface version. A storage swap that leaves all documented field meanings unchanged is a narrower change than a redesign of the API.
| Observation | Likely boundary to inspect | Small comparison |
|---|---|---|
| Page shell loads; API returns HTML | Selection between static files and application routes | Verify path, type and expected JSON at the correct app endpoint |
| Product API returns a valid missing error | Requested identifier and repository lookup | Check a known available code and the exact failed value |
| Process responds; product reports unavailable | Store dependency needed by the operation | Read the exact app error and test access to the intended store |
| JSON parses but price looks wrong | Contract units, data type or stored business value | Compare typed response fields to the agreed unit and independent lookup |
Explain the trade-offs with a worked exercise
Use the two preserved product records to sketch a customer response. For P10, write how a displayed price of 65 rupees came from a stored value of 6500 paise. Show how a 200 with stock zero for M20 differs in the interface from a 404 for Z99. For a duplicate SKU query, show a validation message rather than quietly using whichever code appears first. That is a caller-facing design choice established by the contract. Write which component made each decision and what data it used. Do not include the storage filename in any public error response.
Then propose a new public feature in two steps. The owner wants to display a category or grouping for each product. Decide whether existing clients need it or can safely ignore the additional field. Write the new response example and both adapter changes. Seed the same value into each source and test the original fields as well as the added one. Only after confirming that neither old caller loses its expected meaning should you describe the change as compatible. Optional fields, numeric units and known error semantics form as much of the contract as the URL string.
Finally give a two-minute explanation of an ordering workflow the fixture does not implement. Name the buyer view, order validation, stock check, durable write and the result returned to the caller. Explain a race in which two buyers both see one left. Discuss why a carefully designed database operation or transaction is needed to check and reserve stock consistently. A transaction groups work so the data system can apply it with the guarantees offered by that database and selected operation. Reading a CSV file from two processes gives no such guarantee by itself. The missing feature illustrates how real requirements influence the storage choice.
Complete your comparison with the actual operating notes. Which component needs updates? Where are its private credentials kept? What must be backed up and restored? Which team knows how to interpret failures? Put practical answers next to each proposal rather than picking one named stack as universally best. One clear recommendation connected to your scenario is stronger than a long list of framework names. Mention one deliberately untested assumption, such as multi-user writes or actual public TLS, so another reviewer can identify the next validation task.
Interview questions, quiz and revision cards
Does the stack name describe every deployed service?
No. It names a recognizable set of components. MEAN and MERN do not name the operating system, proxy or cloud services. Even familiar components can share a process or operate on separate hosts. Draw the actual request and deployment roles.
Why could the product API keep the same meaning when storage changes?
The application maps both sources into the same validated response contract, including data type, price unit and errors. A storage adapter hides internal representation from the callers. Changes to the externally visible contract still require compatibility checks.
Is a browser supposed to connect to the database directly for a normal private-backed storefront?
The backend normally enforces the intended access and uses its approved store connection. The browser makes a request to the supported API. Do not put database secrets in public build settings or response data.
Why can a healthy process still be unable to serve catalog data?
A shallow liveness check can succeed without accessing storage. The catalog route may need an available file or database. Inspect both and choose health checks that correspond to the service behavior you intend them to measure.
Quick quiz
The query for M20 returns 200 and stock zero. Which conclusion fits?
- The product exists but is currently out of stock
- The database file is missing
- The identifier failed validation
Check the first answer
A. Zero is a legitimate data value for a found product. The lab also demonstrates distinct 404, 400 and 503 cases.
A MERN app is deployed with a reverse proxy and a private network. Is the proxy implied by the acronym?
- Yes, the last letter always means Nginx
- No, the name identifies MongoDB, Express, React and Node.js, and the front-door deployment is a separate choice
- Yes, every MERN app runs all services on the same host
Check the second answer
B. Describe the actual listeners and boundaries in your deployment design.
Both adapters produce valid JSON and a 200, but one returns a price in rupees under the price_paise field. What failed?
- Both listeners necessarily failed to connect
- The view was guaranteed correct because JSON parsed
- The stated unit in the response contract was violated
Check the third answer
C. API compatibility needs semantics as well as syntax. Compare typed fields and exact expected values.
Map the work
Identify the client, HTTP listener, application decision and data system. A named stack is a shorthand for common pieces.
Check the contract
Status, format, required fields, value types and units all affect how a caller can use the response.
Separate liveness and readiness
The process can answer while a required dependency is unavailable. Test the critical operation separately.
Choose for the job
Compare user workflow, query and consistency needs, team operation and recovery costs before choosing a stack.
Primary references
- IETF HTTP requests, media and status semantics
- Python HTTP server for controlled examples
- Python CSV adapters and record handling
- Python SQLite connections and parameterized queries
- MongoDB documents, collections and validation
- Express API routing
- React application build choices
- Angular client, server and hybrid rendering
- WHATWG Fetch CORS protocol
- Vite client-exposed build variables
- Nginx FastCGI routing
Quick revision cards
Revise this lesson in two minutes. Save the cards on your phone or download them as PNG files. The QR code on each card opens its lesson.

More cards: Ravi Sir's Cards.