>_
EngineeringNotes
← Back to All Backend Concepts
Concept 01

A High Level Understanding

What is a Backend, why do we need it, and why not put everything on the frontend?

01

What is Backend?

Backend is a Centralized Server application running on a computer that listens for request via HTTP, WebSockets, or gRPC from clients (like browsers or app).

Its primary role is to serve content (like static files or JSON data) and accept data from client, managing all necessary logic and interactions in a secure environment rather than on user device.

Real Architecture Flow

💻
Client
React / App
🌐
DNS Server
domain → IP
Enterprise Backend Environment
🛡️
AWS FirewallFilters malicious requests (DDoS, WAF)
☁️ EC2 Instance (Linux Machine)
NginxReverse Proxy
Port 80/443
Node HTTPApplication Server
localhost:3001
Common Misconception

What beginners think it looks like

💻
Client
🖥️
Server

Too simplified! This model ignores DNS resolutions, Firewalls, Load Balancers, and Reverse Proxies.

02

Why Backend?

1) Data Persistence & Management

Backend components are crucial for saving data securely and reliably to a database.

2) Centralization

Provides a central hub to manage user data, application state, and business logic coherently.

Frontend
→ Receives HTML, CSS and JS from server and runs it on the client machine (browser).
Backend
→ Runs on the centralized Server itself.
03

Why Not Run Everything on Frontend?

1) Security

Browsers are sandbox environments. They cannot access the file system or sensitive environment variables.

2) CORS Restriction

Browsers powerfully block requests to different domains for critical security reasons.

3) Database Access

Only the backend can efficiently use native database drivers and stably maintain connection pools.

4) Computing Power

Backend can be scaled infinitely with more CPU/RAM, whereas frontend performance depends entirely on the user's device.

The Frontend Vulnerability

Frontend is an open book. Anyone can right-click and open "Inspect" and see every single line of code you've written.

  • API KeyIf the secure key is in frontend, a user can easily steal it and exploit it to cost you money or data.
  • Business LogicIf discount calculation is on the frontend, a savvy user can change it in their browser before hitting "Buy".
  • ConsistencyThe Centralized Backend ensures that two people don't try to magically buy the very last seat on a flight at the exact same millisecond.