···11+# Data Model Mapping
22+33+This document maps the public AT Protocol Lexicon records to our internal SQL database schema.
44+55+## Principles
66+77+1. **Separation of Concerns**
88+ We store "my view" of the world (private state) separate from "the network's view" (public records).
99+2. **Hydration**
1010+ We allow hydrating public records into local DB rows for efficient query/indexing, but the source of truth for the record itself is the signed commit in the repository.
1111+3. **Private State**
1212+ User progress, scheduling, and local-only drafts live ONLY in the internal DB.
1313+1414+## Mapping Table
1515+1616+| Public Lexicon | Internal DB Table(s) | Notes |
1717+| :----------------------------- | :------------------- | :------------------------------------------------------------- |
1818+| `app.malfestio.deck` | `decks` | Public metadata. |
1919+| `app.malfestio.card` | `cards` | Content. |
2020+| `app.malfestio.note` | `notes` | Standalone notes. |
2121+| `app.malfestio.source.*` | `sources` | Metadata for articles/lectures. |
2222+| `app.malfestio.collection` | `collections` | |
2323+| `app.malfestio.thread.comment` | `comments` | |
2424+| _(None)_ | `reviews` | **Private**. Logs of every review event. |
2525+| _(None)_ | `study_progress` | **Private**. Current SRS state for a card (box/interval/ease). |
2626+| _(None)_ | `user_settings` | **Private**. Daily goals, UI references. |
2727+| _(None)_ | `drafts` | **Private**. Content being authored before publishing. |
2828+2929+## Sync Strategy
3030+3131+- **Publishing**:
3232+ Write to `drafts` -> User clicks "Publish" -> Sign record -> Push to PDS -> Move `drafts` content to `decks`/`cards` tables (or mark as synced).
3333+- **Consuming**:
3434+ Pull from PDS (firehose or direct sync) -> Validate signature -> Upsert into local tables.
+38
docs/publish-pipeline.md
···11+# Publish Pipeline Spec
22+33+This document defines the lifecycle of content from draft to published record.
44+55+## Lifecycle States
66+77+1. **Draft** (Local Only)
88+ - Stored in local SQL/captured in UI state.
99+ - Not visible to PDS or other users.
1010+ - Mutable without restriction.
1111+ - IDs are local UUIDs or temporary placeholders.
1212+1313+2. **Published** (Public / Unlisted / Shared)
1414+ - Signed and committed to the AT Protocol repository.
1515+ - Assigned a permanent `at://` URI.
1616+ - stored in Lexicon-compliant format.
1717+ - **Edits**: Append a new commit replacing the record. History is technically preserved in the repo log but UI typically shows latest.
1818+1919+3. **Deprecated / Tombstoned**
2020+ - User "deletes" the content.
2121+ - **Action**: We replace the record with a minimal "tombstone" or actually delete the record from the repo (RepoOp `delete`).
2222+ - *Note*: Aggregators may still have cached copies.
2323+2424+## Protocol Flow
2525+2626+1. **Auth**: User logs in via OAuth (or app app-password initially).
2727+2. **Format**: App converts internal `Draft` model -> `Lexicon` JSON.
2828+3. **Sign & Commit**:
2929+ - App constructs a repository operation (create/update).
3030+ - Sends to PDS (Personal Data Server).
3131+4. **Confirm**: PDS confirms commit CID.
3232+5. **Index**: App updates local distinct "published" view to match confirmed state.
3333+3434+## Versioning Content
3535+3636+- No git-like branching for content *history* in the MVP.
3737+- "Edit" = "Overwrite".
3838+- Collaborative editing (forking) = "Copy & Publish New".
+2-32
docs/todo.md
···37373838## Roadmap Milestones
39394040-### Milestone A - Product Spec + IA + UX Flows
4141-4242-#### Deliverables
4343-4444-- Core user journeys (5):
4545- - Import source -> generate notes/cards -> publish deck
4646- - Daily study -> review queue -> grade -> progress view
4747- - Follow curator -> discover deck -> fork -> contribute improvements
4848- - Discuss a card/deck -> moderation/report flow
4949- - Lecture workflow -> outline -> timestamps -> linked cards
5050-- Information architecture + navigation map
5151-- "Share vs private" rules doc (what becomes public records; what never does)
5252-5353-#### Acceptance
5454-5555-- Every screen maps to a backend capability + a data model entity.
5656-5757-### Milestone B - Lexicon Design Kit + Data Model Mapping
4040+- **(Done) Milestone A**: Defined core user journeys, information architecture, and privacy rules for the platform.
58415959-#### Deliverables
6060-6161-- Lexicon repo folder with:
6262- - record schemas for note/card/deck/article/lecture/collection/comment
6363- - schema evolution notes (what can change, what cannot)
6464-- Mapping doc:
6565- - Public record (lexicon) <-> internal DB row(s)
6666-- Minimal "publish pipeline" spec (draft->published->deprecated)
6767-6868-#### Acceptance
6969-7070-- You can create a deck and serialize it into a stable record shape.
7171-- Follow Lexicon rules; prefer additive evolution.
7272-- Review Bluesky "custom schemas" patterns for compatibility expectations.
4242+- **(Done) Milestone B**: Designed AT Protocol Lexicons for all core types and documented data model mapping + publishing pipeline.
73437444### Milestone C - Foundations: Repo, CI, Axum API Skeleton, Solid Shell
7545
···11+# Lexicon Schemas
22+33+This directory contains the Lexicon definitions for the malfestio's public records.
44+55+## Evolution Rules
66+77+1. **Additive Changes Only**: You can add new optional fields to existing records.
88+2. **No Renaming**: Do not rename fields.
99+ If a semantic change is needed, add a new field and deprecate the old one.
1010+3. **No Type Changes**: Once published, a field's type is fixed.
1111+4. **Version by Copying**: If a breaking change is absolutely required, create a new Lexicon with a new major version or a new name (e.g., `app.malfestio.noteV2`).