2.8 KiB
2.8 KiB
Database & Architecture Todos
Server-Side & Schema Tasks
Schema Changes (Postgres/Supabase)
- Split
profilesTable:- Create
user_secretstable (Columns:user_id(PK, FK),openai_api_key,bria_api_key,replicate_api_key,settings,google_api_key). - Migrate data from
profilestouser_secrets(Ref:src/integrations/supabase/types.ts). - Drop secret columns from
profiles. - Rename
profilestoprofiles_public(optional, or just restrict access).
- Create
- Create
page_collaboratorsTable:- Columns:
page_id(FK),user_id(FK),role(enum: 'viewer', 'editor', 'owner'),created_at. - Add unique constraint on
(page_id, user_id).
- Columns:
- RLS Policies Update:
user_secrets: Enable RLS. Policy:auth.uid() = user_id.profiles: Policy: Public read. Update strictly limited to owner.pages: Policy:- Read:
is_publicORauth.uid() = ownerORauth.uid() IN (select user_id from page_collaborators). - Update:
auth.uid() = ownerORauth.uid() IN (select user_id from page_collaborators where role IN ('editor', 'owner')).
- Read:
Server Logic (Node/Hono)
- Implement
ServingProductEndpoints (Ref:server/src/products/serving/index.ts):GET /api/feed: Returns hydrated feed (Posts + Authors + Cover Images).GET /api/profile/:id: Returns public profile + recent posts.GET /api/me/secrets: (Secure) Returns user secrets for settings page.
- Server-Side Injection:
- Update
handleServeAppinServingProductto pre-fetch User & Feed. - Inject into
index.htmlaswindow.__INITIAL_STATE__.
- Update
Client-Side Tasks
src/lib/db.ts Refactor
- Deprecate Direct Selects: Identify all
supabase.from('posts').select(...)calls insrc/lib/db.ts. - Implement Proxy Clients:
- Create
fetchFeedFromProxy()calling/api/feedinsrc/lib/db.ts. - Create
fetchProfileFromProxy(id)calling/api/profile/:idinsrc/lib/db.ts.
- Create
- Hydration Logic:
- Check
window.__INITIAL_STATE__on app boot to populate React Query cache before fetching.
- Check
Component Updates
- Post Page:
- Use
fetchPostFromProxy(or standarddb.fetchPostByIdredirected to proxy) insrc/pages/Post.tsx. - Handle 404s gracefully (See Security.md for details).
- Use
- PageManager:
- Update
src/components/PageManager.tsxto fetch "My Pages" AND "Shared Pages".
- Update