🗂️ File System: Private vs. Public
CICADA implements a dual file system concept to cater to different access and privacy requirements for documents. This distinction is managed through separate Supabase tables, storage buckets, and Row Level Security (RLS) policies.Private File System
- Purpose: Allows users to upload and manage documents that are personal or sensitive and should not be accessible by others.
- Storage:
- Database Table:
public.documents_private - Supabase Storage Bucket:
private-files - Embeddings Table:
public.private_vectors
- Database Table:
- Access Control:
- Strict RLS policies ensure that a user can only access, modify, or delete their own private documents and associated vectors.
- Operations are tied to the authenticated user’s ID (
auth.uid()).
- Organization: Users can create and manage their own folder structures within their private space.
- Search: When an authenticated user performs a search, the RAG system queries their
private_vectorsin addition to public vectors, ensuring their private documents are included in search results visible only to them.
Public File System
- Purpose: Hosts documents that are intended for public access and general knowledge sharing.
- Storage:
- Database Table:
public.documents_public - Supabase Storage Bucket:
public-files(configured as a public bucket) - Embeddings Table:
public.public_vectors
- Database Table:
- Access Control:
- Read: Anyone (authenticated or unauthenticated) can read public documents and their content.
- Write/Modify/Delete: Restricted to authenticated users, typically administrators or designated uploaders. RLS policies ensure only the uploader (
uploader_user_id) can modify or delete their own public document contributions unless service role overrides are used.
- Organization: Public documents are organized into predefined categories (e.g., “Legislation”, “Case Law”) which act as top-level folders.
- Search: Public documents and their vectors are accessible in search results for all users.
Key Differentiators
User Interface
- In the admin file management section (
src/components/admin/FileTable.tsx), users can toggle between viewing and managing their “Private Files” or “Public Files”. - The
UploadForm.tsxallows users to specify whether a document should be uploaded to the private or public system.
Implications for AI Search
- The RAG system (
cleoChatEdge Function) is designed to query bothpublic_vectorsand, if the user is authenticated,private_vectors(filtered byuser_id). - This ensures that search results are comprehensive, including relevant public documents for everyone and private documents specifically for the logged-in user.
- The
match_documentsPostgreSQL function has logic to handle filtering byuser_idwhen querying private vectors.