ROADMAP — Multi-Library & AI Optimization
Status (Aug 2026)
| Phase | Status |
|---|---|
| 1 — Editable title | ✅ Done |
2 — libraries schema + switcher MVP | ✅ Done (SQL applied; app reads/writes libraries) |
3a — buildLibraryContext | ✅ Done (src/lib/library-ai-context.mjs) |
| 3b — Public JSON-LD | ✅ Done (/l/{token}) |
| 3c — Gemini auto-fill title/description | ✅ Done (library-ai Function + UI) |
| 4 — AI export / recommend / README | ⏳ Partial — recommend empty-library examples ✅ |
| 5 — Multi-library UX | ✅ Done (shipped with Phase 2) |
Cleanup — drop dormant user_profiles.library_* | ⏳ Optional later |
user_profiles note: Library title/description/share live on libraries only. user_profiles is still used for author fields (public_display_name, public_avatar_url, public_show_author). Legacy library_* / share_* columns on user_profiles are unused by the app after migration — safe to leave until a dedicated drop migration.
Public discovery (read): MCP list_public_libraries / search_public_libraries / get_public_library, site search type: "library", sitemap, and chatbot proxy (parallel public-library search) all read share-enabled libraries.
Context
PATTTTERNS supports N libraries per user with editable title, share token, and AI context description. Architecture: Supabase REST + RLS from the client (library-cloud.ts / bookmark-cloud.ts) — no Prisma.
Constraints:
- Patterns may belong to one or many libraries (M2M via
bookmark_on_library). - Pricing / plan gating is not in scope.
- Token share URLs (
/l/{token}) are canonical; username slugs stay later (Public Libraries PRD).
Goals
- Editable library title
- Library context (description) for AI
- Multiple libraries per user + switcher
- Patterns assignable to multiple libraries
- Gemini auto-fill when title is default and/or description empty
- AI recommend examples for empty libraries with context
- AI export / README (rest of Phase 4)
Non-Goals (this roadmap)
- Pricing tiers or
isProenforcement. - Username SEO slug URLs (tracked in Public Libraries PRD).
- Full CMS / Notion replacement.
Data model (current)
auth.users
│ 1:N
▼
libraries (title, description, share_token, share_enabled, is_default, position)
│
│ M:N via bookmark_on_library
▼
bookmarks (pattern payload)
user_profiles — author display fields only (not library chrome)
SQL: docs/queries/DB_LIBRARIES_MULTILIBRARY.sql
Phased Roadmap
Phase 1 — Editable Library Title ✅
Shipped: inline rename (now via library tabs), persistence on libraries.title.
Phase 2 — Schema + multi-folder MVP ✅
libraries+bookmark_on_library+ RLS + backfilllibrary-cloud.ts/bookmark-cloud.tscut over- Share via
/l/{token}+/library?token= - Switcher, create, rename, delete (non-default),
?lib= - Save picker when user has multiple libraries
- Drawer filter + per-library counts
- Public shared library: save-to picker + duplicate as new owner library
- Drop dormant
user_profiles.library_*/share_*columns (optional)
Phase 3 — AI context ✅ (core)
3a — Structured context object ✅
src/lib/library-ai-context.mjs — buildLibraryContext() grounds title, curator, description, top tags, and up to 20 patterns.
3b — JSON-LD for public libraries ✅
Canonical /l/{token} injects ItemList JSON-LD (Public Libraries PRD).
3c — Gemini auto-fill ✅
- Netlify Function:
POST /.netlify/functions/library-ai(alias/api/v1/library-ai) - Auth: owner Bearer token
- Fills title only if still default (
My Pattern Library/ empty) - Fills description only if empty
- Requires ≥1 pattern in the library
- UI: Auto-fill with AI on owner
/librarycontext field
Phase 4 — AI Features: Export & Build From Patterns ⏳
- Pattern recommender (empty library → Auto-load examples with AI from title/context)
- Code export from library context
- Shareable README / summary copy
library-ai action: "recommend" ranks search-index candidates, asks Gemini to pick 5–8, client upserts into the active library.
Phase 5 — Multiple Libraries Per User ✅
Merged into Phase 2 ship (client Supabase REST, not Next /api/libraries routes).
Exit criteria:
- Create / rename / delete additional libraries
- Patterns in multiple libraries (join table + save picker)
- Default library keeps working
- Switcher on
/library
Public listing (MCP / search / bot)
| Surface | Status |
|---|---|
MCP list_public_libraries | ✅ reads libraries |
MCP search_public_libraries | ✅ |
MCP get_public_library | ✅ |
Topbar search (type: "library") | ✅ listNonEmptyPublicLibraries |
| Chatbot proxy | ✅ parallel search_public_libraries in prompt |
Sitemap /sitemap-libraries.xml | ✅ |
Critical path doc
Close stage and multilibrary path — Stage close decisions (no public_library_index table; branded OG deferred).
Migration safety
- Do not drop
user_profiles.library_*in the same deploy that still reads them — app no longer reads them; drop can be a separate SQL change when ready. - Default library is created lazily via
ensureDefaultLibrary()(internal) / SQL backfill. - Deleting a library detaches join rows; bookmarks remain unless removed from all libraries.