# 2026-04-18 — Doc Service Redesign: Scalable UX + Group-Based Sharing **Timestamp:** 2026-04-18T00:00:00+00:00 ## Summary Complete redesign of the document management UX for scale (10 → 100 000 documents, 2 → 1 000 categories) and group-based document sharing. Replaced the monolithic DocumentsPage with a three-column layout (Sidebar + SourcePanel + main), a slide-over detail panel, a filter chip system, multi-file upload queue, and bulk actions. Added the full backend sharing stack: `document_shares` table, share CRUD endpoints, a shared-with-me view, and X-User-Groups header injection in the gateway proxy. --- ## Files Added | File | Description | |------|-------------| | `features/doc-service/app/models/document_share.py` | DocumentShare ORM model (document_id, group_id, shared_by_user_id) | | `features/doc-service/app/schemas/share.py` | DocumentShareOut, DocumentShareCreate, SharedDocumentOut schemas | | `features/doc-service/alembic/versions/0004_add_document_shares.py` | Migration creating document_shares table with indexes | | `frontend/src/components/SourcePanel.tsx` | Left panel (240px): views (All/Mine/Shared) + searchable category tree + new category form | | `frontend/src/components/ManageCategoriesDialog.tsx` | Category CRUD modal (inline rename, delete with confirm, search) | | `frontend/src/components/DocumentSlideOver.tsx` | Right slide-over (480px): metadata, inline title edit, type picker, AI suggestions, categories combobox, tags, sharing section, raw text, actions | --- ## Files Modified | File | Change | |------|--------| | `features/doc-service/app/models/__init__.py` | Import DocumentShare | | `features/doc-service/app/deps.py` | Added `get_user_groups` dependency (reads X-User-Groups header) | | `features/doc-service/app/schemas/document.py` | Added `share_count: int = 0` to DocumentOut | | `features/doc-service/app/routers/documents.py` | Complete rewrite: added share CRUD endpoints, shared-with-me endpoint, N+1-safe share_count, recipient download access, X-User-Groups enforcement | | `features/doc-service/STATUS.md` | Added sharing section, migration 0004, updated future work | | `backend/app/routers/documents_proxy.py` | Injects X-User-Groups header (queries GroupMembership per request) | | `backend/app/routers/categories_proxy.py` | Same X-User-Groups injection pattern | | `backend/app/routers/users.py` | Added GET /me/groups endpoint | | `backend/app/schemas/user.py` | Added UserGroupOut schema | | `backend/STATUS.md` | Added /me/groups endpoint | | `frontend/src/api/client.ts` | Added share_count to DocumentOut, SharedDocumentOut, DocumentShareOut, listSharedWithMe, getDocumentShares, addDocumentShare, removeDocumentShare, getMyGroups | | `frontend/src/components/Sidebar.tsx` | Removed per-category NavLinks; Documents is now a single NavLink under Apps | | `frontend/src/components/AppShell.tsx` | Renders SourcePanel between Sidebar and main on /apps/documents route | | `frontend/src/pages/DocumentsPage.tsx` | Complete rewrite: three-panel layout, view param (all/mine/shared), smart polling, drag-and-drop, multi-file upload queue, filter chip system, bulk actions bar | | `frontend/STATUS.md` | Complete rewrite reflecting all new components and patterns | | `CLAUDE.md` | Updated file tree, Database Models (DocumentShare), Migration chains (0004), API endpoints (shares, shared-with-me, /me/groups), TanStack Query keys, request flow diagram |