
🧠 Client–Server Architecture
🔹 What it is:
Client–Server Architecture is a design model where two entities communicate —
- Client: the user or application that requests data or services.
- Server (Backend): the system that processes the request, performs necessary operations, and sends back the response.
⚙️ How it works (Flow):
- Client → Backend:
- The client sends a request (req) to the backend.
- Example: A browser requesting user data from a web server.
- Backend → Database:
- The backend receives the request and may need data.
- It then acts as a client itself to another service — typically a database.
- Sends a request (req) to the database.
- Database → Backend:
- The database processes the query and sends back a response (res) containing the data.
- Backend → Client:
- The backend processes the data, formats it (e.g., JSON), and sends the response (res) to the client.
🔁 Key Points:
- The client never interacts directly with the database — all communication goes through the backend.
- The backend acts both as:
- a server for the client, and
- a client for other services (like databases, APIs, etc.).
- This structure improves security, scalability, and separation of concerns.
💡 Example: