maarcadetweet: initial commit

AT Protocol PDS + AppView + Tauri Desktop Client, 160-char post limit.

- PDS (Rust + axum + sqlx)
  - Auth: createAccount, createSession, refreshSession
  - Records: createRecord, deleteRecord (race-safe via SELECT FOR UPDATE)
  - Feed: feed.like.create, feed.repost.create
  - Sync: getRepo, getBlocks, getLatestCommit, getRecord (with MST proof), listRepos
  - Identity: resolveHandle
  - MST: spec-conformant (at-mst crate, 27 tests)
  - Repo: signed commits, TID counter (monotonic, 4096 wrap safe)

- AppView (Rust + axum + sqlx)
  - Jetstream consumer (WebSocket, exponential backoff, 38k+ events indexed)
  - REST API: timeline/home (graph-aware), profile, search, post (with thread hydration)
  - Handle-sync worker (did:plc + did:web)
  - JSONB embed storage + thread columns (migration 0003)
  - Like/repost counter cache (migration 0004)

- Tauri 2 + Svelte 5 Desktop Client
  - System tray (Show/Compose/Quit menu)
  - OS notifications (tauri-plugin-notification)
  - Auto-update (tauri-plugin-updater, placeholder endpoint)
  - Window-state (tauri-plugin-window-state)
  - 160-char compose with live counter
  - Image/Link embed rendering
  - LocalStorage-persisted like state
  - Timeline with poll (prepend new posts)
  - Custom TitleBar (transparent, no decorations)
  - Orange/IBM Plex Mono maarcade design

Tests: 231 Rust + 9 vitest = 240 passed.
This commit is contained in:
tomdebone
2026-07-05 20:01:31 +02:00
commit c586fd39c9
134 changed files with 35279 additions and 0 deletions
+99
View File
@@ -0,0 +1,99 @@
-- PDS database schema (initial)
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
-- =====================================================
-- users
-- =====================================================
CREATE TABLE users (
did TEXT PRIMARY KEY, -- did:plc:...
handle TEXT NOT NULL UNIQUE, -- alice.maarcadetweet.local
email TEXT, -- nullable for did:web
password_hash TEXT, -- argon2id; nullable
signing_key BYTEA NOT NULL, -- compressed secp256k1 pubkey
rotation_key BYTEA NOT NULL, -- for PLC rotation ops
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX users_handle_idx ON users (LOWER(handle));
-- =====================================================
-- repos
-- =====================================================
CREATE TABLE repos (
did TEXT PRIMARY KEY REFERENCES users(did) ON DELETE CASCADE,
rev TEXT NOT NULL, -- TID-encoded revision counter
head_cid BYTEA NOT NULL, -- CID of latest commit
head_commit BYTEA NOT NULL, -- CBOR block of latest commit
prev_commit BYTEA, -- for fast linear back-link
indexed_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
-- =====================================================
-- repo blocks (MST nodes + records)
-- =====================================================
CREATE TABLE repo_blocks (
did TEXT NOT NULL,
cid BYTEA NOT NULL,
block BYTEA NOT NULL,
size INTEGER NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
PRIMARY KEY (did, cid)
);
CREATE INDEX repo_blocks_did_idx ON repo_blocks (did);
-- =====================================================
-- blobs
-- =====================================================
CREATE TABLE blobs (
cid TEXT PRIMARY KEY, -- bafy...
did TEXT NOT NULL,
mime_type TEXT NOT NULL,
size BIGINT NOT NULL,
storage_key TEXT NOT NULL, -- S3 object key
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX blobs_did_idx ON blobs (did);
-- =====================================================
-- sessions
-- =====================================================
CREATE TABLE sessions (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
did TEXT NOT NULL REFERENCES users(did) ON DELETE CASCADE,
access_jwt TEXT NOT NULL, -- ES256K signed
refresh_jwt TEXT NOT NULL, -- ES256 signed (different key)
access_expires_at TIMESTAMPTZ NOT NULL,
refresh_expires_at TIMESTAMPTZ NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
revoked_at TIMESTAMPTZ
);
CREATE INDEX sessions_did_idx ON sessions (did);
-- =====================================================
-- plc operations (audit log of submitted ops)
-- =====================================================
CREATE TABLE plc_ops (
id BIGSERIAL PRIMARY KEY,
did TEXT NOT NULL,
prev TEXT, -- CID of previous op, or null for create
op_cid TEXT NOT NULL,
signed_op BYTEA NOT NULL, -- DAG-CBOR
submitted BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX plc_ops_did_idx ON plc_ops (did);
-- =====================================================
-- update trigger for users.updated_at
-- =====================================================
CREATE OR REPLACE FUNCTION touch_updated_at() RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER users_touch BEFORE UPDATE ON users
FOR EACH ROW EXECUTE FUNCTION touch_updated_at();