How laribright/slack-clone works
The project is a full-stack Slack clone built using Next.js 15, TypeScript, and Supabase. It also integrates several other technologies and external services (e.g., Uploadthing for file uploads, Socket.IO for real-time communications, Tailwind CSS along with Shadcn UI, and Supabase for authentication and database management). The architecture leverages both server-rendered and API route capabilities of Next.js, while also implementing custom business logic in the “actions” folder and using a clearly structured component hierarchy.
• Frontend Client: Represented by the “src/app” and “src/components” folders. This includes:
• Authentication routes and components (under “src/app/(authentication)”).
• Main application UI and workspace functionalities (under “src/app/(main)” including channels and direct messages).
• UI components, layouts, and other visual elements.
• API Endpoints: These are provided via both "src/app/api" and "src/pages/api". Highlight:
• API routes for direct messages, livekit (video or audio-related), messages, and file uploads (Uploadthing).
• WebSocket API endpoints under “src/pages/api/web-socket” handling real-time message exchange.
• Business Logic / Actions: Located in “src/actions”, which encapsulate common operations such as creating workspaces, adding members, handling channels, and user authentication.
• Database and External Service Integration:
• Supabase integration is critical. Represent the Supabase database and its associated server libraries (under “src/supabase” and “supabase” directories with configuration and seed data).
• SQL scripts (sql.txt) used to define the schema and database functions.
• External Services and Real-Time Communication:
• File Upload Service (Uploadthing integration in “src/app/api/uploadthing” and “src/lib/uploadthing.ts”).
• Real-time communication via Socket.IO endpoints (web-socket API routes).
• Providers and Global State:
• Application-wide state management (e.g., Zustand, React Hook Form) and global application providers in “src/providers” (theme, query state, and WebSocket connection).
Out the Relationships and Interactions
• How user actions from UI components trigger business logic (“src/actions”) and connect via API routes.
• Next.js server which renders pages, handles API endpoints, and employs middleware (see “src/middleware.ts”).
• From frontend components invoking API routes (HTTP requests) to the backend logic that, in turn, communicates with Supabase (or other external services).
• Real-time interactions through WebSocket endpoints for direct messaging and chat features.
• Authentication flow:
• Users begin at the auth pages (under “src/app/(authentication)”), which direct to backend for handling callback and confirmation.
• File upload flows via Uploadthing.
• Real-time messaging components working with Socket.IO endpoints.
Architectural Patterns and Design Principles
• Separation of Concerns: Differentiate between concerns by splitting the app into authentication, main application, API routes, and utility functions.
• Modular Structure: Emphasize the "actions" module for business logic and clear separation between UI components and backend logic.
• Use of Providers: Global contexts and state management (theme-provider, query-provider) which reflect dependency injection and centralized state.
• Notice the file naming conventions and folder structure that imply adherence to standard Next.js directory organization.
Relevant Technologies, Frameworks, and Libraries
• Next.js 15 and its app routing and API features.
• TypeScript for type safety.
• Supabase for database, authentication, and storage.
• Tailwind CSS and Shadcn UI for styling.
• Uploadthing for handling file uploads.
• Socket.IO (or similar WebSocket library as seen in the “web-socket” endpoints).