Introduction
to Backend Development
Let use Restaurant as an example “Imagine
you’re in a restaurant. You sit at the table and order jollof rice. The waiter
takes your order, disappears into the kitchen, and then comes back with your
food. That’s how the internet works too!”
- The front end is what you see (like the
restaurant table).
- The back end is the kitchen where things happen
(you don’t see it, but it’s very important).
- The waiter is like the API that moves
messages back and forth.
What Tools Do We Use?
- Node.js
→ a tool that lets JavaScript work on the server (kitchen).
- Express.js
→ makes Node.js easier and faster, like a smart waiter.
- Django
→ also a backend tool but uses Python. Very organized, great for big
projects.
My question is “What do you think
happens when you press ‘login’ on Facebook?” Tell me your opinion if is
different from what am about say:
When
a user interacts with a website, such as by clicking a login button after
entering their username and password, that information is sent from the front
end (what the user sees) to the backend (the hidden part of the website that
does the real work). The backend receives this data through an HTTP request,
then checks it against stored information in a database to see if the username
exists and if the password is correct. If the details match, the backend sends
a response back to the front end saying “Login successful” and may also include
some extra data like a token to keep the user logged in. If the information is
incorrect, the backend sends a response saying something like “Invalid username
or password.” This process is what allows websites to securely check and
respond to user actions.
RESTful
APIs & HTTP Requests
Keep It Real:
“Let’s go back to our restaurant.
You ask for fried rice that’s a request.
The waiter delivers it that’s a response.”
What is an API?
- An API is a list of things you can ask the
backend to do.
- Think of it like a menu the options are: get user, post comment,
delete message, etc.
When
learning about RESTful APIs and how websites or apps work behind the scenes,
it's helpful to think of it like choosing from a menu at a restaurant. On a
website, when you do something like view a profile, post a comment, or delete a
message, you're basically selecting an "option" from the system’s
menu just like ordering food. These
actions are not random; they follow a standard way of communication between the
front end (what you see) and the backend (the system doing the work). This is
where RESTful APIs come in.
RESTful
APIs allow different parts of a website or app to talk to each other by sending
and receiving information. Each action you want to perform — like getting data,
sending new information, updating something, or deleting it — has its own
"option" or command. These commands are known as HTTP methods. For
example, `GET` is used when you want to read or fetch data, `POST` is used when
you're sending new data (like submitting a form or comment), `PUT` or `PATCH`
is used for updating something, and `DELETE` that is for removing data.
So,
when you hear "think of it like a menu," it means the API gives you a
list of allowed actions that you can request. Just like you tell a waiter what
dish you want, your website sends a request to the backend with instructions.
The backend then prepares the right response and sends it back to the front end
for the user to see. This simple structure makes it easier to build and
maintain websites and apps in a clear and organized way.
What is a HTTP Request?
- The way you talk to the backend.
- There are 4 common types:
- GET → give me something (like “get user data”)
- POST → I’m sending something (like login info)
- PUT → update something (like change your password)
- DELETE → remove something (like delete a photo)
In backend development, when a
website or app communicates with the server, it uses specific types of actions
called HTTP methods. These methods are like giving clear instructions to the
server about what you want to do. The four most common ones used in RESTful
APIs are GET, POST, PUT, and DELETE.
The GET method is used when you want
to receive or fetch information from the server. For example, if you're on a
social media app and you want to see a user’s profile, the system will use a
GET request to ask the backend, “Give me this user’s data.” It doesn’t change
anything on the server — it just asks for information.
The POST method is used when you
want to send new data to the server. A good example is when you log into a
website. You enter your username and password, and then the site sends that
data using a POST request. The backend checks the data and responds, either
letting you in or telling you the login failed.
The PUT method is for updating
existing data. For example, if you want to change your password or update your
profile picture, a PUT request is used to tell the backend, “Here is the new
information — please update it.”
Lastly, the DELETE method is used to
remove data from the server. For instance, if you decide to delete a photo or a
post, the system sends a DELETE request to the backend, which then removes that
item from the database.
These four simple actions make up
the main way the front end and back end talk to each other, allowing apps and
websites to function smoothly.
Now do this class work create their
own API for a music app:
- GET /songs
- POST /new-song
- DELETE /song/2
Database
Basics
“Okay, now we’ve placed the order. Where does
the chef go to get rice, chicken, or pepper? From the store, right? The store
is like a database.”
📦 A database stores
all your data:
- Names
- Passwords
- Pictures
- Comments
- And more!
Types of Databases:
- SQL
(Structured) → like tables in Excel: rows and columns.
- MySQL / Postgre SQL
→ examples of SQL databases.
- MongoDB (NoSQL) → stores data as documents, like short stories
in a notebook.
In
backend development, databases are used to store, organize, and manage data.
There are two main types: SQL (Structured Query Language) databases and NoSQL
databases. Each has its own style of keeping data.
SQL
databases are structured and organized like tables in Excel — with rows and
columns. Each row is a record (like one person’s data), and each column is a
field (like name, age, or email). This makes it easy to sort and search for
information. Examples of SQL databases include MySQL and PostgreSQL. They are
great when you need everything to stay organized and follow a clear structure.
On
the other hand, MongoDB is an example of a NoSQL database, which stores data in
a more flexible way as documents. Think
of each document like a short story in a notebook, where the data is written in
key-value pairs (like “name: John”). This makes MongoDB good for situations
where the data may change often or doesn’t need to fit into a strict table
format.
In
short, SQL databases are best when you need a clear, organized structure, while
MongoDB and other NoSQL databases offer more freedom and flexibility when
storing information.
QUICK
RECAP:
- Backend is like the kitchen.
- RESTful APIs are how we order (requests).
- Databases are where we store ingredients (data).
🎉 End with This:
“Now you see how big apps like
WhatsApp and Instagram work behind the scenes! If you want to become a
developer, learning backend is like learning to be a great chef!”
0 comments:
Post a Comment