3.1 Tech Fundamentals
What Does It Take to Run a "Restaurant"?โ
You've probably heard terms like "frontend," "backend," and "database," but they still feel fuzzy. Don't worry โ I'll explain using something you experience every day: going to a restaurant.
Imagine you're opening a restaurant. What do customers see when they walk in? The menu, the decor, the waitstaff, the tables and chairs โ everything visible and tangible. In the internet world, this is the frontend. After customers order, the ticket goes to the kitchen where chefs prepare the food โ everything happening in the kitchen is invisible to customers, but without it the restaurant can't operate. This is the backend. The restaurant needs daily supplies โ ingredients stored in an organized warehouse, pulled out when needed. This is the database.
๐ค User (Customer)
โ Opens browser (Walks into restaurant)
โผ
๐ฝ๏ธ Frontend
โ HTML (Menu) + CSS (Decor) + JS (Waitstaff actions)
โ Everything the user sees: buttons, images, text, animations
โ Sends request (Waitstaff delivers order to kitchen)
โผ
๐จโ๐ณ Backend
โ Receives order โ Verifies identity โ Processes logic โ Fetches data
โ Business rules and security controls the user never sees
โ Reads/writes data (Chef gets ingredients from warehouse)
โผ
๐ฆ Database
โ Stores user info, order records, product data
โ Organized like a warehouse โ categorized, ready to retrieve
Remember these three terms: Frontend = dining room, Backend = kitchen, Database = warehouse.
System Architecture Overviewโ
Frontend: Everything the User Seesโ
Frontend is everything that appears on screen when a user opens your website or app. It's powered by three "languages":
HTML โ the skeleton. Determines what content is on the page, like framing a house first. <h1> is a heading, <p> is a paragraph, <button> is a button.
CSS โ the clothes. Determines how things look โ colors, sizes, spacing, border radius. The same button can be red with rounded corners or blue with sharp corners, all thanks to CSS.
JavaScript โ the muscles and brain. Makes the page "come alive." Click a button to pop up a dialog, scroll to load more content, real-time input validation โ that's all JS. Without it, a webpage is just a static poster.
Here's an example โ click the button and the text changes:
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: sans-serif; text-align: center; padding-top: 80px; }
button { background: #ff6b35; color: white; border: none;
padding: 12px 24px; border-radius: 8px; font-size: 16px; }
</style>
</head>
<body>
<h1>Hello, World!</h1>
<p id="msg">Haven't clicked yet...</p>
<button onclick="changeText()">Click Me</button>
<script>
function changeText() {
document.getElementById('msg').innerText = '๐ You just wrote your first line of JavaScript!';
}
</script>
</body>
</html>
Save it as an .html file, open it in a browser, and click the button โ that's the frontend trio working together.
Backend: The Secrets of the Kitchenโ
The backend is the logic users never see. It typically does three things:
- Business logic: After an e-commerce order, calculate the price, check inventory, apply coupons, generate an order number
- API endpoints: The frontend "requests" data from the backend through "endpoints." Like telling a waiter "I'll have the braised pork"
- Access control: Who can see what data and perform what actions โ the backend decides
Request/Response: A Back-and-Forthโ
Frontend (Customer) Backend (Kitchen)
โโโ "I'll have braised pork" (Request) โโโ โ
โ โ Processing...
โโโโ "Braised pork ready" (Response) โโโโโโโ
REST API: A Standardized Way to "Order"โ
REST API uses HTTP verbs to express what you want to do:
| Action | HTTP Method | Example |
|---|---|---|
| Read | GET | GET /api/users โ fetch user list |
| Create | POST | POST /api/users โ create a new user |
| Update | PUT | PUT /api/users/123 โ update a user |
| Delete | DELETE | DELETE /api/users/123 โ delete a user |
Think of it like a restaurant's standardized menu โ each dish has a fixed number and preparation method, so it tastes the same no matter who cooks it. Common backend languages include Python, Node.js (JavaScript), Java, and Go. AI coding most commonly uses Python and Node.js.
Database: The Master of Warehouse Managementโ
A database helps you "remember everything" โ user info, product data, order records โ virtually anything that needs to persist lives here.
SQL vs NoSQLโ
Relational databases (SQL) โ MySQL, PostgreSQL โ work like Excel spreadsheets:
โโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโฌโโโโโโ
โ ID โ Name โ Email โ Age โ
โโโโโโผโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโค
โ 1 โ Alice โ alice@example.com โ 25 โ
โ 2 โ Bob โ bob@example.com โ 30 โ
โโโโโโดโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโดโโโโโโ
Each row is a record; each column is a field. Multiple tables are linked by IDs. Queries use SQL:
SELECT * FROM users WHERE age > 25;
Non-relational databases (NoSQL) โ MongoDB โ work more like JSON files, more flexible:
{ "name": "Alice", "email": "alice@example.com", "hobbies": ["coding", "running"] }
SQL is like a rigid table where every record follows the same format; NoSQL is freer โ each record can have different fields.
Beginner recommendation: Use Supabase (built on PostgreSQL) or Firebase (built on NoSQL). They abstract away the complexity โ you can get started without learning SQL.
User Authentication: Never Build It Yourselfโ
Login is formally called "Authentication." It involves an enormous number of concerns: password hashing, verification emails, password reset flows, third-party login, token management, brute-force protection, CSRF/XSS preventionโฆ every single one is a potential security vulnerability.
So, never write your own login system. Use established authentication services:
- Supabase Auth: Seamlessly integrates with Supabase database; free tier is enough for personal projects
- NextAuth.js / Auth.js: The perfect Next.js companion; built-in support for dozens of third-party logins
- Clerk: Best-looking UI, nearly zero-code integration
What Is OAuth? How "Sign in with Google" Worksโ
- User clicks "Sign in with Google"
- Redirected to Google's page to confirm authorization
- Google sends a "pass" (Token) back to your website
- Your website uses the pass to fetch the user's basic info
Throughout this process, the user never gives you their Google password โ that's the elegance of OAuth.
How Do They All Work Together?โ
Let's trace a "user likes a post" action through the full flow:
โ User clicks the "๐ Like" button (frontend interaction)
โ
โก JS captures the click, sends request: POST /api/posts/123/like
Request header includes Token to prove identity (frontend โ backend)
โ
โข Backend receives the request:
- Verify Token โ Who is this user?
- Check rules โ Already liked?
- Write to database โ INSERT INTO likes (user_id, post_id)
โ
โฃ Database returns result (database โ backend)
โ
โค Backend returns response: { "success": true, "likeCount": 42 }
(backend โ frontend)
โ
โฅ JS receives the response, updates page: button changes to "๐ Liked", number 41โ42
โ
Done!
The entire process takes under 1 second. When writing code with AI, you need to understand that "liking" involves four layers โ frontend interaction, network request, backend logic, and database operation โ so you can give AI the right instructions.
Common Tech Stack Combinationsโ
A "tech stack" is your chosen set of tools โ like picking ingredients for a dish. Chinese cooking uses a wok and soy sauce; Western cooking uses an oven and butter.
LAMP (Old-School Classic): Linux + Apache + MySQL + PHP. The powerhouse of the 2000s โ WordPress is built on it. Rarely used for new projects today.
MEAN/MERN (Full-Stack JavaScript): MongoDB + Express + Angular/React + Node.js. Frontend and backend both in JS โ one language to rule them all. Great for small teams shipping fast.
Next.js + Supabase (AI Coding's Top Pick):
Next.js (Frontend + Backend in one)
โโโ Frontend: React components + Tailwind CSS
โโโ Backend: API Routes / Server Actions
โโโ Connects to Supabase
โโโ Database: PostgreSQL
โโโ Auth: User authentication
โโโ Storage: File storage
Two tools to handle everything from UI to database, with free tiers. The go-to combo for indie developers and AI coders.
Quick Tech Glossary (20 Terms)โ
| Term | One-Line Explanation |
|---|---|
| Frontend | Everything the user sees and interacts with |
| Backend | Logic running on the server that users never see |
| Database | Where data is stored and managed |
| API | A "standard interface" for programs to communicate |
| Server | An always-on computer running your backend code |
| Framework | Pre-built tools and rules to help you code faster |
| Library | A collection of ready-made code you can use as needed |
| Deployment | Putting code on a server so the world can access it |
| Domain | A website's address, like google.com |
| HTTPS | Encrypted secure connection โ the ๐ before a URL |
| Token | A "pass" after login that proves "I am who I say I am" |
| Component | A self-contained module of a frontend page, like building blocks |
| Routing | Deciding which page to display based on the URL |
| Responsive | A page that automatically adapts to different screen sizes |
| SDK | A toolkit provided by a service to make integration easier |
| Package/Dependency | Someone else's pre-built tool โ install and use |
| Terminal | A text-based interface for giving commands to your computer |
| Git | A version control tool that tracks every change to your code |
| Open Source | Code that's publicly available and free for anyone to view and use |
| Async | A programming style of "you go ahead, tell me when you're done" |
Tech fundamentals are like learning the city layout before learning to drive โ you don't need to know every street name, but you need the big picture. Frontend is the storefront, backend is the factory, database is the warehouse, and they collaborate through APIs to get things done. With this foundation, you won't get lost when we dive into frameworks and tools.