Skip to main content

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:

ActionHTTP MethodExample
ReadGETGET /api/users โ€” fetch user list
CreatePOSTPOST /api/users โ€” create a new user
UpdatePUTPUT /api/users/123 โ€” update a user
DeleteDELETEDELETE /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โ€‹

  1. User clicks "Sign in with Google"
  2. Redirected to Google's page to confirm authorization
  3. Google sends a "pass" (Token) back to your website
  4. 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)โ€‹

TermOne-Line Explanation
FrontendEverything the user sees and interacts with
BackendLogic running on the server that users never see
DatabaseWhere data is stored and managed
APIA "standard interface" for programs to communicate
ServerAn always-on computer running your backend code
FrameworkPre-built tools and rules to help you code faster
LibraryA collection of ready-made code you can use as needed
DeploymentPutting code on a server so the world can access it
DomainA website's address, like google.com
HTTPSEncrypted secure connection โ€” the ๐Ÿ”’ before a URL
TokenA "pass" after login that proves "I am who I say I am"
ComponentA self-contained module of a frontend page, like building blocks
RoutingDeciding which page to display based on the URL
ResponsiveA page that automatically adapts to different screen sizes
SDKA toolkit provided by a service to make integration easier
Package/DependencySomeone else's pre-built tool โ€” install and use
TerminalA text-based interface for giving commands to your computer
GitA version control tool that tracks every change to your code
Open SourceCode that's publicly available and free for anyone to view and use
AsyncA 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.