EmofyEmofy Developers
Conventions

Architecture Decision Records

The significant decisions 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; this is the index a new engineer should skim first. Status reflects the record at the time of writing.

An ADR marked Proposed documents the intended direction; parts of it may be partially implemented. Accepted means it reflects how the system works today. Superseded means a later ADR replaced it.

Foundation

ADRDecisionStatus
001Dual database — separate emofyplatform_auth (identity) from emofyplatform_core (business data).Accepted
002RS256 JWT (migrated from EdDSA) so JWKS verification works for the backend and Convex.Accepted
005Better Auth over NextAuth — better org plugin, 2FA, JWT, multi-session.Accepted
006OrgScopedRepository — auto-inject orgId + soft-delete filtering; raw tenant queries forbidden.Accepted
007Prefixed nanoid IDsgenerateId("entity")entity_..., readable and migration-free.Accepted

Product model

ADRDecisionStatus
003EMA-first architecture — domain features are EMAs; core holds only interaction channels.Accepted
020Dual ledger — child activity recorded in an org operational ledger and a parent-owned passport.Proposed
021Relationship-based permissions — access = role ∧ active relationship/enrollment ∧ consent.Proposed
022Child-data classification — the ledger/consent/retention/visibility matrix for child data.Proposed

Backend & data

ADRDecisionStatus
009Messaging SSOT — Postgres SSOT + Convex realtime mirror.Superseded by 025
010Transactional outbox — durable side-effect dispatch (email, webhooks, notifications).Accepted
018MongoDB decommission — the audit firehose moved to a partitioned core-Postgres table.Accepted
025Messaging Convex-first SSOT — Convex is the live store; Postgres is the compliance archive.Accepted

Design system

ADRDecisionStatus
004RDS + Ramarkable split — low-level primitives vs. high-level components.Accepted

Ecosystem & API

ADRDecisionStatus
008Paperclip — AI agent orchestration.Accepted
011Multi-environment credentials — dev / staging / production + CLI.Accepted
012EMA R2 immutable publish — R2 is an artifact store, not a root of trust.Accepted
023API versioning & deprecation policy for the partner API.Accepted
024API keys — custom backend implementation over Better Auth's apiKey plugin.Accepted

Infrastructure & ops

ADRDecisionStatus
013Decouple backend env validation from T3 — shared Zod schema, split composition.Proposed
014Runtime destructive-target guard + agent secret-handling policy.Accepted
015Railway as the backend platform (single platform, EU, env-per-project).Accepted
016OpenTofu hybrid IaC — separate root modules; no secrets in TF state.Accepted
017Infisical as the secret SSOT — three-way ownership, flat-per-deploy-target.Accepted
019Domain splitemofy.com.tr = prod, emofy.net = non-prod; branch → env mapping.Accepted

How these show up in the docs

On this page