What is a Backend, why do we need it, and why not put everything on the frontend?
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.
Too simplified! This model ignores DNS resolutions, Firewalls, Load Balancers, and Reverse Proxies.
Backend components are crucial for saving data securely and reliably to a database.
Provides a central hub to manage user data, application state, and business logic coherently.
Browsers are sandbox environments. They cannot access the file system safely or hide sensitive environment variables from users.
Browsers powerfully block requests to different domains for critical security reasons, managed by Same-Origin Policy.
Only the backend can efficiently use native database drivers and stably maintain high-performance connection pools.
Backend can be scaled infinitely with more CPU/RAM, whereas frontend performance depends entirely on the user's device hardware.
"Frontend is an open book. Anyone can right-click and open 'Inspect' and see every single line of code you've written."