Concept

A NetworkManager is a centralized layer responsible for handling all network requests in an application.

It abstracts networking logic away from view controllers and provides a clean, reusable API layer.


Key Idea

ViewController
↓
NetworkManager
↓
URLSession
↓
Server

Why Use NetworkManager

separates concerns
avoids duplicate code
improves maintainability
centralizes networking logic

Responsibilities

A proper NetworkManager handles:

request creation
HTTP methods (GET, POST, etc.)
headers and body configuration
response validation
data decoding
error handling

Core Design Principles

1. Separation of Concerns

ViewControllers → UI only
NetworkManager → networking only

2. Reusability

same function used across multiple screens