WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: extract @atbb/db shared package from appview

Move the Drizzle ORM schema and connection factory into packages/db
so the database layer can be shared by future consumers (firehose
consumer, admin CLI, seed scripts). Appview now depends on @atbb/db
instead of owning drizzle-orm/postgres directly. Drizzle-kit config
stays in appview (migrations are app-level concerns).

https://claude.ai/code/session_014iuD1gNMNFLYgouQ5RhkJX

Claude 1e9a938c 99aad8ce

+68 -23
+2 -1
CLAUDE.md
··· 21 21 22 22 | Package | Description | 23 23 |---------|-------------| 24 + | `@atbb/db` | Drizzle ORM schema and connection factory for PostgreSQL | 24 25 | `@atbb/lexicon` | AT Proto lexicon definitions (YAML) + generated TypeScript types | 25 26 | `@atbb/spike` | PDS read/write test script for validating AT Proto operations | 26 27 27 - **Dependency chain:** `@atbb/lexicon` builds first (generates types), then `@atbb/appview` and `@atbb/web` build in parallel. Turbo handles this via `^build`. 28 + **Dependency chain:** `@atbb/lexicon` and `@atbb/db` build first, then `@atbb/appview` and `@atbb/web` build in parallel. Turbo handles this via `^build`. 28 29 29 30 ## Development 30 31
+1
README.md
··· 41 41 42 42 | Package | Description | 43 43 |---------|-------------| 44 + | [`packages/db`](packages/db) | Drizzle ORM schema and connection factory for PostgreSQL | 44 45 | [`packages/lexicon`](packages/lexicon) | AT Proto lexicon schemas (YAML) and generated TypeScript types | 45 46 | [`packages/spike`](packages/spike) | PDS read/write test script | 46 47
+1 -1
apps/appview/drizzle.config.ts
··· 1 1 import { defineConfig } from "drizzle-kit"; 2 2 3 3 export default defineConfig({ 4 - schema: "./src/db/schema.ts", 4 + schema: "../../packages/db/src/schema.ts", 5 5 out: "./drizzle", 6 6 dialect: "postgresql", 7 7 dbCredentials: {
+2 -3
apps/appview/package.json
··· 13 13 "db:migrate": "drizzle-kit migrate" 14 14 }, 15 15 "dependencies": { 16 + "@atbb/db": "workspace:*", 16 17 "@atbb/lexicon": "workspace:*", 17 18 "@atproto/api": "^0.15.0", 18 19 "@atproto/common-web": "^0.4.0", 19 20 "@hono/node-server": "^1.14.0", 20 - "drizzle-orm": "^0.45.1", 21 - "hono": "^4.7.0", 22 - "postgres": "^3.4.8" 21 + "hono": "^4.7.0" 23 22 }, 24 23 "devDependencies": { 25 24 "@types/node": "^22.0.0",
+2 -12
apps/appview/src/db/index.ts
··· 1 - import { drizzle } from "drizzle-orm/postgres-js"; 2 - import postgres from "postgres"; 3 - import * as schema from "./schema.js"; 4 - 5 - export function createDb(databaseUrl: string) { 6 - const client = postgres(databaseUrl); 7 - return drizzle(client, { schema }); 8 - } 9 - 10 - export type Database = ReturnType<typeof createDb>; 11 - 12 - export * from "./schema.js"; 1 + export { createDb, type Database } from "@atbb/db"; 2 + export * from "@atbb/db/schema";
apps/appview/src/db/schema.ts packages/db/src/schema.ts
+24
packages/db/package.json
··· 1 + { 2 + "name": "@atbb/db", 3 + "version": "0.1.0", 4 + "private": true, 5 + "type": "module", 6 + "main": "./dist/index.js", 7 + "types": "./dist/index.d.ts", 8 + "exports": { 9 + ".": "./dist/index.js", 10 + "./schema": "./dist/schema.js" 11 + }, 12 + "scripts": { 13 + "build": "tsc", 14 + "lint": "tsc --noEmit", 15 + "clean": "rm -rf dist" 16 + }, 17 + "dependencies": { 18 + "drizzle-orm": "^0.45.1", 19 + "postgres": "^3.4.8" 20 + }, 21 + "devDependencies": { 22 + "typescript": "^5.7.0" 23 + } 24 + }
+12
packages/db/src/index.ts
··· 1 + import { drizzle } from "drizzle-orm/postgres-js"; 2 + import postgres from "postgres"; 3 + import * as schema from "./schema.js"; 4 + 5 + export function createDb(databaseUrl: string) { 6 + const client = postgres(databaseUrl); 7 + return drizzle(client, { schema }); 8 + } 9 + 10 + export type Database = ReturnType<typeof createDb>; 11 + 12 + export * from "./schema.js";
+8
packages/db/tsconfig.json
··· 1 + { 2 + "extends": "../../tsconfig.base.json", 3 + "compilerOptions": { 4 + "outDir": "./dist", 5 + "rootDir": "./src" 6 + }, 7 + "include": ["src/**/*.ts"] 8 + }
+16 -6
pnpm-lock.yaml
··· 17 17 18 18 apps/appview: 19 19 dependencies: 20 + '@atbb/db': 21 + specifier: workspace:* 22 + version: link:../../packages/db 20 23 '@atbb/lexicon': 21 24 specifier: workspace:* 22 25 version: link:../../packages/lexicon ··· 29 32 '@hono/node-server': 30 33 specifier: ^1.14.0 31 34 version: 1.19.9(hono@4.11.8) 32 - drizzle-orm: 33 - specifier: ^0.45.1 34 - version: 0.45.1(postgres@3.4.8) 35 35 hono: 36 36 specifier: ^4.7.0 37 37 version: 4.11.8 38 - postgres: 39 - specifier: ^3.4.8 40 - version: 3.4.8 41 38 devDependencies: 42 39 '@types/node': 43 40 specifier: ^22.0.0 ··· 70 67 typed-htmx: 71 68 specifier: ^0.3.0 72 69 version: 0.3.1 70 + typescript: 71 + specifier: ^5.7.0 72 + version: 5.9.3 73 + 74 + packages/db: 75 + dependencies: 76 + drizzle-orm: 77 + specifier: ^0.45.1 78 + version: 0.45.1(postgres@3.4.8) 79 + postgres: 80 + specifier: ^3.4.8 81 + version: 3.4.8 82 + devDependencies: 73 83 typescript: 74 84 specifier: ^5.7.0 75 85 version: 5.9.3