CSC 431 - Web Development (Part 2)
Module 1: Introduction to Backend Development
1.1 What is Backend Development?
Definition and Importance of Backend Development
Backend development refers to the process of building and maintaining the
server-side logic of web applications. It involves working with databases,
servers, APIs, and application logic to ensure data is processed correctly and
securely.
The backend is responsible for:
Managing data storage and retrieval
Handling user authentication and authorization
Ensuring the security and performance of web applications
Providing APIs for frontend applications
Real-World Examples of Backend Systems
E-commerce Websites: Handling product catalogs, user
authentication, and payment processing.
Social Media Platforms: Managing user profiles, posts, and real-time
messaging.
Online Banking Systems: Processing transactions securely.
1.2 Role of Backend in Web Development
How Backend Powers Web Applications
A web application consists of three main layers:
1. Frontend (Client-Side) – What users see and interact with (HTML,
CSS, JavaScript).
2. Backend (Server-Side) – Handles business logic, database
operations, and user authentication.
3. Database – Stores application data.
Key Responsibilities of Backend Development
Processing client requests (handling form submissions, API calls, etc.).
Performing complex computations and business logic.
Managing and securing user data in databases.
Ensuring scalability and efficiency of applications.
1.3 Backend vs. Frontend
Frontend Development
Focuses on the user interface and user experience.
Technologies: HTML, CSS, JavaScript (React, Vue, Angular).
Backend Development
Focuses on the server-side logic, databases, and APIs.
Technologies: Python (Flask, Django), Node.js, Java (Spring Boot).
How They Work Together
The frontend sends requests to the backend via HTTP. The backend
processes the request, retrieves or updates data, and sends a response back
to the frontend.
Example:
1. A user submits a login form.
2. The frontend sends the credentials to the backend.
3. The backend verifies the credentials and responds with a success or
failure message.
1.4 Overview of Python for Web Development
Why Use Python for Backend Development?
Easy to learn and read.
Strong community support.
Extensive libraries and frameworks for web development.
Key Python Web Frameworks
Flask: A lightweight and flexible micro-framework.
Django: A full-stack web framework with built-in features for security
and scalability.
Important Python Libraries for Web Development
requests: Handling API requests.
SQLAlchemy: Database ORM for Flask.
Django ORM: Built-in database handling for Django.
1.5 Introduction to Web Servers and Databases
What is a Web Server?
A web server processes client requests and serves web pages or API
responses. Examples include:
Apache
Nginx
Gunicorn (for Python applications)
Types of Databases
1. SQL Databases (Relational Databases)
o Examples: PostgreSQL, MySQL, SQLite
o Use structured query language (SQL) for data manipulation.
2. NoSQL Databases
o Examples: MongoDB, Firebase
o Store data in flexible formats like JSON or key-value pairs.
How Backend Communicates with Databases
Backend applications use Object-Relational Mappers (ORMs) like
SQLAlchemy (Flask) and Django ORM to interact with databases without
writing raw SQL queries.
Example of querying a database with Django ORM:
from myapp.models import User
users = User.objects.all()
print(users)
1.6 Introduction to HTTP, REST APIs, and Databases
Understanding HTTP
Hypertext Transfer Protocol (HTTP) is the foundation of communication on
the web. It defines methods for client-server communication:
GET – Retrieve data.
POST – Submit data.
PUT – Update data.
DELETE – Remove data.
What is an API?
An API (Application Programming Interface) allows applications to
communicate with each other. A REST API (Representational State Transfer)
is a popular type of API that follows REST principles.
CRUD Operations in Backend Development
CRUD stands for:
Create – Adding new data (POST request).
Read – Retrieving data (GET request).
Update – Modifying existing data (PUT request).
Delete – Removing data (DELETE request).
1.7 Setting Up a Development Environment
Installing Python and Virtual Environments
1. Install Python from python.org.
2. Create a virtual environment: