Open a food-delivery app and order a biryani. You see a menu with photos and an "Add to cart" button. When you tap "Place order", something checks the restaurant is open, works out the bill with taxes and delivery charges, charges your UPI, and saves the order so the restaurant and the delivery partner can see it. Those are three different parts of the app: the frontend you see, the backend that does the work, and the database that remembers everything.
Job listings use these words constantly ("frontend developer", "backend engineer", "full-stack"), and so do tutorials. This lesson explains frontend, backend and databases: what each does, how they talk to each other, the languages and tools used for each, and how to decide which one interests you.
What you need first: HTTP and HTTPS explained.
Key terms
- Frontend (client side): the part of an app that runs on the user's device and that they see and touch.
- Backend (server side): the part that runs on servers: business rules, security, and talking to the database.
- Database: organised storage for an app's data, such as users, orders and products.
- Full-stack developer: someone who works on both frontend and backend.
- API: the set of requests the backend accepts from the frontend.
- Business logic: the rules of the app, like "delivery is free over ₹199".
The three parts at a glance
| Frontend | Backend | Database | |
|---|---|---|---|
| Runs on | User's browser or phone | Company's servers | Company's servers |
| Job | Show data, take input | Apply rules, check permissions, process data | Store and find data |
| Restaurant comparison | Dining area and menu | Kitchen | Store room and order book |
| Users see it? | Yes | No | No |
| Common tools | HTML, CSS, JavaScript, React, Kotlin, Swift, Flutter | Python (Django, FastAPI), JavaScript (Node.js), Java (Spring), Go, PHP | PostgreSQL, MySQL, MongoDB, Redis |
In a restaurant, you never walk into the kitchen; you talk to the waiter, who passes your order on. In a web app, the frontend never touches the database directly; it sends requests to the backend, and the backend talks to the database.
User <-> Frontend (browser/app) <--HTTP--> Backend (server) <--> Database
Frontend: what users see
The frontend is everything that appears on the screen: layout, colours, buttons, forms, animations. On the web, it's built from three languages:
| Language | Job | Example |
|---|---|---|
| HTML | Structure and content | Headings, paragraphs, buttons, forms |
| CSS | Appearance | Colours, fonts, spacing, layouts for phone and desktop |
| JavaScript | Behaviour | What happens when you click, loading new data without reloading the page |
A tiny piece of a frontend:
<h1>Biryani House</h1>
<p>Chicken Biryani: ₹249</p>
<button id="add">Add to cart</button>
<script>
document.getElementById("add").onclick = () => alert("Added to cart");
</script>
Larger apps use frameworks like React, Angular or Vue to organise their JavaScript. Mobile app frontends are written in Kotlin (Android), Swift (iOS), or cross-platform tools like Flutter and React Native.
Frontend work includes:
- making pages look right on every screen size (responsive design),
- making apps usable for everyone, including people using screen readers (accessibility),
- making pages load fast,
- checking form input early ("please enter a 10-digit mobile number") for a better experience.
Backend: the work behind the scenes
The backend runs on servers the company controls. It receives requests from the frontend and decides what to do. In the food-delivery example, when you tap "Place order", the backend:
- Checks you're logged in.
- Checks the restaurant is open and the items are available.
- Works out the bill: prices, taxes, delivery charge, coupon.
- Asks the payment gateway to charge you.
- Saves the order in the database.
- Notifies the restaurant and finds a delivery partner.
- Sends a response back to the app: "Order placed".
Here's step 3 as a small piece of backend logic in Python:
MENU = {"chicken biryani": 249, "raita": 39, "gulab jamun": 79}
def bill(items, coupon=None):
subtotal = sum(MENU[name] * qty for name, qty in items.items())
delivery = 0 if subtotal >= 199 else 30
discount = 50 if coupon == "FIRST50" and subtotal >= 300 else 0
gst = round((subtotal - discount) * 0.05, 2)
return {"subtotal": subtotal, "discount": discount, "gst": gst,
"delivery": delivery, "total": subtotal - discount + gst + delivery}
print(bill({"chicken biryani": 1, "raita": 2}))
print(bill({"chicken biryani": 1, "raita": 2}, coupon="FIRST50"))
{'subtotal': 327, 'discount': 0, 'gst': 16.35, 'delivery': 0, 'total': 343.35}
{'subtotal': 327, 'discount': 50, 'gst': 13.85, 'delivery': 0, 'total': 290.85}
(The numbers and rules are made up for this example.)
Why the backend must check everything
Anything on the frontend can be changed by the user: they can edit the page in developer tools, or send their own requests without the app at all. So the frontend may show a price of ₹249, but the backend must never trust a price, discount or "isAdmin" flag sent from the frontend. It looks prices up itself and checks permissions on every request. Frontend checks are for convenience; backend checks are for security.
Backend work includes designing APIs, writing business logic, handling logins and permissions, connecting to payment and SMS services, and keeping things fast when thousands of people order at once.
Databases: the app's memory
When the backend restarts, everything in its variables is gone. Anything that must last (users, orders, menus, reviews) goes in a database.
Relational (SQL) databases
The most common kind stores data in tables with rows and columns, like spreadsheets that link to each other. You ask for data with SQL:
| order_id | user_id | restaurant | total | status |
|---|---|---|---|---|
| 5012 | 77 | Biryani House | 343.35 | delivered |
| 5013 | 81 | Dosa Corner | 180.00 | preparing |
SELECT restaurant, total FROM orders WHERE user_id = 77;
PostgreSQL, MySQL, SQLite, SQL Server and Oracle are relational databases. Python includes SQLite, so you can try SQL without installing anything:
import sqlite3
db = sqlite3.connect(":memory:") # a temporary database in RAM
db.execute("CREATE TABLE orders (id INTEGER, user_id INTEGER, restaurant TEXT, total REAL)")
db.executemany("INSERT INTO orders VALUES (?, ?, ?, ?)", [
(5012, 77, "Biryani House", 343.35),
(5013, 81, "Dosa Corner", 180.0),
(5014, 77, "Dosa Corner", 120.0),
])
for row in db.execute("SELECT restaurant, total FROM orders WHERE user_id = 77"):
print(row)
print(db.execute("SELECT COUNT(*), SUM(total) FROM orders").fetchone())
('Biryani House', 343.35)
('Dosa Corner', 120.0)
(3, 643.35)
Other kinds of database
| Type | Stores data as | Examples | Good for |
|---|---|---|---|
| Relational (SQL) | Tables with fixed columns | PostgreSQL, MySQL | Orders, payments, most business data |
| Document | JSON-like documents | MongoDB, Firestore | Flexible data that varies between records |
| Key-value | A key and its value | Redis | Very fast caching, sessions, counters |
| Search | Indexed text | Elasticsearch, OpenSearch | Search boxes, logs |
Most apps start with one relational database, and add others only when needed.
How the parts talk
The frontend and backend talk over HTTP, usually sending data as JSON. When the app loads your past orders:
1. App sends: GET /api/orders (with your login token)
2. Backend checks the token, then asks the database:
SELECT ... FROM orders WHERE user_id = 77
3. Database returns the rows to the backend.
4. Backend sends: 200 OK
[{"id": 5012, "restaurant": "Biryani House", "total": 343.35}, ...]
5. App shows the list on screen.
The list of requests the backend accepts (GET /api/orders, POST /api/orders and so on) is its API, covered in what is an API?. The data format is covered in JSON for beginners.
Roles and careers
| Role | Works on | Typical skills |
|---|---|---|
| Frontend developer | What users see and use | HTML, CSS, JavaScript, React, design sense, accessibility |
| Backend developer | Servers, APIs, business logic | Python, Java, Node.js or Go; SQL; APIs; security |
| Full-stack developer | Both | A frontend framework, a backend language, SQL |
| Mobile developer | Android or iOS apps | Kotlin, Swift or Flutter |
| Database administrator / data engineer | Databases and data pipelines | SQL, performance tuning, data tools |
| DevOps / cloud engineer | Servers and deployment | Linux, Docker, cloud, CI/CD; see what is DevOps? |
How to choose: if you enjoy visual work and seeing results on screen, try frontend. If you enjoy logic, data and how systems work, try backend. Build one small project with both (for example, a to-do app with a simple page and a Python backend) and notice which part you enjoyed.
Practice
- Is each of these frontend, backend or database work? (a) Making the menu look good on a small phone screen. (b) Checking that a coupon is still valid. (c) Storing every order for 7 years. (d) Showing an error if the mobile number has 9 digits.
Show the answer
(a) Frontend. (b) Backend. (c) Database. (d) Frontend, for a quick message; the backend should check it again, because the frontend can be bypassed.
- Why should the backend look up prices itself instead of using the price the app sends?
Show the answer
Users can change anything on their own device, or send requests without the app. If the backend trusted the price sent, someone could order a ₹249 biryani for ₹1. The backend must use its own data for prices and permissions.
- Using the
billfunction above, what's the bill for 2 gulab jamun and nothing else? Work it out first, then check.
Show the answer
Subtotal 158, which is under 199, so delivery is 30. GST is 5% of 158 = 7.9. Total = 158 + 7.9 + 30 = 195.9.
MENU = {"chicken biryani": 249, "raita": 39, "gulab jamun": 79}
def bill(items, coupon=None):
subtotal = sum(MENU[name] * qty for name, qty in items.items())
delivery = 0 if subtotal >= 199 else 30
discount = 50 if coupon == "FIRST50" and subtotal >= 300 else 0
gst = round((subtotal - discount) * 0.05, 2)
return {"subtotal": subtotal, "discount": discount, "gst": gst,
"delivery": delivery, "total": subtotal - discount + gst + delivery}
print(bill({"gulab jamun": 2}))
{'subtotal': 158, 'discount': 0, 'gst': 7.9, 'delivery': 30, 'total': 195.9}
- Using the SQLite example, write a query that finds the total spent at "Dosa Corner".
Show the answer
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE orders (id INTEGER, user_id INTEGER, restaurant TEXT, total REAL)")
db.executemany("INSERT INTO orders VALUES (?, ?, ?, ?)", [
(5012, 77, "Biryani House", 343.35),
(5013, 81, "Dosa Corner", 180.0),
(5014, 77, "Dosa Corner", 120.0),
])
print(db.execute("SELECT SUM(total) FROM orders WHERE restaurant = 'Dosa Corner'").fetchone()[0])
300.0
- Why can't the frontend just connect to the database directly?
Show the answer
The frontend runs on users' devices, so any database password inside it could be found and used to read or delete everyone's data. Keeping the database behind the backend means only trusted server code can reach it, and every request goes through the backend's checks.
Key takeaways
- The frontend runs on the user's device and shows the interface (HTML, CSS, JavaScript, or mobile languages).
- The backend runs on servers and applies the rules: logins, prices, permissions, payments.
- The database stores data that must last; relational databases use tables and SQL.
- The frontend talks to the backend over HTTP with JSON; only the backend talks to the database.
- Never trust data from the frontend: the backend must check everything again.
Frequently asked questions
Is Python used for frontend or backend?
Mainly backend (Django, Flask, FastAPI), plus data and automation. Browser frontends use JavaScript, because that's what browsers run.
Which is easier, frontend or backend?
Neither is easier overall. Frontend gives quick visual results but has many devices, browsers and design details to handle. Backend has less visual work but more logic, data and security. Try both and see which you enjoy.
Do I need to learn SQL?
Yes, for backend, full-stack and data roles. Almost every company stores important data in a relational database, and SQL is how you read it. The basics take a few weeks.
What to learn next
- See how the frontend and backend talk in what is an API?
- Learn the data format they use in JSON for beginners.
- Plan larger systems with system design for beginners.