How focush67/mirrit works
Main Components
• Client / Frontend:
• NextJS App: This is represented by the “app” directory where NextJS pages and layouts are defined. Break down into subcomponents like authentication (sign-in, sign-up), dashboard, routes for posts, profile, chat (both individual and group), notifications, etc.
• UI Components: Represent the reusable UI elements (found in “components”). These include buttons, modals, chat components, navigation, story components, etc.
• State Management: Show the Redux store (in “redux_store”) plus context providers (in “context” and “providers”) that manage UI state, notifications, and toast messages.
• Backend / Server Components:
• API Endpoints: Outline the “app/api” routes. These include endpoints for posts, user actions, file uploads via UploadThing, and webhooks (especially for Clerk).
• Server Actions: Include the “server_actions” module which centralizes business logic for chat, follows, groups, posts, stories, etc.
• Services Layer: Indicate the “services” directory where authentication, posts, chat, follow, notifications, and other business logic is encapsulated.
• Utility Functions: Represent “utilities” which include database operations, date formats, Pusher setup, and UploadThing helpers.
• Database & ORM:
• MongoDB: As mentioned in the README, this is your main data store.
• Prisma: The “prisma/schema.prisma” file ensures you have an ORM to interact with MongoDB.
• External Integrations:
• Clerk: For authentication and user management.
• UploadThing: For file upload handling.
• Pusher: For realtime notifications (integrated via utilities and external configuration).
Relationships & Interactions
• Frontend interactions:
• The NextJS client issues API calls (from “app/api”) to trigger server actions.
• UI components are organized via pages and layouts, which compose the overall user experience.
• Redux and context providers (from “redux_store” and “providers”) manage state and share data across components.
• API & Server:
• The API endpoints receive HTTP (or server action) calls from the frontend, call into the relevant services that encapsulate business logic, and then interact with the database via Prisma.
• Server Actions are used for complex operations like realtime chat, group management, and notifications.
• Database and External Services:
• Services interact with MongoDB (through Prisma) for persisting user data and social interactions.
• Realtime features are handled by sending messages through Pusher.
• Authentication workflows are routed via Clerk and validated via the “/api/webhooks/clerk” endpoint.
• File uploads are managed by UploadThing (with a dedicated core and route).
Architectural Patterns & Design Principles
• Separation of Concerns:
• The project separates UI presentation (pages and components) from business logic (services and server actions) and data persistence (Prisma & MongoDB).
• Modular Structure:
• Each domain (chat, posts, profile, groups, notifications) has its own set of components, API routes, and services.
• Clear Data Flow:
• Data is managed by Redux/context, transferred through API endpoints to the server, which then updates the database and triggers notifications.
• External integrations act as specialized modules (authentication, realtime updates, uploads).
Elements
• Use clearly labeled nodes for:
• Frontend (with sub-nodes for Authentication, Dashboard, Posts, Chat, Notifications).
• API Layer (listing endpoints for posts, user, save, uploadthing, and webhooks).
• Server Actions and Services (showing business logic such as chat, follow, posts, groups).
• Database (MongoDB and Prisma ORM).
• External Services (Clerk, UploadThing, Pusher).
• From the Client to API endpoints.
• From API endpoints to server actions and services.
• From services to the Database.
• From services to external services (for authentication, realtime updates, and file handling).