GetClaps
Ücretsiz DenetimFiyatlandırmaSözlükAkademi
  1. Ana sayfa
  2. /Akademi
  3. /L01 · The big picture: what we are building and how the pieces fit

Ana sayfa / Akademi / L01 · The big picture: what we are building and how the pieces fit

L01Bölüm A · TemellerTemelKod doğrulama tarihi: 2026-12-04

The big picture: what we are building and how the pieces fit

How the product's seven runtime parts, fourteen packages, design triad and five status words fit together without hiding risk.

22 dk·4326 kelime·6 soru·33 terim·docs/lessons/01-the-big-picture.md
Tüm derslere dön
●

Ders içerikleri İngilizce yayınlanır (OD-23)

Sayfa çerçevesi Türkçe ve İngilizce olarak sunulur. Teknik ders metinleri, kod örnekleri ve kendini sına soruları doğrudan ortak kaynak dosyalarından İngilizce okunur; hukuk ve ürün terimlerinde Türkçe karşılıklar yer alır.

0%
▲Yanıtlanan sorular
0 / 6
—
○Doğruluk oranı
Henüz yanıt yok

Bu dersteki bölümler

  1. 1.Why this matters
  2. 2.The ideas
  3. 3.How this repository does it
  4. 4.What went wrong once
  5. 5.Try it yourself
  6. 6.Check yourself
  7. 7.Words to know
  8. 8.Go deeper

Why this matters

If you cannot draw a system on one sheet of paper, you cannot tell whether a new feature strengthens the product or just adds noise. For a founder, the risk is paying weeks of engineering time for extra screens while the core customer journey still cannot run from start to finish. That exact failure happened here: in seven days the repository grew to roughly 980,000 lines, 93 API route files, 31 public pages, 58 UI primitives and 28 read-only preflight calculators, yet nobody could sign in, connect an ad account or send a real conversion event. The independent review of 2 December 2026 caught the gap, and owner decision OD-18 redirected every wave that followed onto one real end-to-end path. When you understand the map of this system and the five status words, you can look at any folder or status update and know immediately what exists, what is proven and what is still missing.

The ideas

One owned operating ledger, eight hard rules and twelve refusals

Every small business running paid advertising faces a common trap: separate tools hold web events, ad campaigns, customer leads and SEO reports, while an agency often holds the logins. When the contract ends, years of audience and conversion history leave with the agency.

This product replaces that sprawl with one business-owned operating ledger. Ad spend, server-side signals, a closed-loop customer pipeline and five SEO tasks live inside one workspace that belongs strictly to the business. An outside specialist works inside owner-set limits without ever holding accounts or cash.

Two lists in the product frame turn that thesis into concrete boundaries: eight hard rules (R1 to R8) and twelve refusals (N1 to N12).

Rule or refusalPlain meaningMistake it stops
R1, N1 (account sovereignty)Business owns ad accounts, pixels, shop and CRM; zero password sharing; one-click revokeAgencies holding accounts hostage
R290-second read-only audit before any credit cardPaywalling an empty screen
R3, N6Dual Meta CAPI and Google Data Manager with separate hashing behind a hard consent gateBroken match quality or unconsented data dispatch
R4, N2Neither marketers nor AI spend directly; every binding change uses an expiring SHA-256 preview approved by the ownerOvernight spend spikes from unchecked clicks or black-box automation
R5, N7, N8Marketer badges come from read-only APIs and safeguarded payment records; the product never promises a guaranteed ROASEdited screenshots, fake star scores and false return claims
R6, N3–N5, N11One-click cancel, zero ad-spend markup, licensed iyzico Pazaryeri safeguarded payments, verified company billingPooling client cash illegally or phone cancellation traps
R7Moving a consented CRM deal to qualified or won queues conversion feedback in the same transactionAd platforms optimizing for junk leads
R8, N12At most five SEO tasks from an isolated crawler instead of 400 raw rowsDashboard sprawl

A common mistake is treating product rules as marketing slogans. Here, every rule above maps to code, database checks or automated gates covered in later lessons.

Who uses it and the five places

A small-business tool breaks down when every user holds the same privileges or navigation sprawls across fourteen tabs. This product separates two roles and five calm places:

  • The business owner owns the workspace, connects OAuth accounts, sets daily ceilings and step caps, toggles the kill switch, approves proposals, releases safeguarded payments and revokes access in one click.
  • The hired marketer works inside a time-bound, scoped grant, inspects diagnostics, proposes changes into the approval queue and never sees OAuth vault tokens or billing controls.

Signed-in navigation exposes five places plus a Settings icon:

  1. Overview (Özet): 30-day spend, verified revenue, signal health, kill-switch status and pending approvals.
  2. Signals and Connections (Sinyal & Bağlantılar): OAuth connections, signal studio and live event debugger.
  3. Marketers (Uzmanlar): vetted specialist dossiers and safeguarded-payment engagements.
  4. Customers (Müşteriler): closed-loop CRM pipeline feeding consented sales back to ad platforms.
  5. SEO (SEO): Core Web Vitals, Search Console summary and at most five prioritized fixes.

Advanced modules (profit margins, AI copy proposals, raw ingest inspection) open one click beneath their parent place. This lesson covers the map only; sign-in and roles belong to lesson 04.

The seven runtime parts and what each may touch

Think of a restaurant kitchen that separates the front counter, the cash register, the locked safe and the delivery scooter. If a stranger walks up to the front counter, they cannot open the safe because the counter clerk does not even hold the key. Software architecture uses the same idea: split the running system into a small number of distinct processes so a bug in one part cannot automatically compromise every secret.

That analogy stops being exact at one point: in software, splitting into too many tiny services creates more network failures and operational drag than a small team can handle. That is why bounded architecture keeps this entire system to seven well-defined runtime pieces rather than dozens of microservices.

text
Browser (Owner / Marketer / Shopper)
   |                           |
   | HTTPS pages               | Tracking beacon
   v                           v
[1. Web App (apps/web)]     [6. Edge Collector (apps/collector)]
   | HTTP JSON only            | Signed HTTPS batch
   v                           v
[2. API Server (apps/api/src/server.ts)] -----> Meta Graph API (test budget execution)
   | app login + vault login
   v
[3. PostgreSQL 18 Database] <---- [4. Background Worker (worker-main.ts)] (app login only)
   ^
   | app login + vault login
[5. Dispatch Process (dispatch-main.ts)] -----> Meta CAPI & Google Data Manager

[7. SEO Crawler (apps/seo-worker)] -----> Public shop URLs only (zero DB or vault secrets)

Each of the seven runtime parts has a strict job and an explicit list of what it must never touch:

Runtime partJobMay touchMust never touch
1. Web appRenders Turkish and English screens in Next.jsBrowser HTTP calls to the API and closed UI primitivesPostgreSQL directly, OAuth vault tokens, raw secrets
2. API serverHandles auth, workspace routes, approvals and Meta budget executionApp database login, vault login and master key when configuredUnverified client totals or direct browser DOM
3. PostgreSQL 18 databaseStores tenant rows, auth sessions, vault ciphertexts and audit logTenant rows filtered by forced row-level security; separate auth and vault schemasCalling external ad APIs directly
4. Background workerRuns database housekeeping and queue sweepingApp database login only (DATABASE_URL)Vault database login, vault master key or live ad-platform delivery
5. Dispatch processSends stored conversion events and refreshes OAuth tokensApp database login plus vault login and master keyServing public browser HTTP requests
6. Edge collectorReceives storefront and browser events, hashes personal data and signs batchesPublic event payloads and edge signing secretPostgreSQL, vault secrets or raw long-term PII storage
7. SEO crawlerFetches public shop pages and runs technical SEO checksPublic HTTPS targets checked by SSRF guardsAny database URL, vault key, payment key or ad-platform secret

The most common mistake in early web apps is letting the frontend framework query the database directly or giving every background worker full database superuser access. Separating the vault-less worker from the dispatch process and blocking every secret at startup inside the SEO crawler shrinks the blast radius if any single component fails.

Three journeys end to end

Tracing three real journeys shows how the seven parts cooperate across boundaries.

Journey 1: a page request

When a signed-in owner opens /w/{workspaceId}/overview, the frontend asks the backend API for workspace data.

text
Browser -> Web App (reads workspaceId from URL)
        -> API GET /v1/w/:workspaceId/overview (checks session cookie + role)
        -> PostgreSQL (sets transaction-local workspace context)
        -> API returns JSON DTO (Cache-Control: no-store) -> Web App renders

The workspace ID stays in the URL so two open tabs for two shops never mix, and the web app never queries PostgreSQL directly.

Journey 2: a tracked event

text
Shopper browser -> Edge Collector (hashes email/phone per platform, signs batch)
                -> API ingest endpoint (verifies signature + consent gate, stores row)
                -> Dispatch Process (claims row, decrypts token from vault, sends to Meta/Google)
                -> PostgreSQL updated with delivery receipt (or skipped_no_consent)

Platform-specific hashing and consent rules belong to lesson 07; vault encryption belongs to lesson 05.

Journey 3: an approval

text
Marketer -> API POST /v1/w/:workspaceId/approvals (checks ceilings, hashes payload, stores pending row)
Owner    -> Reviews Approval Drawer (exact integer diff, expiry timer, SHA-256 preview)
Owner    -> Approves with step-up -> API re-verifies hash, expiry, ceiling and kill switch
         -> API reads Meta budget, writes new budget, reads back to confirm -> Audit log receipt

Re-verifying the hash and ceilings on the server stops any browser tamper after approval. The full approval state machine and crash recovery belong to lesson 08.

The map of the repository

This codebase is structured as a monorepo: one Git repository holding all applications, shared libraries, design contracts, documentation, verification tools and tests together. One commit can update a shared library and every app that depends on it at the same time.

Top-level folderWhat lives thereExample
apps/The four runnable applicationsapps/web, apps/api, apps/collector, apps/seo-worker
packages/Ten shared internal libraries imported by appspackages/db, packages/vault, packages/approvals, packages/ui, packages/signals
design/The product frame, all UI copy, design decisions, visual tokens and prototypesdesign/FRAME.md, design/WORDS.md, design/DECISIONS.md
docs/Architecture records, schema, OpenAPI contract, runbooks, owner decisions, wave reports and lessonsdocs/schema.sql, docs/openapi.yaml, docs/adr/, docs/lessons/
tools/Zero-dependency verification runner, static gates, learning builder and local dev stacktools/verify, tools/gates.manifest.json, tools/learning/build.mjs
tests/Cross-cutting contract, security fuzz, chaos, load and real-browser journey suitestests/contracts/, tests/security/, tests/browser/

A typical newcomer mistake is editing generated outputs directly or putting product copy inside packages/ui. Knowing the folder roles tells you immediately where a change belongs: shared UI parts live in packages/ui with zero product strings, user-facing strings start in design/WORDS.md, and cross-package rules live in packages/.

How decisions are recorded and what the five status words mean

Large projects break down when product rules, legal trade-offs and technical choices live only in someone's memory. This repository records decisions in four linked places:

  1. The design triad under design/: FRAME.md defines product scope and rules, WORDS.md holds every Turkish and English screen string (with the one named exception OD-23 for English lessons and dictionary content), and DECISIONS.md records numbered design decisions (D01 to D40) and founder open questions (Q1 to Q10).
  2. The owner decision register in docs/OWNER-DECISIONS.md, recording business and governance calls (OD-01 onward) that only the two founders can answer.
  3. Ten architecture decision records (0001 to 0010) in docs/adr/, explaining major technical choices such as passwordless sign-in (ADR-0010) and the closed UI kit (ADR-0003).
  4. The root rulebook AGENTS.md, which binds every person and agent with 22 numbered rules, including using the brand slot ({ürün} / {product}) until OD-01 settles the public name.

Finally, every claim about any feature must use one of five exact status words:

  • researched: studied from external sources or competitor evidence, not yet designed or coded.
  • designed: written down in a specification, decision record or contract, not yet coded.
  • built: code exists on the branch, with no claim yet that tests passed.
  • verified: built code passed concrete, recorded checks on a named commit and environment.
  • deployed: running on a real server reachable by owners or customers.

Saying "done" hides the difference between a document, untested code and a live server. Using these five words keeps every conversation grounded in facts.

How this repository does it

Every boundary sketched above is enforced in concrete files on this branch today:

  • Rules and product contract: AGENTS.md lists all 22 repository rules; design/FRAME.md sets out R1 to R8, N1 to N12, the twelve Release 1 screens and the three supporting surfaces; design/WORDS.md holds bilingual screen strings; design/DECISIONS.md and docs/OWNER-DECISIONS.md track D01 to D40, Q1 to Q10 and OD- decisions; docs/adr holds ADRs 0001 to 0010.
  • Workspace packages: pnpm-workspace.yaml registers apps/* (web, api, collector, seo-worker) and packages/* (ai, approvals, auth, connectors, db, payments, shared, signals, ui, vault). If a package boundary were broken—for instance, if apps/web imported packages/db directly—architecture and web-budget checks would fail.
  • API composition root: server.ts is the API composition root. Before opening any HTTP port, loadApiRuntimeConfig validates environment variables (logging codes only, never values), runSchemaGuard verifies the database schema version, and server.ts refuses to start in production if OAUTH_FAKE_PROVIDER_BASE is set. It builds the app database pool (DATABASE_URL), the optional vault pool (VAULT_DATABASE_URL) and the real Meta budget executor (createMetaBudgetExecutor), then passes them to createApiApp in app.ts. Removing this composition root would scatter secret parsing and let production accidentally start with sample memory data or test stubs.
  • Separate background processes: worker-main.ts runs vault-less database queues and hourly housekeeping (auth.cleanup_login_challenges and expired OAuth flow purges) using only DATABASE_URL. dispatch-main.ts runs as the separate least-privilege dispatch process holding DATABASE_URL, VAULT_DATABASE_URL and the vault master key; runDispatchMainCli runs SignalDispatchEngine.runCycle and periodic token refresh (runConnectionRefreshCycle) and refuses the fake provider in production. Removing that split would force the general worker to hold vault credentials unnecessarily.
  • Edge and crawler isolation: app.ts implements the Hono edge collector with CORS, rate limiting and edge hashing; env-guard.ts lists FORBIDDEN_EXACT_ENV_VARS and FORBIDDEN_ENV_PREFIXES (DATABASE_, VAULT_, POSTGRES_, IYZICO_) and aborts apps/seo-worker at startup if any forbidden secret is present. Removing env-guard.ts would remove the startup guarantee that a compromised crawler cannot read database or payment keys.
  • Workspace shell and endpoints: WorkspaceShell.tsx renders the five places and URL-based workspace switcher, while apps/api/src/routes implements every HTTP endpoint described in docs/openapi.yaml.
  • What is true today on this branch: Passwordless sign-in, OAuth ad-account connection (against a production-refused local fake provider), stored event ingest, the dispatch process and the Meta budget approval executor are built and verified locally (and Waves 46 and 47 ran green on GitHub Actions, as recorded in LOG.md).
◆

Not built yet

Nothing in this repository is deployed to a public production server, no real Meta or Google API call has been executed against live customer accounts, and there are zero paying customers. Live deployment waits for private staging verification, external security review (issue 97), Turkish legal and tax counsel sign-off (OD-05, issue 3), database residency confirmation (OD-04), ad-platform app approvals (issue 4) and the founders' explicit sign-off (AGENTS.md rule 22). Release 2 (TikTok, Google Business Profile, Multi-Brand Pro) and Release 3 (global expansion and open public directory) are planned only, not designed or built.

What went wrong once

Breadth outran the critical path

  • What happened: During the first week of rapid parallel building, the repository accumulated roughly 980,000 lines, 93 API route files (including 28 read-only preflight calculators), 31 public pages, 58 UI components and 81 documents. Despite that volume, a real person still could not create an account, sign in, connect a Meta or Google ad account, send a real event or execute an approved budget change.
  • How it was noticed: The independent review recorded in docs/INDEPENDENT-REVIEW-2026-12-02.md checked every core promise from a clean clone instead of judging progress by file counts.
  • Cause in plain words: Earlier checks measured growth by minimum counts (more routes, more pages, more docs), so adding sideways surfaces stayed green while wiring the hard end-to-end journey remained unfinished.
  • Fix: The founders recorded owner decision OD-18 (depth-first engineering, deletion allowed), retired growth-only count checks and focused Waves 46, 47 and 48 on finishing the four-step critical path: sign in, connect an account, deliver a test event and execute one approved budget change.
  • General lesson: Progress is the shortest complete path a real customer can walk from end to end, never the count of screens or documents.

Decisions on paper and the code drifted apart

  • What happened: Early records ADR-0001 and ADR-0004 named Better Auth, pg-boss, Drizzle and Node 26, yet the actual code used none of those libraries and ran on Node 24. Meanwhile README.md had grown into a 124 KB log summary that never told a newcomer how to start the project.
  • How it was noticed: The 2 December 2026 review compared the ADRs and README.md line by line against package.json and the live source code.
  • Cause in plain words: Code evolved quickly while architecture documents were treated as one-time write-only artifacts instead of living records.
  • Fix: In Wave 46 the founders accepted OD-14 and ADR-0010 for passwordless sign-in in own code, amended ADR-0001, ADR-0004 and docs/SYSTEM.md, and placed a short "Start here" section at the top of README.md.
  • General lesson: A decision record that contradicts running code misleads every future contributor; when the code changes, amend the record the same day.

Three finished parts that did not add up to a working sign-in

  • What happened: In Wave 46, three parallel workstreams built auth storage (A), sign-in API routes (B) and login screens (C), and each passed its own tests. Yet taken together, the sign-in routes were not mounted in the app, the development CORS rule blocked the browser's request header, sign-out left new cookies behind and a new workspace fell back to displaying a sample business's name.
  • How it was noticed: Wave 46 included a dedicated wiring workstream (F) whose real-browser journey tested the whole flow in Chromium against the live API and database, recorded in docs/wave46/reports/F-REPORT.md.
  • Cause in plain words: Each part was tested in isolation against stand-ins for the other two parts, and browser rules like CORS preflights only trigger in a real browser.
  • Fix: Workstream F mounted the routes, added the cookie-mutation origin guard, unified token reading into one leaf module, cleared all three cookies on sign-out and proved the full flow with sign-in-journey-e2e.mjs.
  • General lesson: Passing unit tests on separate pieces never proves the pieces work together; integration needs its own owner and an end-to-end test.

Try it yourself

Every step below is read-only and safe to run on Windows. None of these commands touch your running local dev stack on ports 3000, 4000 or 5432, and none call Meta or Google.

Step 1: list the fourteen workspace packages in PowerShell

bash
Get-ChildItem apps, packages -Directory | Select-Object Parent, Name

You should see four directories under apps (api, collector, seo-worker, web) and ten directories under packages (ai, approvals, auth, connectors, db, payments, shared, signals, ui, vault). That list matches pnpm-workspace.yaml and shows the full footprint of the monorepo.

Step 2: inspect the ten architecture decision records in PowerShell

bash
Get-ChildItem docs/adr -File | Select-Object Name

You should see ten numbered Markdown files from 0001-web-first-nextjs-fastify-postgres.md through 0010-durable-sessions-and-passwordless-sign-in.md. Open 0010 to see how a real decision records its context, rejected alternatives and consequences.

Step 3: verify the SEO crawler's startup secret guard in PowerShell

bash
Select-String -Path apps/seo-worker/src/env-guard.ts -Pattern "FORBIDDEN_ENV_PREFIXES|DATABASE_URL|VAULT_DATABASE_URL"

You should see DATABASE_URL, VAULT_DATABASE_URL and FORBIDDEN_ENV_PREFIXES (DATABASE_, VAULT_, POSTGRES_, IYZICO_). This confirms in live code that Zone 3 refuses to start if any database, vault or payment secret is ever injected into its environment.

Step 4: check the verification plan without executing anything in Git Bash

bash
bash tools/verify --list

Git Bash prints the complete ordered list of checks from tools/gates.manifest.json grouped into core, static, suites, postgres, deploy, scanners, build and browser, without starting any server or changing any file. Seeing the plan tells you exactly what "verified" covers on this branch.

Check yourself

0 / 6

Q1.Why does the dispatch process run separately from the general background worker?

Q2.A feature's code is merged on a branch and its local tests passed on your Windows machine, but no server is running it for customers. Which status words accurately describe it?

Q3.Why must every workspace URL include /w/:workspaceId/... instead of storing the active workspace in a session cookie?

Q4.If an attacker tricks the SEO crawler into reading environment variables while scanning a hostile storefront page, why can they not steal customer OAuth tokens?

Q5.What did the 2 December 2026 independent review reveal about building 28 read-only preflight calculators before real sign-in existed?

Q6.A proposed screen needs to show a new Turkish button label and bend hard rule R4 so AI can raise budgets automatically without approval. What must happen first according to AGENTS.md?

Words to know

33
account sovereignty

The rule that the small business always owns its ad accounts, tracking data, storefront and customer records.

Büyük resimSözlükte incele
AGENTS.md

The root rulebook file listing the numbered rules every person and AI agent working in this repository must follow.

Büyük resimSözlükte incele
APIAPI

A defined set of web addresses and rules through which one program asks another program for data or an action.

Büyük resimSözlükte incele
architecture decision recordADR

A short numbered document that records one major technical decision, the alternatives weighed and its consequences.

Büyük resimSözlükte incele
backendTR: arka uç

The server-side part of a software system that stores data, enforces rules and talks to outside platforms.

Büyük resimSözlükte incele
bounded architecture

The discipline of keeping the system small and plain, refusing extra infrastructure until a measured bottleneck demands it.

Büyük resimSözlükte incele
brand slotTR: {ürün}

The placeholder token standing wherever the public brand name will appear until the founders choose the final name.

Büyük resimSözlükte incele
built (status word)

The status word meaning code for a feature exists in the repository, without yet claiming that checks passed or users can reach it.

Büyük resimSözlükte incele
business ownerTR: çalışma alanı sahibi

The person who runs the small business and holds the owner role in its workspace, reading daily numbers and approving changes.

Büyük resimSözlükte incele
composition root

The single startup file where a program reads configuration, builds its components and wires them together.

Büyük resimSözlükte incele
critical pathTR: kritik yol

The shortest end-to-end journey a real customer must be able to complete for the product to deliver its core promise.

Büyük resimSözlükte incele
deployed (status word)

The status word meaning software is running on a live or staging server where real callers or owners can reach it.

Büyük resimSözlükte incele
design decision

One of the numbered product decisions D01 to D40 recorded with its evidence in design/DECISIONS.md.

Büyük resimSözlükte incele
design triad

The three contract documents under design/ that define the product's scope, every screen string and its decisions.

Büyük resimSözlükte incele
designed (status word)

The status word meaning a feature is written down in specifications or contracts but has not been turned into code yet.

Büyük resimSözlükte incele
dispatch process

The separate least-privilege background program that sends stored conversion events to Meta and Google and refreshes OAuth tokens.

Büyük resimSözlükte incele
endpointTR: uç nokta

One specific HTTP method and URL path on the API, answered by one handler function.

Büyük resimSözlükte incele
founder open question

One of the ten foundational questions Q1 to Q10 in design/DECISIONS.md that only the two founders may answer.

Büyük resimSözlükte incele
frontendTR: ön uç

The user-facing part of the product rendered in the web browser, including layouts, forms, copy and keyboard controls.

Büyük resimSözlükte incele
hard rule

One of the eight binding product principles R1 to R8 in design/FRAME.md that no screen, workflow or contract may break.

Büyük resimSözlükte incele
marketerTR: uzman

An outside growth specialist hired by a small business to work inside its workspace under time-bound, revocable access.

Büyük resimSözlükte incele
monorepo

A single Git repository holding all apps, shared packages, documentation and verification tools together.

Büyük resimSözlükte incele
operating ledger

One business-owned system of record uniting ad spend, server-side signals, customer pipeline, SEO tasks and approved actions.

Büyük resimSözlükte incele
owner decisionODTR: kurucu kararı

A numbered business or governance decision recorded with its options and status in docs/OWNER-DECISIONS.md.

Büyük resimSözlükte incele
place (navigation)

One of the five top-level sections a signed-in user navigates between inside a workspace.

Büyük resimSözlükte incele
product frame

The contract file design/FRAME.md defining who uses the product, its twelve screens, eight hard rules and twelve refusals.

Büyük resimSözlükte incele
refusal

One of the twelve explicit boundaries N1 to N12 in design/FRAME.md naming what the product will never build, promise or tolerate.

Büyük resimSözlükte incele
researched (status word)

The earliest status word, meaning a topic was studied from external sources but is neither designed nor coded yet.

Büyük resimSözlükte incele
status word

One of the five required labels—researched, designed, built, verified or deployed—stating how far any capability really is.

Büyük resimSözlükte incele
verified (status word)

The status word meaning built code passed concrete, recorded checks on a named commit and environment.

Büyük resimSözlükte incele
web app

The Next.js application in apps/web that renders every public and workspace screen and talks only to the API.

Büyük resimSözlükte incele
worker

A vault-less background process that executes queued database jobs and periodic housekeeping without blocking user requests.

Büyük resimSözlükte incele
workspaceTR: çalışma alanı

One customer business's isolated space inside the product, separating its data, encryption key, guardrails and user grants.

Büyük resimSözlükte incele

Go deeper

  • Repository rules and product constitution: AGENTS.md, design/FRAME.md, design/DECISIONS.md and docs/OWNER-DECISIONS.md.
  • System overview and decision records: docs/SYSTEM.md, docs/adr/0001-web-first-nextjs-fastify-postgres.md and docs/adr/0010-durable-sessions-and-passwordless-sign-in.md.
  • Real history behind the depth-first shift: docs/INDEPENDENT-REVIEW-2026-12-02.md and LOG.md.
  • Archived lessons this lesson replaces (historical only, not a source of current facts): archived lesson 10, archived lesson 13, archived lesson 16, archived lesson 20 and the archive index.
  • External documentation for core web technologies used here: MDN overview of HTTP, TypeScript documentation, Fastify documentation, Next.js App Router documentation, Cloudflare Workers documentation and OpenAPI Specification.
◆

NOT LEGAL OR TAX ADVICE · Açık karar kapıları dürüstlüğü

Bu müfredat öğrenme amaçlıdır; hukuk veya vergi danışmanlığı değildir. #3 hukuk ve mali müşavir onayı, #21 keşif görüşmeleri, OD-01 marka tescil kontrolü ve canlı dağıtım henüz tamamlanmamıştır. ISO-27001 / SOC 2: UNOBTAINED. Sıfır canlı müşteri veya canlı reklam harcaması iddia edilmez.

Tüm derslere dönSonraki ders: L02

L01 · Part A · foundation · Verified 2026-12-04 · 22 min

The big picture: what we are building and how the pieces fit

How the product's seven runtime parts, fourteen packages, design triad and five status words fit together without hiding risk.

Bu müfredat öğrenme amaçlıdır; hukuk veya vergi danışmanlığı değildir. #3 hukuk ve mali müşavir onayı, #21 keşif görüşmeleri, OD-01 marka tescil kontrolü ve canlı dağıtım henüz tamamlanmamıştır. ISO-27001 / SOC 2: UNOBTAINED. Sıfır canlı müşteri veya canlı reklam harcaması iddia edilmez.

Why this matters

If you cannot draw a system on one sheet of paper, you cannot tell whether a new feature strengthens the product or just adds noise. For a founder, the risk is paying weeks of engineering time for extra screens while the core customer journey still cannot run from start to finish. That exact failure happened here: in seven days the repository grew to roughly 980,000 lines, 93 API route files, 31 public pages, 58 UI primitives and 28 read-only preflight calculators, yet nobody could sign in, connect an ad account or send a real conversion event. The independent review of 2 December 2026 caught the gap, and owner decision OD-18 redirected every wave that followed onto one real end-to-end path. When you understand the map of this system and the five status words, you can look at any folder or status update and know immediately what exists, what is proven and what is still missing.

The ideas

One owned operating ledger, eight hard rules and twelve refusals

Every small business running paid advertising faces a common trap: separate tools hold web events, ad campaigns, customer leads and SEO reports, while an agency often holds the logins. When the contract ends, years of audience and conversion history leave with the agency.

This product replaces that sprawl with one business-owned operating ledger. Ad spend, server-side signals, a closed-loop customer pipeline and five SEO tasks live inside one workspace that belongs strictly to the business. An outside specialist works inside owner-set limits without ever holding accounts or cash.

Two lists in the product frame turn that thesis into concrete boundaries: eight hard rules (R1 to R8) and twelve refusals (N1 to N12).

Rule or refusalPlain meaningMistake it stops
R1, N1 (account sovereignty)Business owns ad accounts, pixels, shop and CRM; zero password sharing; one-click revokeAgencies holding accounts hostage
R290-second read-only audit before any credit cardPaywalling an empty screen
R3, N6Dual Meta CAPI and Google Data Manager with separate hashing behind a hard consent gateBroken match quality or unconsented data dispatch
R4, N2Neither marketers nor AI spend directly; every binding change uses an expiring SHA-256 preview approved by the ownerOvernight spend spikes from unchecked clicks or black-box automation
R5, N7, N8Marketer badges come from read-only APIs and safeguarded payment records; the product never promises a guaranteed ROASEdited screenshots, fake star scores and false return claims
R6, N3–N5, N11One-click cancel, zero ad-spend markup, licensed iyzico Pazaryeri safeguarded payments, verified company billingPooling client cash illegally or phone cancellation traps
R7Moving a consented CRM deal to qualified or won queues conversion feedback in the same transactionAd platforms optimizing for junk leads
R8, N12At most five SEO tasks from an isolated crawler instead of 400 raw rowsDashboard sprawl

A common mistake is treating product rules as marketing slogans. Here, every rule above maps to code, database checks or automated gates covered in later lessons.

Who uses it and the five places

A small-business tool breaks down when every user holds the same privileges or navigation sprawls across fourteen tabs. This product separates two roles and five calm places:

  • The business owner owns the workspace, connects OAuth accounts, sets daily ceilings and step caps, toggles the kill switch, approves proposals, releases safeguarded payments and revokes access in one click.
  • The hired marketer works inside a time-bound, scoped grant, inspects diagnostics, proposes changes into the approval queue and never sees OAuth vault tokens or billing controls.

Signed-in navigation exposes five places plus a Settings icon:

  1. Overview (Özet): 30-day spend, verified revenue, signal health, kill-switch status and pending approvals.
  2. Signals and Connections (Sinyal & Bağlantılar): OAuth connections, signal studio and live event debugger.
  3. Marketers (Uzmanlar): vetted specialist dossiers and safeguarded-payment engagements.
  4. Customers (Müşteriler): closed-loop CRM pipeline feeding consented sales back to ad platforms.
  5. SEO (SEO): Core Web Vitals, Search Console summary and at most five prioritized fixes.

Advanced modules (profit margins, AI copy proposals, raw ingest inspection) open one click beneath their parent place. This lesson covers the map only; sign-in and roles belong to lesson 04.

The seven runtime parts and what each may touch

Think of a restaurant kitchen that separates the front counter, the cash register, the locked safe and the delivery scooter. If a stranger walks up to the front counter, they cannot open the safe because the counter clerk does not even hold the key. Software architecture uses the same idea: split the running system into a small number of distinct processes so a bug in one part cannot automatically compromise every secret.

That analogy stops being exact at one point: in software, splitting into too many tiny services creates more network failures and operational drag than a small team can handle. That is why bounded architecture keeps this entire system to seven well-defined runtime pieces rather than dozens of microservices.

Browser (Owner / Marketer / Shopper)
   |                           |
   | HTTPS pages               | Tracking beacon
   v                           v
[1. Web App (apps/web)]     [6. Edge Collector (apps/collector)]
   | HTTP JSON only            | Signed HTTPS batch
   v                           v
[2. API Server (apps/api/src/server.ts)] -----> Meta Graph API (test budget execution)
   | app login + vault login
   v
[3. PostgreSQL 18 Database] <---- [4. Background Worker (worker-main.ts)] (app login only)
   ^
   | app login + vault login
[5. Dispatch Process (dispatch-main.ts)] -----> Meta CAPI & Google Data Manager

[7. SEO Crawler (apps/seo-worker)] -----> Public shop URLs only (zero DB or vault secrets)

Each of the seven runtime parts has a strict job and an explicit list of what it must never touch:

Runtime partJobMay touchMust never touch
1. Web appRenders Turkish and English screens in Next.jsBrowser HTTP calls to the API and closed UI primitivesPostgreSQL directly, OAuth vault tokens, raw secrets
2. API serverHandles auth, workspace routes, approvals and Meta budget executionApp database login, vault login and master key when configuredUnverified client totals or direct browser DOM
3. PostgreSQL 18 databaseStores tenant rows, auth sessions, vault ciphertexts and audit logTenant rows filtered by forced row-level security; separate auth and vault schemasCalling external ad APIs directly
4. Background workerRuns database housekeeping and queue sweepingApp database login only (DATABASE_URL)Vault database login, vault master key or live ad-platform delivery
5. Dispatch processSends stored conversion events and refreshes OAuth tokensApp database login plus vault login and master keyServing public browser HTTP requests
6. Edge collectorReceives storefront and browser events, hashes personal data and signs batchesPublic event payloads and edge signing secretPostgreSQL, vault secrets or raw long-term PII storage
7. SEO crawlerFetches public shop pages and runs technical SEO checksPublic HTTPS targets checked by SSRF guardsAny database URL, vault key, payment key or ad-platform secret

The most common mistake in early web apps is letting the frontend framework query the database directly or giving every background worker full database superuser access. Separating the vault-less worker from the dispatch process and blocking every secret at startup inside the SEO crawler shrinks the blast radius if any single component fails.

Three journeys end to end

Tracing three real journeys shows how the seven parts cooperate across boundaries.

Journey 1: a page request

When a signed-in owner opens /w/{workspaceId}/overview, the frontend asks the backend API for workspace data.

Browser -> Web App (reads workspaceId from URL)
        -> API GET /v1/w/:workspaceId/overview (checks session cookie + role)
        -> PostgreSQL (sets transaction-local workspace context)
        -> API returns JSON DTO (Cache-Control: no-store) -> Web App renders

The workspace ID stays in the URL so two open tabs for two shops never mix, and the web app never queries PostgreSQL directly.

Journey 2: a tracked event

Shopper browser -> Edge Collector (hashes email/phone per platform, signs batch)
                -> API ingest endpoint (verifies signature + consent gate, stores row)
                -> Dispatch Process (claims row, decrypts token from vault, sends to Meta/Google)
                -> PostgreSQL updated with delivery receipt (or skipped_no_consent)

Platform-specific hashing and consent rules belong to lesson 07; vault encryption belongs to lesson 05.

Journey 3: an approval

Marketer -> API POST /v1/w/:workspaceId/approvals (checks ceilings, hashes payload, stores pending row)
Owner    -> Reviews Approval Drawer (exact integer diff, expiry timer, SHA-256 preview)
Owner    -> Approves with step-up -> API re-verifies hash, expiry, ceiling and kill switch
         -> API reads Meta budget, writes new budget, reads back to confirm -> Audit log receipt

Re-verifying the hash and ceilings on the server stops any browser tamper after approval. The full approval state machine and crash recovery belong to lesson 08.

The map of the repository

This codebase is structured as a monorepo: one Git repository holding all applications, shared libraries, design contracts, documentation, verification tools and tests together. One commit can update a shared library and every app that depends on it at the same time.

Top-level folderWhat lives thereExample
apps/The four runnable applicationsapps/web, apps/api, apps/collector, apps/seo-worker
packages/Ten shared internal libraries imported by appspackages/db, packages/vault, packages/approvals, packages/ui, packages/signals
design/The product frame, all UI copy, design decisions, visual tokens and prototypesdesign/FRAME.md, design/WORDS.md, design/DECISIONS.md
docs/Architecture records, schema, OpenAPI contract, runbooks, owner decisions, wave reports and lessonsdocs/schema.sql, docs/openapi.yaml, docs/adr/, docs/lessons/
tools/Zero-dependency verification runner, static gates, learning builder and local dev stacktools/verify, tools/gates.manifest.json, tools/learning/build.mjs
tests/Cross-cutting contract, security fuzz, chaos, load and real-browser journey suitestests/contracts/, tests/security/, tests/browser/

A typical newcomer mistake is editing generated outputs directly or putting product copy inside packages/ui. Knowing the folder roles tells you immediately where a change belongs: shared UI parts live in packages/ui with zero product strings, user-facing strings start in design/WORDS.md, and cross-package rules live in packages/.

How decisions are recorded and what the five status words mean

Large projects break down when product rules, legal trade-offs and technical choices live only in someone's memory. This repository records decisions in four linked places:

  1. The design triad under design/: FRAME.md defines product scope and rules, WORDS.md holds every Turkish and English screen string (with the one named exception OD-23 for English lessons and dictionary content), and DECISIONS.md records numbered design decisions (D01 to D40) and founder open questions (Q1 to Q10).
  2. The owner decision register in docs/OWNER-DECISIONS.md, recording business and governance calls (OD-01 onward) that only the two founders can answer.
  3. Ten architecture decision records (0001 to 0010) in docs/adr/, explaining major technical choices such as passwordless sign-in (ADR-0010) and the closed UI kit (ADR-0003).
  4. The root rulebook AGENTS.md, which binds every person and agent with 22 numbered rules, including using the brand slot ({ürün} / {product}) until OD-01 settles the public name.

Finally, every claim about any feature must use one of five exact status words:

  • researched: studied from external sources or competitor evidence, not yet designed or coded.
  • designed: written down in a specification, decision record or contract, not yet coded.
  • built: code exists on the branch, with no claim yet that tests passed.
  • verified: built code passed concrete, recorded checks on a named commit and environment.
  • deployed: running on a real server reachable by owners or customers.

Saying "done" hides the difference between a document, untested code and a live server. Using these five words keeps every conversation grounded in facts.

How this repository does it

Every boundary sketched above is enforced in concrete files on this branch today:

  • Rules and product contract: AGENTS.md lists all 22 repository rules; design/FRAME.md sets out R1 to R8, N1 to N12, the twelve Release 1 screens and the three supporting surfaces; design/WORDS.md holds bilingual screen strings; design/DECISIONS.md and docs/OWNER-DECISIONS.md track D01 to D40, Q1 to Q10 and OD- decisions; docs/adr holds ADRs 0001 to 0010.
  • Workspace packages: pnpm-workspace.yaml registers apps/* (web, api, collector, seo-worker) and packages/* (ai, approvals, auth, connectors, db, payments, shared, signals, ui, vault). If a package boundary were broken—for instance, if apps/web imported packages/db directly—architecture and web-budget checks would fail.
  • API composition root: server.ts is the API composition root. Before opening any HTTP port, loadApiRuntimeConfig validates environment variables (logging codes only, never values), runSchemaGuard verifies the database schema version, and server.ts refuses to start in production if OAUTH_FAKE_PROVIDER_BASE is set. It builds the app database pool (DATABASE_URL), the optional vault pool (VAULT_DATABASE_URL) and the real Meta budget executor (createMetaBudgetExecutor), then passes them to createApiApp in app.ts. Removing this composition root would scatter secret parsing and let production accidentally start with sample memory data or test stubs.
  • Separate background processes: worker-main.ts runs vault-less database queues and hourly housekeeping (auth.cleanup_login_challenges and expired OAuth flow purges) using only DATABASE_URL. dispatch-main.ts runs as the separate least-privilege dispatch process holding DATABASE_URL, VAULT_DATABASE_URL and the vault master key; runDispatchMainCli runs SignalDispatchEngine.runCycle and periodic token refresh (runConnectionRefreshCycle) and refuses the fake provider in production. Removing that split would force the general worker to hold vault credentials unnecessarily.
  • Edge and crawler isolation: app.ts implements the Hono edge collector with CORS, rate limiting and edge hashing; env-guard.ts lists FORBIDDEN_EXACT_ENV_VARS and FORBIDDEN_ENV_PREFIXES (DATABASE_, VAULT_, POSTGRES_, IYZICO_) and aborts apps/seo-worker at startup if any forbidden secret is present. Removing env-guard.ts would remove the startup guarantee that a compromised crawler cannot read database or payment keys.
  • Workspace shell and endpoints: WorkspaceShell.tsx renders the five places and URL-based workspace switcher, while apps/api/src/routes implements every HTTP endpoint described in docs/openapi.yaml.
  • What is true today on this branch: Passwordless sign-in, OAuth ad-account connection (against a production-refused local fake provider), stored event ingest, the dispatch process and the Meta budget approval executor are built and verified locally (and Waves 46 and 47 ran green on GitHub Actions, as recorded in LOG.md).
◆

Not built yet

Nothing in this repository is deployed to a public production server, no real Meta or Google API call has been executed against live customer accounts, and there are zero paying customers. Live deployment waits for private staging verification, external security review (issue 97), Turkish legal and tax counsel sign-off (OD-05, issue 3), database residency confirmation (OD-04), ad-platform app approvals (issue 4) and the founders' explicit sign-off (AGENTS.md rule 22). Release 2 (TikTok, Google Business Profile, Multi-Brand Pro) and Release 3 (global expansion and open public directory) are planned only, not designed or built.

What went wrong once

Breadth outran the critical path

  • What happened: During the first week of rapid parallel building, the repository accumulated roughly 980,000 lines, 93 API route files (including 28 read-only preflight calculators), 31 public pages, 58 UI components and 81 documents. Despite that volume, a real person still could not create an account, sign in, connect a Meta or Google ad account, send a real event or execute an approved budget change.
  • How it was noticed: The independent review recorded in docs/INDEPENDENT-REVIEW-2026-12-02.md checked every core promise from a clean clone instead of judging progress by file counts.
  • Cause in plain words: Earlier checks measured growth by minimum counts (more routes, more pages, more docs), so adding sideways surfaces stayed green while wiring the hard end-to-end journey remained unfinished.
  • Fix: The founders recorded owner decision OD-18 (depth-first engineering, deletion allowed), retired growth-only count checks and focused Waves 46, 47 and 48 on finishing the four-step critical path: sign in, connect an account, deliver a test event and execute one approved budget change.
  • General lesson: Progress is the shortest complete path a real customer can walk from end to end, never the count of screens or documents.

Decisions on paper and the code drifted apart

  • What happened: Early records ADR-0001 and ADR-0004 named Better Auth, pg-boss, Drizzle and Node 26, yet the actual code used none of those libraries and ran on Node 24. Meanwhile README.md had grown into a 124 KB log summary that never told a newcomer how to start the project.
  • How it was noticed: The 2 December 2026 review compared the ADRs and README.md line by line against package.json and the live source code.
  • Cause in plain words: Code evolved quickly while architecture documents were treated as one-time write-only artifacts instead of living records.
  • Fix: In Wave 46 the founders accepted OD-14 and ADR-0010 for passwordless sign-in in own code, amended ADR-0001, ADR-0004 and docs/SYSTEM.md, and placed a short "Start here" section at the top of README.md.
  • General lesson: A decision record that contradicts running code misleads every future contributor; when the code changes, amend the record the same day.

Three finished parts that did not add up to a working sign-in

  • What happened: In Wave 46, three parallel workstreams built auth storage (A), sign-in API routes (B) and login screens (C), and each passed its own tests. Yet taken together, the sign-in routes were not mounted in the app, the development CORS rule blocked the browser's request header, sign-out left new cookies behind and a new workspace fell back to displaying a sample business's name.
  • How it was noticed: Wave 46 included a dedicated wiring workstream (F) whose real-browser journey tested the whole flow in Chromium against the live API and database, recorded in docs/wave46/reports/F-REPORT.md.
  • Cause in plain words: Each part was tested in isolation against stand-ins for the other two parts, and browser rules like CORS preflights only trigger in a real browser.
  • Fix: Workstream F mounted the routes, added the cookie-mutation origin guard, unified token reading into one leaf module, cleared all three cookies on sign-out and proved the full flow with sign-in-journey-e2e.mjs.
  • General lesson: Passing unit tests on separate pieces never proves the pieces work together; integration needs its own owner and an end-to-end test.

Try it yourself

Every step below is read-only and safe to run on Windows. None of these commands touch your running local dev stack on ports 3000, 4000 or 5432, and none call Meta or Google.

Step 1: list the fourteen workspace packages in PowerShell

Get-ChildItem apps, packages -Directory | Select-Object Parent, Name

You should see four directories under apps (api, collector, seo-worker, web) and ten directories under packages (ai, approvals, auth, connectors, db, payments, shared, signals, ui, vault). That list matches pnpm-workspace.yaml and shows the full footprint of the monorepo.

Step 2: inspect the ten architecture decision records in PowerShell

Get-ChildItem docs/adr -File | Select-Object Name

You should see ten numbered Markdown files from 0001-web-first-nextjs-fastify-postgres.md through 0010-durable-sessions-and-passwordless-sign-in.md. Open 0010 to see how a real decision records its context, rejected alternatives and consequences.

Step 3: verify the SEO crawler's startup secret guard in PowerShell

Select-String -Path apps/seo-worker/src/env-guard.ts -Pattern "FORBIDDEN_ENV_PREFIXES|DATABASE_URL|VAULT_DATABASE_URL"

You should see DATABASE_URL, VAULT_DATABASE_URL and FORBIDDEN_ENV_PREFIXES (DATABASE_, VAULT_, POSTGRES_, IYZICO_). This confirms in live code that Zone 3 refuses to start if any database, vault or payment secret is ever injected into its environment.

Step 4: check the verification plan without executing anything in Git Bash

bash tools/verify --list

Git Bash prints the complete ordered list of checks from tools/gates.manifest.json grouped into core, static, suites, postgres, deploy, scanners, build and browser, without starting any server or changing any file. Seeing the plan tells you exactly what "verified" covers on this branch.

Words to know

  • account sovereignty
  • AGENTS.md
  • API
  • architecture decision record
  • backend
  • bounded architecture
  • brand slot
  • built (status word)
  • business owner
  • composition root
  • critical path
  • deployed (status word)
  • design decision
  • design triad
  • designed (status word)
  • dispatch process
  • endpoint
  • founder open question
  • frontend
  • hard rule
  • marketer
  • monorepo
  • operating ledger
  • owner decision
  • place (navigation)
  • product frame
  • refusal
  • researched (status word)
  • status word
  • verified (status word)
  • web app
  • worker
  • workspace

Go deeper

  • Repository rules and product constitution: AGENTS.md, design/FRAME.md, design/DECISIONS.md and docs/OWNER-DECISIONS.md.
  • System overview and decision records: docs/SYSTEM.md, docs/adr/0001-web-first-nextjs-fastify-postgres.md and docs/adr/0010-durable-sessions-and-passwordless-sign-in.md.
  • Real history behind the depth-first shift: docs/INDEPENDENT-REVIEW-2026-12-02.md and LOG.md.
  • Archived lessons this lesson replaces (historical only, not a source of current facts): archived lesson 10, archived lesson 13, archived lesson 16, archived lesson 20 and the archive index.
  • External documentation for core web technologies used here: MDN overview of HTTP, TypeScript documentation, Fastify documentation, Next.js App Router documentation, Cloudflare Workers documentation and OpenAPI Specification.

Kendini sına soru özeti ve yanıt anahtarı

Q1. Why does the dispatch process run separately from the general background worker?

Answer: B

Separating apps/api/src/dispatch-main.ts from apps/api/src/worker-main.ts keeps the general worker vault-less so only processes that genuinely need encrypted OAuth tokens hold VAULT_DATABASE_URL and the vault master key. Option A is wrong because a single Node.js process easily runs multiple timers; the split is a least-privilege security boundary, not a runtime limitation.

Q2. A feature's code is merged on a branch and its local tests passed on your Windows machine, but no server is running it for customers. Which status words accurately describe it?

Answer: C

Under AGENTS.md rule 1, code on a branch with recorded passing local checks is built and verified locally—and explicitly not deployed until it runs on a live or staging server. Option A is the most tempting mistake because teams often conflate a green local test suite with live deployment.

Q3. Why must every workspace URL include /w/:workspaceId/... instead of storing the active workspace in a session cookie?

Answer: B

A mutable "active workspace" cookie is shared across every browser tab, so switching clients in tab two silently redirects clicks in tab one to the wrong business. Putting the workspace ID in the URL locks each tab to one tenant. Option C is wrong because PostgreSQL never reads browser URLs; the API extracts workspaceId and passes it into a transaction-local database setting.

Q4. If an attacker tricks the SEO crawler into reading environment variables while scanning a hostile storefront page, why can they not steal customer OAuth tokens?

Answer: B

The crawler runs as an isolated Zone 3 worker with zero database or vault credentials, and its startup guard aborts before handling any crawl if a forbidden environment variable is present. Option A is wrong because apps/seo-worker is a server-side worker, not browser code.

Q5. What did the 2 December 2026 independent review reveal about building 28 read-only preflight calculators before real sign-in existed?

Answer: B

Preflight calculators have real value for previewing guardrails, so Option A goes too far; the real lesson from CS-26 and OD-18 is that surface breadth never substitutes for completing the thin end-to-end critical path first.

Q6. A proposed screen needs to show a new Turkish button label and bend hard rule R4 so AI can raise budgets automatically without approval. What must happen first according to AGENTS.md?

Answer: C

AGENTS.md rules 2, 16 and 17 make the design triad the binding contract: breaking a frame rule requires changing design/FRAME.md first (and changing an owner-backed rule requires founder sign-off), and every user-facing string starts in design/WORDS.md rather than inside packages/ui (Option B violates the app-free kit rule).

GetClaps Kurucu Akademisi · Tarayıcı açılışında ağ çağrısı yapılmaz; ilerleme yalnızca cihazındaki yerel depolamada tutulur.