How aries-0331/bookmark-assistant works
Purpose and topology
Bookmark Assistant is a self-hostable Chrome extension plus Node.js server that captures browser bookmarks, Reading List entries, current pages, and context-menu links, then synchronizes them into a user’s Notion database. It is a pnpm TypeScript monorepo with deployable extension/server applications and reusable core packages.
Extension entry points and browser boundary
Chrome loads the extension through packages/extension/public/manifest.json. The persistent orchestration point is the background runtime at packages/extension/src/background/index.ts; user-facing entry points are the popup at packages/extension/src/popup/popup.tsx and options application at packages/extension/src/options/options.tsx.
The extension is the boundary to Chrome APIs: it reads bookmarks/Reading List, registers browser actions/context menus, obtains page content, and persists local state in Chrome storage. It communicates with the configured self-hosted server rather than calling Notion directly for sync.
Capture and local normalization
Capture paths include background extraction and content-side description extraction:
• packages/extension/src/background/content-extractor.ts
• packages/extension/src/content/description-extractor.ts
• packages/extension/src/utils/bookmark.ts
The extension transforms browser-specific bookmark, Reading List, and page/link data into normalized sync payloads. Shared link/content rules live in packages/extension-core/src/content.ts, packages/extension-core/src/links.ts, and packages/extension-core/src/reading-list.ts, separating reusable capture semantics from Chrome UI/runtime code.
Extension sync orchestration
The background sync layer coordinates manual, scheduled, and stateful synchronization:
• packages/extension/src/background/sync.ts
• packages/extension/src/background/auto-sync.ts
• packages/extension/src/background/server-api.ts
It sends normalized records to the server, tracks fingerprints/sync state locally, and updates popup/options state. Authentication is initiated through packages/extension/src/background/oauth.ts; server configuration and extension identity constraints are centralized in packages/extension/src/background/config.ts.
Server API, authentication, and persistence
The Node.js server starts at packages/server/src/index.ts and composes HTTP routes from packages/server/src/routes/index.ts. Route groups cover bookmark ingestion, Notion operations, OAuth, user state, and administration, including packages/server/src/routes/bookmarks.ts and packages/server/src/routes/oauth.ts.
Authentication/security middleware sits at the API boundary in packages/server/src/middleware/auth.ts and packages/server/src/middleware/security.ts. The server uses JWT-based authorization and is configured to accept the designated extension identity. PostgreSQL persistence is modeled through Prisma in packages/server/prisma/schema.prisma, with migrations under packages/server/prisma/migrations.
Notion synchronization pipeline
Server-side bookmark handling converts submitted records into Notion database operations while preserving deduplication and result state:
• packages/server/src/services/notion.ts
• packages/server-core/src/bookmarks.ts
• packages/server-core/src/notion-database.ts
The server owns stored Notion access tokens and connects to the Notion API on behalf of authenticated users. Core logic handles database/property mapping, URL and sync-ID matching, persistence abstractions, and per-item sync results through packages/server-core/src/notion-properties.ts, packages/server-core/src/persistence.ts, and packages/server-core/src/sync-results.ts.
Shared contracts and deployment
packages/contracts/src/types.ts and packages/contracts/src/index.ts define cross-package data shapes; packages/server-core/src/index.ts and packages/extension-core/src/index.ts expose reusable domain logic. This limits direct coupling between the Chrome runtime and server implementation.
Material runtime dependencies are Chrome extension APIs, Node.js 20.x for the server, PostgreSQL/Prisma, and the external Notion API/OAuth service. The server includes Vercel deployment configuration at packages/server/vercel.json; extension builds are produced by Vite configuration in packages/extension/vite.config.ts.
Main entry points: background/index.ts Background runtime · notion.ts Notion sync service · routes/index.ts HTTP routes · oauth.ts OAuth routes
Components 18
Chrome Extension
Browser runtime and capture orchestration.
- Extension manifest
packages/extension/public/manifest.json - Popup & options · User controls and sync status.
packages/extension/src/popup/popup.tsx - Background runtime · Persistent browser event and capture coordinator.
packages/extension/src/background/index.ts - Capture & normalization · Extracts page data and normalizes browser records.
packages/extension/src/background/content-extractor.ts - Sync orchestration · Runs manual and scheduled sync and tracks local state.
packages/extension/src/background/sync.ts - OAuth & server config · Initiates authentication and enforces server identity configuration.
packages/extension/src/background/oauth.ts
Shared Packages
Reusable capture and server domain logic.
- Extension capture rules · Shared link, content, and Reading List semantics.
packages/extension-core/src/content.ts - Cross-package contracts · Sync request and response data shapes.
packages/contracts/src/types.ts - Sync domain core · Deduplication, mapping, persistence abstractions, and item results.
packages/server-core/src/bookmarks.ts
Node.js Server
Authenticated sync API and Notion integration.
- Server entry
packages/server/src/index.ts - HTTP routes · Bookmark, Notion, OAuth, user, and admin endpoints.
packages/server/src/routes/index.ts - Auth & security middleware · JWT authorization and extension identity validation.
packages/server/src/middleware/auth.ts - Bookmark ingestion · Receives normalized extension records.
packages/server/src/routes/bookmarks.ts - OAuth routes · Connects user accounts to Notion.
packages/server/src/routes/oauth.ts - Notion sync service · Converts submitted bookmarks into Notion operations.
packages/server/src/services/notion.ts
External Systems
- Chrome APIs · Bookmarks, Reading List, tabs, context menus, and storage.
- PostgreSQL via Prisma · Stores users, sync state, and Notion access tokens.
packages/server/prisma/schema.prisma - Notion API & OAuth
Connections 22
- Extension manifest → Background runtime: loads
- Extension manifest → Popup & options: loads
- Chrome APIs → Background runtime: browser events
- Popup & options → Background runtime: user actions
- Background runtime → Capture & normalization: collects
- Capture & normalization → Extension capture rules: applies rules
- Background runtime → Sync orchestration: triggers
- Sync orchestration → Cross-package contracts: serializes payloads
- Sync orchestration → HTTP routes: sync API
- Background runtime → OAuth & server config: auth flow
- OAuth & server config → OAuth routes: OAuth requests
- Server entry → HTTP routes: composes
- HTTP routes → Auth & security middleware: protects routes
- Auth & security middleware → Bookmark ingestion: authorizes
- HTTP routes → OAuth routes: routes OAuth
- Bookmark ingestion → Notion sync service: submits records
- Notion sync service → Sync domain core: uses sync rules
- Sync domain core → PostgreSQL via Prisma: reads and writes state
- Notion sync service → Notion API & OAuth: database operations
- OAuth routes → Notion API & OAuth: authorization
- OAuth routes → PostgreSQL via Prisma: stores tokens
- Notion sync service → Cross-package contracts: returns results