Things can become messy really fast depending upon the application you are building. That's why we have a way of building and organizing things called the MVC pattern. Here we divide the application into 3 parts: Model, View and Controllers.
In one word Model "Data Storage", View "Visual elements like UI" and Controllers "Controls the flow of Data between Model and View".
Lets look at an example of IKEA store
The Customer wants to buy a Chair, and places order to the Cashier.
The Cashier then asks the group of workers to build the Chair.
The Workers get individual parts from the Warehouse(Model) to build the chair. Then they assemble the parts and build a chair.
They then return this chair to the Cashier.
The cashier delivers this Chair to the customer.
Cashier is similar to UI of the app. Controller class is similar to the workers and the API/Database is similar to models.
What is happening inside an app ?
When you click on an App, you are asking the app to display the UI.
Then App's UI requests data from the Controller class.
The Controller class requests the data such as Img, title, description etc from the API client.
Then the API client fetches data from API/Database in the form of JSON, XML or HTML and sends it to the Controller class.
Controller class converts this JSON data into Class Objects. So that we can easily modify and present this data.
Now this object model is passed to the UI which access and displays on the screen.
References
Code sensi: https://www.youtube.com/watch?v=zjfViRCjT5U&t
Learned implementation from dbestech youtube channel