Client–Server Architecture
REST APIs commonly follow a client-server architecture. The client initiates requests, while the server processes requests and returns representations of resources.
The client might be a browser, mobile application, CLI, another backend service, or an IoT device. The server owns application logic and data.
Separating client and server allows them to evolve independently. A React application can consume an API implemented by Node.js, Java, Go, Python, or another technology without knowing the implementation details.
Responsibilities
Client:
Requests resources and operationsThe client decides what it needs and sends HTTP requests.
Server:
Processes requestsThe server validates input, executes business logic, and creates responses.
Database:
Persists application stateThe database is an implementation detail behind the API.
Client–Server Separation
Key Takeaways
- Clients and servers can evolve independently.
- The API forms a boundary between client and server.
- Database details should normally remain behind the API.