supabase/β All backend code, Edge Functions, and migrationssupabase/functions/β Supabase Edge Functions (serverless API endpoints)create-conversation/β Implemented: Handles conversation creation (used by frontend)get-conversations/β Placeholder (add code if needed)get-messages/β Placeholder (add code if needed)get-user-permissions/β Placeholder (add code if needed)send-message/β Placeholder (add code if needed)
supabase/migrations/β Database migration files (SQL)supabase/config.tomlβ Supabase project config
sql/policies/β (Optional) SQL files for RLS policies
src/β All React app codesrc/api/β API calls (calls Edge Functions or Supabase directly)src/components/β React UI componentssrc/pages/,src/hooks/, etc. β App logic and UI
public/β Static assets for the frontend.envβ Environment variables for frontend (Supabase URL/keys)
package.json,vite.config.ts,tsconfig.json, etc. β Project configREADME.mdβ This file
Real-time updates for all conversations are now handled globally using the ConversationSubscriptions component. This ensures users receive updates for all their conversations, not just the currently open one.
How it works:
src/components/ConversationSubscriptions.tsxusesuseConversationsto get all conversation IDs for the current user.- For each conversation, it renders a hidden subscription using
useRealtimeMessages. - The component is rendered at the top level of the
Messagespage.
Usage Example:
// src/pages/Messages.tsx
import { ConversationSubscriptions } from '../components/ConversationSubscriptions';
export default function Messages() {
// ...existing code...
return (
<div>
<ConversationSubscriptions />
{/* ...rest of your layout... */}
</div>
);
}Extending:
- To add new real-time events, update
useRealtimeMessagesand/or the Edge Functions as needed. - No need to manually subscribe/unsubscribe in each chat window.
Vanish supports a social posts feature, allowing users to create, view, and interact with posts. Posts are displayed on the Home page and can be created via a modal dialog.
Key Components & Hooks:
src/components/PostList.tsxβ Displays a list of posts.src/components/CreatePostModal.tsxβ Modal for creating a new post.src/hooks/usePosts.tsβ Custom hook for fetching and creating posts.
How it works:
- Posts are fetched and managed using the
usePostshook, which interacts with Supabase directly. - The Home page (
src/pages/Home.tsx) displays posts and provides a button to open the create post modal.
Usage Example:
// src/pages/Home.tsx
import { PostList } from '../components/PostList';
import CreatePostModal from '../components/CreatePostModal';
import { usePosts } from '../hooks/usePosts';
export default function Home() {
const { posts, createPost } = usePosts();
// ...existing code...
return (
<>
<PostList posts={posts} />
<CreatePostModal onCreate={createPost} />
</>
);
}Extending:
- To add new post features (e.g., comments, likes), extend the
usePostshook and related components.
Edge Functions are serverless API endpoints deployed to Supabase. Only create-conversation is implemented by default. Others are placeholdersβadd code as needed.
create-conversation: Handles creation of conversations and participants in a single transaction, bypassing RLS issues. Used by the frontend for all new conversation creation.get-conversations,get-messages,get-user-permissions,send-message: Placeholders. Implement as needed for advanced backend logic or security.
To add or update an Edge Function:
- Add or edit code in
supabase/functions/<function-name>/index.tsfor your desired function (e.g.,create-conversation,get-messages, etc.). - Deploy the function with:
You can deploy multiple functions by running the command for each one.
npx supabase functions deploy <function-name>
- Call the deployed function from the frontend using the
/functions/v1/<function-name>endpoint.
- All schema and RLS changes should be made as migration files in
supabase/migrations/. - To apply migrations locally:
npx supabase db reset(WARNING: this wipes local data!) - To push migrations to remote:
npx supabase db push(requires project to be linked) - RLS policies may also be managed in
sql/policies/for reference, but only migrations insupabase/migrations/are applied automatically.
Vanish supports user authentication with login and signup flows. Authentication state is managed globally using AuthContext and the useAuth hook.
Key Files:
src/pages/Login.tsxβ Login pagesrc/pages/Signup.tsxβ Signup pagesrc/AuthContext.tsxβ Authentication context and logic
Usage Example:
import { useAuth } from '../AuthContext';
const { login, signup, logout, isAuthenticated } = useAuth();
// Use these methods in your components for authentication actionsUsers can view and edit their profile, including display name, profile picture, and bio. Settings are managed via modals and custom hooks.
Key Files:
src/pages/Profile.tsxβ User profile pagesrc/pages/Settings.tsxβ Settings pagesrc/hooks/useUserData.tsβ Fetch and update user datasrc/hooks/useSettings.tsβ Manage user settings
Vanish provides a toast notification system for user feedback. Use the useToast hook to trigger notifications, and wrap your app with ToastProvider.
Key Files:
src/components/ToastProvider.tsxβ Toast context providersrc/hooks/useToast.tsβ Toast hook
Usage Example:
import { useToast } from '../hooks/useToast';
const { addToast } = useToast();
addToast('Profile updated!', 'success');Pages that require authentication are wrapped with the ProtectedRoute component to prevent unauthorized access.
Key File:
src/components/ProtectedRoute.tsx
- Modals: Used for creating posts and editing settings (
CreatePostModal,SettingsModal). - Particles & Animations: Visual enhancements using
Particles.tsxand Framer Motion. - Sidebar Navigation: Quick navigation and actions via
Sidebar.tsx.
The landing page (Landing.tsx) provides an introduction and call-to-action for new users.
Custom types for user profiles and other entities are defined in src/types/.
Vanish/
βββ supabase/ # π¦ Supabase backend (Edge Functions, migrations, config)
β βββ config.toml # Supabase project config
β βββ migrations/ # Database migration files (SQL)
β β βββ *.sql # Migration scripts (schema, RLS fixes, etc.)
β βββ functions/ # Supabase Edge Functions (serverless API endpoints)
β βββ create-conversation/ # Implemented Edge Function (conversation creation)
β β βββ index.ts
β βββ get-conversations/
β βββ get-messages/
β βββ get-user-permissions/
β βββ send-message/
βββ sql/
β βββ policies/ # (Optional) SQL files for RLS policies
βββ src/ # π© Frontend (React app)
β βββ api/ # API layer (calls Edge Functions or Supabase directly)
β βββ components/ # React UI components
β βββ hooks/ # Custom React hooks
β βββ pages/ # Page components
β βββ assets/ # Static assets (images, icons)
β βββ types/ # TypeScript type definitions
β βββ App.tsx, main.tsx, ...# Main app files
β βββ supabaseClient.ts # Supabase client config for frontend
βββ public/ # Static assets for frontend
βββ .env # Environment variables (Supabase URL/keys for frontend)
βββ package.json, ... # Project config
βββ README.md # Project documentation (this file)
βββ ... # Other config files (Vite, Tailwind, etc.)
- π¦ = Supabase backend (Edge Functions, migrations, config)
- π© = Frontend (React app)
- Edge Functions (called via
/functions/v1/<function-name>):create-conversation(used insrc/api/messagesApi.ts)- (Add more as you implement them)
- Direct Supabase API (called via
supabase-js):- Posts (see
src/hooks/usePosts.ts), user profiles, and some messaging features
- Posts (see
- Clone the repository:
git clone <repository_url> cd Vanish
- Install dependencies:
npm install
- Configure environment variables:
Create a
.envfile in the project root and add your Supabase credentials:VITE_SUPABASE_URL=<your_supabase_url> VITE_SUPABASE_ANON_KEY=<your_supabase_anon_key> - Set up Supabase database:
- Apply migrations:
npx supabase db reset(local) ornpx supabase db push(remote) - (Optional) Run SQL from
sql/policies/in the Supabase SQL editor for reference
- Apply migrations:
- Deploy Edge Functions:
- Deploy at least
create-conversationfor messaging to work:npx supabase functions deploy create-conversation - Deploy others as you implement them
- Deploy at least
- Run the application:
The app will be available at http://localhost:5173.
npm run dev
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Main App: src/App.tsx
- Real-time Messaging: src/components/ConversationSubscriptions.tsx, src/hooks/useRealtimeMessages.ts
- Posts: src/components/PostList.tsx, src/components/CreatePostModal.tsx, src/hooks/usePosts.ts
- Messages API: src/api/messagesApi.ts
- Auth Context: src/AuthContext.tsx
- Supabase Client: src/supabaseClient.ts
- Edge Functions: supabase/functions/
- Migrations: supabase/migrations/
This project is licensed under the terms specified in the repository LICENSE file.