Backend class notes Week 1
Backend class notes Week 1
Development
WEEK 01
INSTRUCTORS:
1
The Internet
The Web
The web is one of the ways information is shared on the internet. It, is a collection
of information that is accessed via the internet using web browsers., such as
Chrome, Safari, Microsoft Edge, Firefox, and others.
Difference
You can think of the internet as the infrastructure that connects different networks
and devices, and the web as one of the services that runs on top of that
infrastructure.
Server side applications also known as backend apps are applications that run on
the web server (a physical computer that hosts the source code of the server side
app) which performs a specific task and gives back response when requests are
sent to it from client side applications (apps that a user can interact with) or other
server side applications.
Components
2
The major components of a server side app are the API and the DATABASE.
SERVER: Servers, which are the hardware and software that make up your
computer. It is also responsible for hosting the source code of the server side app
which is an API. The API(Application Programming Interface) as the name suggests
is the intermediary or better put the middleman between a client side app and a
database. It is responsible for sending, processing, and receiving data requests. It
receives requests from the client side, processes the requests with data gotten
from the database if need be, also sends any data to the database that needs to be
stored and sends back a response to the client side app. There are two major types
of API’s which are Representational State Transfer(REST) API and Simple Object
Access Protocol(SOAP) API.
3
DATABASE: The Database is the part of the server side app that is responsible for
storing, organizing, and processing data so that it is retrievable by server requests.
E.g the information of a user facebook account like the name, pictures and friends
list is stored in facebook's database. There are different types of database and the
choice of one will depend on the nature of operations that will be carried out on the
application and type of data your application will use. The two types of database
are: Relational Database Management System(RDBMS) and the Non Relational
Database Management System(NoRDBMS).
These components work together to build the foundation for each website.
As for building your website, backend developers will establish three things:
● Your logic code, which is essentially a set of rules for how your website will
respond to certain requests and how objects of your website will interact.
● Your database management, which is how your website will organize,
manage, and retrieve its data.
● Your infrastructure, which is how your site will be hosted. Hosting your own
site will give you greater control, but it’s much more expensive and requires
you to maintain your own server health and security.
With these components and decisions in place, your website will be ready for
front-end development.
4
Note: The back-end is slightly tangential to web development because you don't
always need a back-end if you're not storing any data. “Data” in this context means
any user-entered information that you need to save and persist. Think about
logging in to a website. If they don't have a back-end, how could they remember
your login information? Or what your profile settings are? To get this information,
you need a back-end.
Facebook, as an example, needs to know what people are in your Friends list, what
events you have joined, what posts you have created, and more. This is all "data"
that lives in a database. If they didn't have a back-end with a database, none of that
data would be accessible to them.
5
On the other hand, a website that’s purely informational and doesn’t require the
users to enter any data wouldn’t need a back-end.
So, if you have no data, you don’t necessarily require back-end development. But
that’s not saying you shouldn’t learn the basics. You never know when you might
need it.
Server side applications are not useful on their own but are used by either client
side apps like mobile applications, websites, games or other server side apps to
store data, to perform authentication or to send back data data as the case may be.
There are many hosting platforms used to host server side applications and
here is a list of a few:
1. Back4app
2. Heroku
3. Firebase
4. Render
5. Digital Ocean
6. AWS
7. Linode
8. Google Cloud
9. Kinvey
10. Cloudflare Workers
6
The Server Side Application Development Process
Server side applications are an integral part of most client side applications so its
use and importance cannot be overemphasized. API’s themselves have become a
source of income and revenue and we have many that are being used in
applications that require their functionalities e.g google maps api, twillo bulk sms
and email api e.t.c. Seeing this, the expertise of server side developers are sought
after not only to build applications that can work with different client side apps but
also custom applications that can render a particular service and generate funds
and revenue. There different things to consider before in building a server side
application which includes:
Map out entities and their relationships: Here, the different entities or blocks of
data and how they will relate to each other is determined. There will be different
options based on the type of database you’re working with. This will affect how data
will be fetched and also flow in your application.
Finalize the data model: Here, the data model of your application is determined.
This is also dependent on the type of database you are working with as different
databases will give you different options.
Server Side App Development: Here is where you start writing your code based
on the information that is gotten from the steps above.
7
Testing: Here, the different endpoints(a point where a client side or server side app
connects to your application and access a specific functionality or feature of your
application) and tested and debugged if errors are found out.
The Command Prompt (cmd.exe) and PowerShell are both command-line interfaces
(CLIs) in Windows. PowerShell provides a more advanced and flexible
command-line experience for Windows users, but the Command Prompt may still
be useful for basic tasks and in situations where compatibility with older systems is
a concern.
8
The next image shows the command prompts available in Windows — there's a
good range of options from the "cmd" program to "powershell" — which can be run
from the start menu by typing the program name.
1. Change Directory
Command: cd
This command will change the directory that you’re currently working with in the
Terminal in order to execute other commands on a different directory, view the
contents of a different directory or open a file in a different directory. This is a very
common command that will be used when working with the CLI. If you ever lose
your place and which directory you’re in, type pwd (print working directory) and
press Return to echo the current path.
If you want to move back up to the previous directory, you can use two dots:
cd ..
2. Listing Directory
9
Command: dir
In the terminal, the "dir" command is used to list the contents of a directory in a file
system. It is commonly used in Microsoft Windows systems and is equivalent to the
"ls" command in Unix-based systems. The "dir" command can display various
information about the files and directories, such as the names, sizes, creation
dates, and permissions.
3. Remove a file
Command: rm
4. Move a file
Command: mv
When you don’t want to copy a file, but instead move it, use the same format of the
cp command, but instead replace ‘cp’ with ‘mv’. This will perform a file move from
10
one location to another, removing the file from the original location and putting it
into the new location.
5. Create a directory
Command: mkdir
This command will allow you to create a directory (folder) right from the CLI. When
you need a place to store new files, just use this command to add a new directory in
the current working directory, or specify a full path to the location where you want
the new directory to be placed.
Command: rmdir
When you’ve created a folder that has the wrong name, you can easily use the mv
command to rename it, or if you want to remove a directory altogether, use the
rmdir command followed by the path to the directory.
Command: clear
11
It removes all previously typed commands from the Terminal view and gives you
back a clean slate to work from. Instead of typing clear, you can also alternatively
press Command+K to perform the same action.
Command: exit
This command will close out the current session in the Terminal.
Note: A very useful terminal shortcut is using the tab key to autocomplete names
that you know are present, rather than having to type out the whole thing. For
example, after typing the above two commands, try typing cd D and pressing tab —
it should autocomplete the directory name Desktop for you, provided it is present
in the current directory. Bear this in mind as you move forward.
Enter NodeJs
● Node.js is an open-source, cross-platform, back-end JavaScript runtime
environment that runs on the V8 engine and executes JavaScript code
outside a web browser.
● Written in: C, C++, JavaScript
● Operating system: z/OS, Linux, macOS, Microsoft Windows, SmartOS,
FreeBSD, OpenBSD, IBM AIX
12
JavaScript Engines
A JavaScript engine is a software component that executes JavaScript code. The first
JavaScript engines were mere interpreters, but all relevant modern engines use
just-in-time compilation for improved performance. JavaScript engines are typically
developed by web browser vendors, and every major browser has one.
V8 from Google is the most used JavaScript Engine.
SpiderMonkey is developed my Mozilla
JavaScriptCore is Apple’s engine for its Safari browser.
Chakra is the engine of Microsoft’s Internet Explorer
13
Variables
4 Ways to Declare a JavaScript Variable:
● Using var
● Using let
● Using const
● Using nothing
14
Variables Declared with let:
Best Practice
Always declare JavaScript variables with var, let, or const.
The var keyword is used in all JavaScript code from 1995 to 2015.
The let and const keywords were added to JavaScript in 2015 in something call
ECMAScript 2015 (ES6).
If you want your code to run in an older browser/server, you must use var. (But var
should be avoided as much as possible)
Most modern browsers or servers can relate very well with let and const
15
Remember, var should be avoided as much as possible because it brings along with
it, a lot of JavaScript issues which are better left forgotten.
16
And 2 data types that cannot contain values
null
undefined
There are 5 different data types that can contain values. Note that there’ve been
additions to these types with ECMA revisions, but these are the types which matter
for now.
string
number
boolean
object
function
17