A
A
AsdfAsdfSK2019-01-19 13:22:51
MySQL
AsdfAsdfSK, 2019-01-19 13:22:51

The structure of an online store?

Good afternoon. There is a task - to create an online store. I can’t figure out the structure and method of connecting technologies. I googled enough, but I didn’t find an answer that I could understand.
The essence of the structure is as follows:
Backend-json file-frontend. As I understand it, the Json file is something like a link between the front and the back. I understand how to connect json and the front end (for example, with a basket for the user), but there are problems with the back. In the json file I am creating a database of products and using them through IDs, but how to implement all this so that the future store administrator can add or delete files not in the JSON file, that is, not in the code itself. As I understand it, this requires a database that and will manage the json file. But how to connect the database with the json file? How to connect all parts of the project together? That is, the administrator user and the database? What technologies can you recommend for this? I know how to approach all this.
I would appreciate any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sorokinfil, 2019-01-19
@sorokinfil

Json is a javascript based way of exchanging data between different parts of an application. I don't know why you focused on it. The exchange of data between the back-end and front-end of a typical store occurs through requests.
A typical story on which you can find a lot of material in the course of development is back-end on apache + php + mysql, front-end interactive on ajax (a way to send information from the front-end to the back-end without reloading the page).
A little more difficult is to use a separate nodejs (server js) server instead of ajax, which can only provide an interactive shopping cart type, or completely replace apache + php. If you like javascript and json objects, it makes sense to learn nodejs and back-end with it.
To store goods, there must be a database. Do not store them in text files. Most likely mysql will do. The back-end connects to the database and retrieves data from there.
The scheme in the general case is as follows:
The client walks around the site. Requests a page from the server, sending some data along with the request (for example, somestore.ru/orders?style=list&page=3). In url data after ? is a get request.
The server receives the request and determines what the client wants. Typically, requests are redirected to a single entry point. If it is apache+php or nginx+php, then it is directed to index.php in the root of the site. url is broken into parts, then the server thinks in the way the developer taught him to think.
Is there /orders in the url? Yes, that means the customer requested an order page.
Is there a style in the get request? Yes, it means that a custom type of order output is selected.
Is there a page in the get request? Yes, that means a custom page is selected.
Is there a limit in the get request? No, it means the number of orders per page will be the default.
Next, the server, in the way that the developer taught it, forms and sends a request to the DBMS to extract orders from the orders table, starting from the page page (from the order numbered (page-1)*limit+1) and in the amount of limit. The database returns the requested information to the server. The server decides how to display information (whether style was passed from the client), generates a response in the form of an html code and sends it to the client. The client sees the finished and generated page on the screen.
html-code, in turn, may contain links to js-files, you know about it. The client clicks on the "Cancel order" button, javascript learns about it and generates an ajax request to the server, which accesses a special file on the server. For example, in the root of the site we have index.php, as well as ajax.php. And the url by which js sends the ajax request can be in the form somestore.ru/ajax.php. In this case, the request can be either in the form of get (details are transmitted using url parameters after the "?" sign), or post (details are transmitted in the request body, they can be just in the form of json).
ajax.php - a separate single handler for all ajax requests (optional). He, too, must be taught to access the database and extract information.
The client canceled the order, ajax.php on the server understands that this has happened and sends a request to the database to delete the record with the order, after which it returns a response to the client. The response from ajax can be either text / html code or a json object. It is displayed in the same way as without ajax, during normal site navigation.
The client-side javascript receives a response that the order has been deleted and removes it from the page without reloading.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question