What is backend?

I understand what the term backend is, code running on the server instead of the client.
But what does it do? What can you do with backend that you can’t with frontend? What changes? How do you program it?
I cannot wrap my head around this, I tried googling some tutorials of backend to hopefully learn more about it, but didn’t find any. So if anyone knows a good backend tutorial, preferably JavaScript (Node), I would appreciate it.

1 Like

Back-end programming actually have a lot of benefits. A server can typically store sensitive information without exposing it into the client, while the client can be manipulated to leak sensitive data.

Today, a lot of server-side coding is used for server-side websites. This means you can control what is inside the code before serving it to the user, while client-side programming only touches the looks and positioning of a website, while the server-side can add logic to buttons, it can add custom animations, etc.

At the end it is mostly used to add logic to a site, serving static-websites, adding connection to databases, and many many more. Here’s articles about it:

2 Likes

It’s a great question. And I’m not sure it’s not possible to do it all Client side using Ajax. And a few other tricks.

One problem I see comes when someone owns a website and wants to make a business. Then, you want to own the data. Credit cards, User names and Passwords. Also, not only business-wise but privacy wise, this is reasonable.

And this data is obviously in a different computer, that you control. Server side is the controlled access from users to this data you own.

So I’d say it’s not only that you can’t run things Client-side.

But it’s part of a business idea.


I just tried a concrete reason, but as for the practical usage, this are examples:

  • Database Connection
  • Authentication

Also, Another absolute basic necessity is that the page has to be stored somewhere. Be it html, or a template that you render on the fly. But you know this already.

1 Like

Thank you, that really explains it well.
I was confused because I only saw backend to connect to databases. But I was confused why you couldn’t just get the data from the frontend and process it on the client.

But this cleared that out, so the server-side controls what the program displays/does and the frontend just makes it pretty?

Yeah, sure. There are other ways to handle things. Sometimes the frontend can handle data, etc. Sometime the backend can handle the view elements, like server side rendering.

But what you describe, as a simple model, sure. I like to think of it as the frontend is the window through which the user looks. There may be minimal processing there are a lot. The backend handles anything that is sensitive, that is too intensive for the frontend (you don’t want to bog down their computer with processing, or that is shared among frontend instances (like a socket for a chat app). But that’s an oversimplification, too. But you’re getting closer to it.

Also, keep in mind that in the FCC curriculum, you have the “APIs and Microservices” section where you’re going to build servers. There are many languages that you can use to write your server (the frontend doesn’t know or care) but we will be doing it in Node (JavaScript). I think things will make a lot more sense once you get through that.

1 Like

For me, i tend to think in bad analogies. For this, i had written an answer sometime back involving a great one… The classic American diner.

You, the client, find a seat. Your waitron comes by and takes your order. Think of this as the front end code, on which the client depends. Once the order is taken, an interesting handoff occurs.

Diner lingo is colorful and entertaining. It is also an API - an agreed-upon communication standard between the front end (the wait-staff) and the backend (the kitchen). Your order is sent to the kitchen and (in a deeper analogy) the order becomes a promise. But that’s a story for another day.

For now, this works. You, the client at the table, can season with condiments or perhaps get a beverage at the fountain, but the grill is out of your hands. Someone else is doing the heavy lifting.

In essence, that’s front end and back end. For security reasons, our client side might not be able to pull in data from as many places as the server can (client side will encounter CORS issues, while servers have more latitude). Servers might access databases or other APIs, or hardware devices, things the client simply can’t.

We do have a lot more leeway lately, with serverless apps (using things like firebase), but they’re more “server-lite” - it’s still accessing remote information that is somehow secured and private.

Each plays a part. The front end is client facing, like an atm - but the server is the bank and FDIC behind it, providing services and security the atm lacks. (oooo, another terrible analogy. Gotta remember that one…)

2 Likes

It’s weird because there are so many ways to architect applications (see JAM Stack or Serverless)

But in general backend is about centralizing and mediating data flow between clients (the frontend) and securing that data.

A user in China might drag a ticket from “todo” to “doing” and a user in Canada sees the app update. That’s handled by your backend code of some form or another.

Typically (not always) most business rules live in backend code. How often should a contact receive a promotional email, and how many days between? When they click the email, the system probably shouldn’t keep resending it.

When a new user signs up, send them a verification email.

All of those rules have to live somewhere and it can’t be the code executing in people’s browsers.

The other piece is hiding and controlling access to data or sensitive environment variables like database connection strings, API keys etc.

Everything in the browser is public so you can’t just make a call to a 3rd party API directly without exposing your credentials. Your backend has to be the one to query those API’s or some other serverless alternative. You’re front end asks the backend to fetch the data from that API on its behalf.

You know the frontend is mainly concerned with the presentation of a website to your clients with all it’s animations and interactive ui’s to make experience better but in the backend imagine all the posts you make on Facebook where do they go, how do Facebook store all users on FB, those post likes counts and all those user data that is what the backend is made of. It includes your database and a backend language like node to be able to retrieve all data and store it in an API format like json so that the front end can easily present this data in a more convenient and approachable way. Hope this helps. :smiling_face_with_three_hearts::blush::hugs: Happy Coding