How chunkangwong/slack-clone works
Project type and purpose
• This is a full-stack, real-time chat application (“Slack clone”) built with Next.js on the frontend, Convex for backend functions and data, and shadcn/ui for styling.
• Users can sign in/up, create or join workspaces, channels, direct-message other members, send/receive messages, react, and upload attachments.
File structure
• Top-level config files: next.config.mjs, tsconfig.json, tailwind.config.ts, bun.lockb, package.json
• “convex/”: all backend functions, API definitions, schema & auth config
• “src/app/”: Next.js 13 “app” directory—page routes for auth, join, workspace, channel, member
• “src/components/” & “src/features/”: React UI components and feature slices (auth, channels, messages, workspaces, members, reactions, upload)
• “src/hooks/” and “src/lib/”: custom hooks and utilities
• Middleware.ts, React-Query & Convex providers, static assets in “public”
Key insights from the README
• Uses Next.js for SSR/SSG & routing, @convex/react & custom hooks for data fetching/mutations, React-Query wrapper for caching, react-hook-form for forms
• Deployed serverless on Vercel, Convex functions run in a serverless environment and persist in Convex’s database
Main components and their relationships
a. Frontend (Next.js App)
• Browser ▶ Next.js pages & layouts ▶ React components
• Uses UI library (shadcn/ui) + feature modules + custom hooks
• React-Query & Convex client provider handle data fetching & mutations
b. Backend (Convex Serverless Functions)
• Endpoints defined in convex/*.ts (e.g., messages.ts, channels.ts, auth.ts)
• Exposed via the Convex client (uses api.js / server.js under the hood)
c. Database (Convex Data Storage)
• Schema defined in convex/schema.ts
• All reads/writes happen through Convex functions for security rules
d. Authentication & Authorization
• Managed by Convex’s auth.config.ts plus Next.js middleware
e. File Uploads
• generateUploadUrl Convex function returns signed URL; client uploads to (likely) a cloud storage bucket
f. Hosting & Deployment
• Next.js static assets and serverless functions on Vercel
• Convex functions & DB in Convex cloud
Architectural patterns & design principles
• Client-Server separation: Next.js frontend vs. Convex backend
• Feature-based folder structure in frontend: each domain (channels, messages, workspaces, etc.) has its own API hooks, components & store logic
• Serverless functions as micro-endpoints: each Convex file maps to a logical operation
• Data fetching & caching with React-Query & custom hooks
• Form management with react-hook-form