Task #487
openTask #482: BackEnd common concepts investigation
BackEnd common concepts investigation [Minh]
100%
Description
What is API
APIs are mechanisms that enable two software components to communicate with each other using a set of definitions and protocols. For example, the weather bureau’s software system contains daily weather data. The weather app on your phone “talks” to this system via APIs and shows you daily weather updates on your phone.
REST APIs
These are the most popular and flexible APIs found on the web today. The client sends requests to the server as data. The server uses this client input to start internal functions and returns output data back to the client. Let’s look at REST APIs in more detail below.
What are REST APIs?
REST stands for Representational State Transfer. REST defines a set of functions like GET, PUT, DELETE, etc. that clients can use to access server data. Clients and servers exchange data using HTTP.
The main feature of REST API is statelessness. Statelessness means that servers do not save client data between requests. Client requests to the server are similar to URLs you type in your browser to visit a website. The response from the server is plain data, without the typical graphical rendering of a web page.
------------------------------------------------------------------------------------------------------------------------------------------
What is swagger
Swagger is the standard way of documenting the Standard APIs. Swagger is helpful when deploying APIs in azure. Swagger is primarily used for documenting API; now the question arises that why document APIs?. The building APIs that are internal in the enterprise or for the public consumption, the theme is the same that the developers usually use in the apps that they are building. For the other developers to be able to use our API, the API must be properly documented; otherwise, how would they know that what are the endpoints exposed by the api and what are the operations supported on those endpoints? What parameters should they pass, and what will they get back? What authentication methods to use?. To answer these questions, it is very important to document the APIs; if you want APIs to be consumed and properly used.
------------------------------------------------------------------------------------------------------------------------------------------
What is CRUD (Create,read,update,delete)
When we are building APIs, we want our models to provide four basic types of functionality. The model must be able to Create, Read, Update, and Delete resources. Computer scientists often refer to these functions by the acronym CRUD. A model should have the ability to perform at most these four functions in order to be complete. If an action cannot be described by one of these four operations, then it should potentially be a model of its own.
------------------------------------------------------------------------------------------------------------------------------------------
Relationship between frontend, backend, database:
Frontend: The frontend is the user interface of a web application that users interact with. It consists of web pages, components, and user interfaces that are rendered in a web browser or a mobile app. The frontend is responsible for presenting data to users, receiving user input, and sending requests to the backend. It is typically built using technologies such as HTML, CSS, and JavaScript, and often leverages frontend frameworks and libraries like React, Angular, or Vue.js.
Backend: The backend is the server-side of the application responsible for processing requests, managing business logic, and interacting with the database. It receives requests from the frontend, performs necessary computations, retrieves or updates data from the database, and sends responses back to the frontend. The backend is developed using server-side programming languages like PHP, Python, Ruby, Node.js, and Java. It may also use frameworks such as Laravel (for PHP), Express (for Node.js), Django (for Python), and many others.
Database: The database stores and manages the application's data. It is where information is stored, retrieved, updated, and deleted. The database could be a relational database (e.g., MySQL, PostgreSQL, SQLite) or a NoSQL database (e.g., MongoDB, Redis). The backend communicates with the database to read and write data. It is responsible for managing the database schema, executing SQL queries, and ensuring data consistency.
The flow of information in a typical web application is as follows:
The frontend sends HTTP requests to the backend. These requests can include actions like fetching data, submitting forms, or performing CRUD (Create, Read, Update, Delete) operations.
The backend receives the request, processes it, and interacts with the database to retrieve or modify data.
The database performs the necessary data operations and provides the results to the backend.
The backend, after processing data from the database, sends an HTTP response back to the frontend.
The frontend displays the response to the user.
----------------------------------------------------------------------------------------------------------------------------------------
HTTP response status codes
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped in five classes:
Informational responses (100 – 199)
Successful responses (200 – 299)
Redirection messages (300 – 399)
Client error responses (400 – 499)
Server error responses (500 – 599)
No data to display