EmofyEmofy Docs
Conventions

Architecture Decision Records

Every significant decision that shaped the platform, each with a one-line rationale and its current status.

Architecture Decision Records (ADRs) capture the why behind the platform's structure. The full records live in docs/ai-context/decisions/ in the repo, indexed by docs/ai-context/decisions/README.md. This page lists every ADR, grouped by area. Status mirrors the record's own header.

Accepted means the record describes how the system works today. Proposed documents an intended direction that is not (fully) built; Rejected was never adopted. Superseded means a later ADR or PRD replaced it; Deprecated means the mechanism was removed with no successor. Both records are kept as history. Number 060 was never used.

Foundation & identity

ADRDecisionStatus
001Dual database — emofyplatform_auth (identity) separate from emofyplatform_core (business data).Accepted
002RS256 JWT (migrated from EdDSA) so any JWKS verifier can check tokens.Accepted
005Better Auth over NextAuth — org plugin, 2FA, JWT, multi-session.Accepted
006OrgScopedRepository — auto-injected orgId + soft-delete filtering; raw tenant queries forbidden.Accepted
007Prefixed nanoid IDs — generateId("entity") → entity_....Accepted
024API keys — custom backend module instead of Better Auth's apiKey plugin.Accepted
026Seed data lives in the pure leaf package @emofy/seed-data.Accepted
027Prefixed-ID SSOT in the pure leaf package @emofy/ids.Accepted
028Org role vocabulary renamed; platform privilege has a single SSOT.Accepted
031Account onboarding — user-scoped state + org invite short codes.Accepted
085Native passkeys via react-native-passkeys + the official server plugin.Accepted
090Native → web session handoff — one-time token, single handoff page on the account host.Accepted

Authorization & tenancy

ADRDecisionStatus
021Relationship-based permissions — access = role ∧ active relationship/enrollment ∧ consent.Accepted
034Internal authorization platform — decision service, policy sources, fact store, PEP adapters.Accepted
035Authorization leaf packages @emofy/authz-core + @emofy/authz.Accepted
036ABAC operator engine — restrict-only AST, narrows after the RBAC decision.Accepted
037Scope-plane model — tenant / personal / platform planes, enforced by a coverage ratchet.Accepted
070RLS pilot — database-level tenant backstop on report_cards and grades.Accepted
071Response-view serialization with zod view schemas, not class-transformer.Accepted
077Third-party authz enforcement — composite guard, two trust branches, measured back-compat.Accepted
078Row-level authz — imperative handler checks + repository predicates; ABAC projection deferred.Accepted
084Platform authorization tiers — support / auditor / admin / operator.Accepted
103Org custom roles are grant-only — extra rows on the static matrix, lazy-loaded in the guard.Accepted
116Deny policies on the allowed path — in-process org cache (30 s), owner exemption, fail-closed.Accepted

Child data & compliance

ADRDecisionStatus
020Dual ledger — org operational ledger + parent-owned child passport.Accepted
022Child-data classification — ledger / consent / retention / visibility matrix.Accepted
032Legal document content has one SSOT package, @emofy/legals.Accepted
033Docs reference blocks are generated from code SSOTs and drift-gated.Accepted
046Guardian-authored passport entries — a second writer on the parent ledger.Accepted
048Child badges are a read-only derivation of the passport.Accepted
049Child mode — age-appropriate access and closed surfaces.Accepted
050Account deletion scope and the field-level anonymization boundary.Accepted
052Import consent boundary + batch / rollback model.Accepted
068DSAR orchestration ledger + class-based retention engine.Accepted
069Driver location data regime — purpose limitation, 72 h raw-ping purge.Accepted

Messaging, notifications & realtime

ADRDecisionStatus
009Messaging SSOT — Postgres SSOT + Convex realtime mirror.Superseded by 025 → 073 → 104
010Transactional outbox for durable side-effect dispatch (webhook outbox is the live use).Accepted
025Messaging Convex-first SSOT + Postgres compliance archive.Superseded by 073 → 104
029Convex mirror table naming aligned to the SSOT.Deprecated (104)
030Identity-plane Convex mirroring via a transactional outbox.Superseded by 104
044Structured message cards — versioned data payload validated on send; stored message is plaintext.Accepted
045Expo Push HTTP API as the native push provider.Accepted
047Convex → backend notification bridge.Superseded by 104
051SMS — TR-first provider abstraction with a fallback chain.Accepted
055Push credential operator handoff and secret regime (VAPID + Expo).Accepted
073Messaging hybrid dual writer — REST/Postgres authoritative, opt-in Convex-first.Superseded by 104
074Conversation create — best-effort synchronous mirror + outbox fallback.Superseded by 104
075Convex ↔ Postgres sync hardening.Superseded by 104
083Announcement channels and bulk email delivery paths.Accepted
104Realtime provider = Cloudflare Durable Objects; Convex retired.Accepted

Backend & data

ADRDecisionStatus
018MongoDB decommission — the audit firehose moved to partitioned Postgres.Accepted
023API versioning & deprecation policy for the partner API.Accepted
038Organization-deletion cascade — schema-introspected purge order.Accepted
039Event replay — typed reconstruction + idempotency ledger.Accepted
042Perf baseline — Redis histograms over Prometheus/OTel.Accepted
043Flag evaluation precedence — kill > override > cohort > percentage > default.Accepted
054Search — Meilisearch pre-filter + row scope, fail-closed permission trimming.Accepted
057Analytics warehouse — separate analytics schema, T+1 rollup, PII-free.Accepted
063Billing provider abstraction and entitlement model.Accepted
064Media scan provider seam — interface + no-op default.Accepted
065Backup & disaster recovery — inventory, RPO / RTO.Accepted
066Org lifecycle state machine — single-writer matrix + windowed purge.Accepted
067Surveys is a core module, separate from family forms.Accepted
072Fees (org → parent) are separate from platform billing (Emofy → org).Accepted
086Onboarding step payloads in jsonb + a shared pure state machine in @emofy/types.Accepted
087Seed plan artifacts in R2; only aggregates in the ledger.Accepted
088Ops incident data ownership.Accepted
110SIS copy-model records — org-native record, optional account link, mirror columns.Accepted
117Org as seller — iyzico marketplace / sub-merchant, one seller-account seam.Accepted
119Org sales invoices — e-Arşiv / e-Fatura integrator port, none by default.Accepted
122Seed universe — the mock universe lands in a real DB through domain writers.Accepted

EMA ecosystem

ADRDecisionStatus
003EMA-first architecture — domain features are EMAs; core holds only interaction channels.Accepted
012EMA R2 immutable publish — R2 is an artifact store, not a root of trust.Accepted
041EMA mobile-view compatibility flag semantics.Accepted
056EMA manifest v2 — agent-surface schema and tool registration.Accepted
059Cafeteria scopes as EMA permissions + the ema/cafeteria surface.Accepted
061EMA event-subscription delivery gating.Accepted
062dev-sdk resource client generated from the OpenAPI snapshot.Accepted
076Personal-plane app surface — install = tenant, global flag, no org override.Accepted
080EMA runtime activation — web env gate, native ungated.Accepted
081Personal-plane runtime deferral.Superseded by 112
112Personal-plane EMA runtime — personal token, plane-default deny, native host.Accepted
118EMA data plane — acting-user token, direct REST, host owns only the experience.Accepted
124Host-owned EMA navigation — host draws title and back button; one back controller.Accepted

Web, native & design system

ADRDecisionStatus
004RDS + Ramarkable split — low-level primitives vs. high-level components.Accepted
053Observability stack — OTel via the Sentry provider, exporter selection, rollback levers.Accepted
082Native Sentry re-enable gate — killswitch stays on until a real-device retest passes.Accepted
089App route story-coverage ratchet.Accepted
091Native list header — pull-to-reveal secondary layer, in-place collapsing search.Accepted
092Consumer web rewrite — thin host apps/app, packaged consumer screens, incremental ports.Accepted
093Sentry v11 + OTel bootstrap — mode matrix, single provider (replaces 053 §1).Accepted
095Consumer demo mode — build flag + shared mock ports package.Accepted

Infrastructure & deploy

ADRDecisionStatus
011Multi-environment credentials — dev / staging / production + CLI.Accepted
013Decouple backend env validation from T3 — shared Zod schema.Rejected
014Runtime destructive-target guard + agent secret-handling policy.Accepted
015Railway as the backend platform — EU, env per project.Accepted
016OpenTofu hybrid IaC — no secrets in state.Accepted
017Infisical as the secret SSOT — three-way ownership.Accepted
019Domain split — emofy.com.tr = prod, emofy.net = non-prod.Superseded by 108
058Turbo task-scoped env — strict mode, generated from the env schema.Accepted
079Package boundary tags + repo-wide turbo boundaries.Accepted
107Deploys run from the operator's machine — pnpm deploy:<env>, clean clone, staging first.Accepted
108All tiers under emofy.com.tr — tier host pattern, prefix + strip mitigations.Accepted
109Railway ownership split — tofu project + domains, Railway IaC services, Infisical shared vars.Accepted
115Build once, promote many — CodeBuild build plane, sha-bound artifact set.Rejected
120R2 storage + CDN — tier × purpose buckets, EU jurisdiction, separate EMA domain.Accepted

Agent workflow & tooling

ADRDecisionStatus
008Paperclip AI agent orchestration.Superseded
040Parallel-agent orchestration — path-conflict plane, ready queue, generated status panel.Accepted
094Gotcha pool SSOT — lane table + secret-value pattern in one module.Accepted
096Probabilistic model output is advice, not a gate.Accepted
097Proof-carrying FRs — named Phase 5 evidence + red-revert.Accepted
098Readiness v2 — question bank + pre-mortem + assumptions instead of a score.Accepted
099Independence is the runner's job — isolated headless agent, run record as proof.Accepted
100Out-of-band memory consolidation — probabilistic proposal, deterministic apply.Accepted
101Night driver — deterministic loop controls, segment agent judges, never pushes.Accepted
102_provegate — standalone control app outside the workspace, HTTP-only boundary.Accepted
105Agent core single source — five entry files, injection + measurement.Accepted
106Single-family panel / scorer — effort in the launch contract, routing kill switch.Accepted
111Operator's chat Go is operator approval — hook record, ask binding, per-turn push.Accepted
113Model router — one routing point, suggested vs. applied route, shadow mode.Accepted
114Cross-machine PRD assignments — tracked single-writer record, network-free gates.Accepted
121Single-writer lander + signed feat push — narrow exception to 114 §2.Accepted
123Emofy CLI REPL runs in-process with Ink; commands take a CommandRuntime.Accepted
125Panel lens plan bound to the diff, quorum in code, recheck round.Accepted

How these show up in the docs

On this page