CYDERCODER // PLAYBOOK
SYS.STATUS: OK 00%
> INITIALIZING...
Install this playbook for offline access
You're offline — reading cached content
WHO THIS IS FOR

Built for every stage of the builder journey

Beginners

Clear path from zero to deployed product in one afternoon. Exact AI prompts to copy. Explains the why, not just the how — all the way to production with a custom domain.

  • Build your first website end-to-end
  • Deploy with Vercel, set up Google Search Console
  • Understand what React is doing behind the scenes

Senior Devs

A reference manual for AI architecture decisions. RAG chunking, MCP, multi-agent systems, CDN caching, deployment strategies — without the fluff.

  • RAG chunking strategies, MCP protocol architecture
  • Typography scale, color theory, motion design systems
  • CDN caching, edge functions, deployment strategies
Portrait Lock Active
Please rotate your device back to Portrait orientation to read the playbook content.
Back to Dashboard

Global Infrastructure: How the Internet Works

01. The Request-Response Lifecycle

Every digital interaction begins with a boundary: the division between the Client (browser, mobile app, frontend) and the Server (remote machine holding logic and data).

When a user clicks a button, types a search, or loads a page, a structured lifecycle executes across the network:

Step 1DNS ResolutionDomain → IP
Step 2TCP HandshakeEstablish connection
Step 3HTTP RequestMethod, headers, body
Step 4HTTP ResponseStatus, headers, body
Step 5Connection CloseOr keep-alive

The HTTP Methods

Every request carries a method — the verb that tells the server what you want to do:

MethodPurposeHas Body?Idempotent?Example
GETRead dataNoYesFetch user profile
POSTCreate dataYesNoSubmit a form, create account
PUTReplace dataYesYesUpdate entire user profile
PATCHPartial updateYesYesChange just the email field
DELETERemove dataYesYesDelete a comment

Idempotent means calling it 10 times has the same effect as calling it once. GET is idempotent — fetching a page 10 times doesn’t create 10 copies. POST is not — submitting a form 10 times creates 10 records.

Status Codes: The Server’s Language

The server communicates the outcome of every request through a three-digit status code:

RangeCategoryCommon CodesMeaning
2xxSuccess200 OKRequest succeeded
201 CreatedResource created successfully
204 No ContentSuccess, but no body returned (e.g., DELETE)
3xxRedirect301 Moved PermanentlyResource moved permanently (SEO transfers rank)
302 FoundTemporary redirect
304 Not ModifiedUse cached version (saves bandwidth)
4xxClient Error400 Bad RequestMalformed syntax, missing fields
401 UnauthorizedNot authenticated (no valid credentials)
403 ForbiddenAuthenticated but not authorized (no permission)
404 Not FoundResource doesn’t exist
429 Too Many RequestsRate limited
5xxServer Error500 Internal Server ErrorSomething broke on the server
502 Bad GatewayUpstream server returned invalid response
503 Service UnavailableServer overloaded or down for maintenance

The Senior Rule: Never return 200 for an error. Never return 500 for a missing resource (that’s a 404). Status codes are a contract — your clients, load balancers, and monitoring tools depend on them being accurate.


02. DNS (Domain Name System): The Internet’s Phonebook

Computers route traffic through numerical IP addresses (192.0.2.1 or IPv6 equivalents). DNS is the globally distributed translation layer that converts human-readable domains into machine routing targets.

The Resolution Chain

When a user types cydemy.com into their browser:

1. Browser Cache
Local browser checks first
”Do I already know this IP address?“
2. OS Cache
Operating system cache
”Does the OS have this cached?“
3. Router Cache
Local router cache
”Does the router know this domain?“
4. ISP Resolver
ISP DNS server
”Does my internet provider know?“
5. Root Server
13 root clusters worldwide
”Who handles .com domains?” → directs to TLD server
6. TLD Server
Top-Level Domain registry
”Who owns cydemy.com?” → directs to authoritative nameserver
7. Authoritative NS
Cloudflare, Namecheap, etc.
”Here’s the IP: 192.0.2.1”
8. Connect
Browser connects via TCP
TCP connection to 192.0.2.1:443

Total time: Typically 20-120ms for the first lookup. Subsequent lookups are cached at various levels, taking <1ms.

DNS Record Types

RecordPurposeExample
AMaps domain to IPv4 addresscydemy.com → 192.0.2.1
AAAAMaps domain to IPv6 addresscydemy.com → 2606:4700::1
CNAMEAlias pointing to another domainwww.cydemy.com → cydemy.com
MXMail server for the domaincydemy.com → mail.protonmail.ch
TXTArbitrary text (domain verification)google-site-verification=abc123
NSNameserver for the domaincydemy.com → ns1.cloudflare.com
SRVService location (port + protocol)_sip._tcp.cydemy.com → sip.cydemy.com:5060

TTL (Time to Live)

Every DNS record has a TTL — how long (in seconds) resolvers should cache the answer before asking again.

TTL ValueCache DurationWhen to Use
300 (5 min)Short cacheBefore changing IP addresses
3600 (1 hour)StandardNormal operations
86400 (24 hours)Long cacheStable records that rarely change

The Senior Move: Before changing your server’s IP address, lower the TTL to 300 (5 minutes) 24-48 hours in advance. This ensures the old IP expires from caches quickly when you make the switch. Changing IP with a high TTL means some users hit the old server for hours.

How to Check DNS

You can check DNS resolution using online tools or command line:

Online tools:

  • dnschecker.org — Shows resolution from 100+ global locations
  • whatsmydns.net — Visual map of DNS propagation worldwide

Command line (if you’re comfortable):

  • dig domain.com — Shows the full DNS resolution chain
  • nslookup domain.com — Simpler alternative for quick lookups

03. HTTP vs HTTPS: The Encryption Wall

Standard HTTP transmits data in plain text. If a user enters their password on an HTTP page, anyone on the same Wi-Fi network can read it with a basic packet sniffer.

HTTPS wraps HTTP inside a TLS (Transport Layer Security) cryptographic tunnel. Every byte is encrypted end-to-end.

The TLS Handshake

Step 1Client → Server
ClientHello
”I support TLS 1.3, these ciphers”
Step 2Server → Client
ServerHello + Certificate
”Here’s my SSL cert + public key”
Step 3Client → Server
Key Exchange
Client generates session key, encrypts with server’s public key, sends it back
Step 4Both
Finished — Encrypted Communication
Both sides switch to symmetric encryption. Every packet is unreadable to interceptors.

Why the complexity? The server’s public key can encrypt data, but can’t decrypt it. Only the private key can decrypt. So the client generates a temporary symmetric key (which is fast), encrypts it with the public key (so only the server can read it), and now both sides share a secret key for fast symmetric encryption.

Certificate Types

TypeValidation LevelCostUse Case
DV (Domain Validation)Proves you own the domainFree (Let’s Encrypt)Most websites
OV (Organization Validation)Proves your organization exists$50-200/yearBusiness sites
EV (Extended Validation)Full legal entity verification$200-1000/yearBanks, enterprise

For 99% of projects: Use Let’s Encrypt (free DV certificates). They’re trusted by all browsers, auto-renew, and cost nothing.

HSTS (HTTP Strict Transport Security)

HSTS tells the browser: “Never connect to this domain over HTTP — always use HTTPS, even if the user types http://.”

The header: Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

This tells the browser to enforce HTTPS for 1 year (31536000 seconds), include all subdomains, and submit the domain to the HSTS preload list.

The rule: Once you enable HSTS, you cannot easily go back to HTTP. Make sure HTTPS works perfectly before setting this header.


04. CORS (Cross-Origin Resource Sharing): The Browser’s Bouncer

Every frontend engineer eventually hits the dreaded error: Access to fetch at '...' from origin '...' has been blocked by CORS policy.

The Mental Model: CORS is not a server error. It is a browser security mechanism. Your server didn’t block the request — the user’s browser blocked the frontend from reading the response because the server didn’t explicitly grant permission.

Why CORS Exists

Without CORS, any malicious website could make requests to your bank’s API using your cookies. The browser would send your session cookie automatically, the bank’s server would respond with your account data, and the malicious site could read it. CORS prevents this by requiring the server to explicitly say “I trust this origin.”

The Same-Origin Policy

A same-origin request means the protocol, hostname, and port all match:

FrontendAPIResult
https://cydemy.comhttps://api.cydemy.comDifferent hostname = CORS applies
https://cydemy.comhttps://cydemy.com:3001Different port = CORS applies
https://cydemy.comhttp://cydemy.comDifferent protocol = CORS applies

The Preflight Handshake

For “complex” requests (POST with JSON body, custom headers, PUT, DELETE), the browser fires a hidden preflight request first:

Step 1Browser → Server
OPTIONS /api/users (Preflight)
Origin: https://cydemy.com, Request-Method: POST, Request-Headers: Content-Type
Step 2Server → Browser
200 OK — Preflight Approved
Allow-Origin: https://cydemy.com, Allow-Methods: POST, GET, DELETE, Max-Age: 86400
Step 3Browser → Server
POST /api/users (Actual Request)
Browser sends the real request only if preflight was approved

Common CORS Headers

HeaderWhat It Does
Access-Control-Allow-OriginWhich origins can read the response (* or specific URL)
Access-Control-Allow-MethodsWhich HTTP methods are allowed (GET, POST, PUT, DELETE)
Access-Control-Allow-HeadersWhich custom headers are allowed (Authorization, Content-Type)
Access-Control-Allow-CredentialsWhether cookies/auth headers can be sent
Access-Control-Max-AgeHow long to cache the preflight result (seconds)
Access-Control-Expose-HeadersWhich response headers the frontend can read

Solutions When You Control the Server

Tell your AI tool: “Add CORS middleware that only allows requests from my frontend URL. Allow GET, POST, PUT, DELETE methods. Allow credentials (cookies). Cache preflight for 24 hours.”

Solutions When You Don’t Control the Server

Tell your AI tool: “Set up a proxy route that forwards requests from /api/* to the external API URL. This avoids CORS issues by making requests from the same origin.”

The Senior Rule: CORS errors in development are almost always because you’re running frontend on localhost:3000 and API on localhost:4000 — different ports = different origins. Add your dev origin to the CORS whitelist.


05. HTTP/2 & HTTP/3: The Modern Protocol

HTTP/1.1: The Old Way

Each request opens a new TCP connection (or reuses one with keep-alive). Only one request can use a connection at a time — this is called head-of-line blocking. If one request is slow, everything behind it waits.

HTTP/2: Multiplexing

HTTP/2 allows multiple requests and responses to travel simultaneously over a single TCP connection using binary frames.

HTTP/1.1 vs HTTP/2:

  • HTTP/1.1: Requests queue one at a time — if one is slow, everything behind it waits
  • HTTP/2: Requests travel simultaneously over one connection — no queuing

Impact: Pages with 50+ resources load dramatically faster because requests don’t queue.

HTTP/3: QUIC Protocol

HTTP/3 replaces TCP with QUIC (built on UDP). This eliminates head-of-line blocking at the transport layer — if one packet is lost, only that stream is affected, not all of them.

HTTP/2 vs HTTP/3:

  • HTTP/2: Packet loss blocks ALL streams (they share one TCP connection)
  • HTTP/3: Packet loss only affects the specific stream that lost data

Adoption: Cloudflare, Google, and most modern CDNs support HTTP/3. You get it for free when deploying behind Cloudflare or Vercel.


06. WebSockets vs. SSE vs. REST: Real-Time Patterns

Standard HTTP is stateless and unidirectional — the client asks, the server responds, the connection closes. For real-time features, you need persistent connections.

The Three Patterns

REST (Polling):
  Client ──[Request]──▶ Server ──[Response]──▶ Close
  Client ──[Request]──▶ Server ──[Response]──▶ Close
  Client ──[Request]──▶ Server ──[Response]──▶ Close
  (Wasteful — most responses say "nothing changed")

WebSocket (Bi-directional):
  Client ◀══════════ Persistent Pipe ══════════▶ Server
  Either side can push data at any time

SSE (Server → Client):
  Client ──[Request]──▶ Server
  Client ◀══════════ Event Stream ═══════════════ Server
  (Server pushes, client listens — one-way)

WebSockets

A persistent, bi-directional TCP connection. Either side can send data at any time with zero HTTP overhead.

// Client — Connect to WebSocket server
const ws = new WebSocket('wss://api.example.com/ws');

ws.onopen = () => {
  console.log('Connected');
  ws.send(JSON.stringify({ type: 'subscribe', channel: 'prices' }));
};

ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  updatePriceDisplay(data);
};

ws.onclose = () => {
  console.log('Disconnected — reconnecting in 3s...');
  setTimeout(reconnect, 3000);
};

Use WebSockets when: Both sides need to push data frequently (chat, multiplayer games, live collaboration, real-time trading).

To build a WebSocket server, tell your AI tool: “Create a WebSocket server that allows clients to subscribe to channels. When a client subscribes, send them live data every second. Use the ws library.”

Server-Sent Events (SSE)

A one-way persistent connection where the server pushes events to the client. Simpler than WebSockets, works over standard HTTP, and auto-reconnects.

Use SSE when: Only the server needs to push data (live feeds, notifications, progress updates).

To build SSE, tell your AI tool: “Create an SSE endpoint at /api/events that sends a heartbeat every second. Set the correct headers for event streaming.”

req.on(‘close’, () => clearInterval(interval)); });


**Use SSE when:** Only the server needs to push data (live feeds, notifications, progress updates, activity logs).

### When to Use What

| Pattern | Direction | Connection | Auto-Reconnect | Best For |
|---------|-----------|------------|----------------|----------|
| **REST** | Client → Server | New per request | N/A | CRUD operations, form submissions |
| **WebSocket** | Bi-directional | Persistent TCP | No (manual) | Chat, games, collaboration |
| **SSE** | Server → Client | Persistent HTTP | Yes (built-in) | Feeds, notifications, dashboards |
| **Polling** | Client → Server | New per request | N/A | Legacy systems, simple intervals |

### Senior Moves

1. **Prefer SSE over WebSockets** for one-way data (dashboards, feeds). SSE is simpler, works over standard HTTP, and handles reconnection automatically.
2. **WebSockets need a stateful server.** Each connection is a persistent session. This complicates horizontal scaling — you need sticky sessions or a message broker (Redis Pub/Sub).
3. **Never use polling for real-time.** Requesting "anything new?" every 5 seconds wastes bandwidth and server resources. Use SSE or WebSockets.
4. **Implement heartbeat/ping.** WebSocket connections can silently die (NAT timeouts, network switches). Send a ping every 30s and close the connection if no pong arrives.

---

## 07. HTTP Caching: The Performance Multiplier

Every request to your server costs time and bandwidth. Caching stores copies of responses so subsequent requests are served instantly without hitting your server.

### The Caching Headers

```http
# Server response headers that control caching

Cache-Control: public, max-age=3600          # Cache for 1 hour
Cache-Control: private, no-cache              # User-specific, always revalidate
Cache-Control: no-store                       # Never cache (sensitive data)
ETag: "a1b2c3d4"                             # Unique hash of the response
Last-Modified: Tue, 15 Jul 2026 10:00:00 GMT  # When the resource last changed

Cache-Control Directives

DirectiveMeaning
publicAny cache can store this (CDN, browser, proxy)
privateOnly the user’s browser can cache this (not CDN)
no-cacheCache it, but always revalidate with server before using
no-storeDon’t cache at all (banking, medical data)
max-age=NCache is valid for N seconds
s-maxage=NCDN cache valid for N seconds (overrides max-age for CDN)
stale-while-revalidate=NServe stale cache while fetching fresh copy in background

The Caching Strategy

Static Assets (CSS, JS, images, fonts)
  → Cache-Control: public, max-age=31536000, immutable
  → Filename includes hash: /assets/style.a1b2c3.css
  → Never changes — cache forever

API Responses (user-specific)
  → Cache-Control: private, no-cache
  → ETag included for revalidation
  → Browser always checks with server

API Responses (public, semi-static)
  → Cache-Control: public, max-age=3600
  → Stale-while-revalidate: 86400
  → CDN caches for 1 hour, serves stale while refreshing

Sensitive Data (tokens, medical records)
  → Cache-Control: no-store
  → Never cached, ever

CDN Caching

A Content Delivery Network (Cloudflare, Vercel Edge, AWS CloudFront) caches your static assets at edge locations worldwide. A user in Tokyo gets assets from the Tokyo edge node, not your server in Virginia.

ScenarioDistanceLatency
Without CDNTokyo → Virginia → Tokyo~400ms round trip
With CDNTokyo → Tokyo Edge Node~40ms round trip (10x faster)

CDNs are free with Cloudflare and Vercel. There’s no reason not to use one.


Key Takeaways

ConceptMental ModelSenior Insight
Request-ResponseClient asks, server answers, connection closesHTTP methods are a contract — GET reads, POST creates, DELETE removes
DNSDomain → IP translation chainLower TTL 48h before IP changes to avoid stale caches
TLS/HTTPSEncrypted tunnel over plain HTTPUse Let’s Encrypt (free), enable HSTS after verifying HTTPS works
CORSBrowser’s bouncer, not server’s blockDifferent port = different origin = CORS applies
HTTP/2Multiplexing over single connectionEliminates head-of-line blocking — critical for asset-heavy pages
HTTP/3QUIC protocol over UDPPacket loss only affects one stream, not all
WebSocketsPersistent bi-directional pipeNeed sticky sessions or Redis for horizontal scaling
SSEServer-push over HTTPSimpler than WebSockets, auto-reconnects, works through proxies
CachingStore responses to avoid re-fetchingStatic assets: cache forever with hashed filenames. Sensitive data: never cache
CDNEdge nodes serve assets locally10x latency improvement for global users — free with Cloudflare/Vercel