Question Locked

Server Side of Website

0 helpful
8 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello.
I am a bachelor's student in Automation and Computer Science.
I want to create an eCommerce site from scratch using a three-way architecture. I don't have any questions regarding the HTML or the Database, just about the Server (I'm going to pay for hosting). I created a RestAPI using Spring, Java, and MySQL in the past, so I have some experience (Javascript sends the input to the server, and the server fetches data from my database and sends it back to my website).
I want to know how I can connect my Website and my Database, and how to fetch the correct data. Where do I put my logic code?

I would appreciate your response to this.

8 replies

by kees_b edited

The client (the program running in your browser) sends a get or put-request to the server.
The program running on the server connects to the database and runs the necessary SQL-statements via the database API.

https://www.w3schools.com/php/php_mysql_connect.asp tells how it works in PHP 5. But you might be using another language at the server site.

Two remarks:
1. Isn't this treated in the course material?
2. Why not run the server on your own PC in localhost? You don't have to pay for hosting then and it's a very useful experience for an IT bachelor.

by Iustinian Serban

Thank you for your answer.
So if I want to create a RestAPI as a Spring Boot Application and host it on a server, would it run like a normal website?
1. Currently, I'm in my first year of University. They teach us this type of course in the second or third year. This website is a personal project.
2. I was thinking about that. I will run it on my PC in the early stages, but I want to take the site public when it's finished.

by kees_b edited

Strictly speaking, an API is an interface. Interfaces don't run. They are being called.
Websites don't run either, The webserver runs.

Best of luck with your project.

by auraitsollutions edited

The server-side code handles tasks like validating submitted data and requests, using databases to store and retrieve data and sending the correct data to the client as required.

by km.naqvie14 edited

Hello, as you already have experience with creating a REST API using Spring, Java, and MySQL, connecting your website to the database should be relatively straightforward.

To connect your website to your database, you will need to create a server-side application that will handle requests from the website and interact with the database to retrieve or update data.

You can use Spring to create this server-side application. In the application, you will need to create a data access layer that will handle interactions with the database. This layer should include classes that will connect to the database, execute queries, and return data.

Your logic code should be placed in the appropriate controller classes in the server-side application. These controllers will handle incoming requests from the website, retrieve data from the database using the data access layer, and return the appropriate data to the website in the form of a REST API response.

by lucasgarciabertaina edited

Unfortunately, you haven't made an SSR web app without using Javascript.

If you are new in this area, I recommend you to make the basic frontend courses of FreeCodeCamp and after that start to look up a javascript framework called React.

There are many other options, like angular, svelt, and vue. But I think react is a good option in your context.

by primepage123 edited

In most of the applications, backend APIs will be acted as a mediator to communicate with the clients through the web server.

You can write all the business logic in the APIs itself and use them to showcase the information on the frontend.

You can also go for any no code services like GraphQL to create APIs quickly and use them.

This discussion is closed to new replies.