How ayaan-22/forger works
Project Type and Purpose
• This is a full-stack real-time chat application ("Forger").
• Frontend: React single-page app (Vite + Tailwind + Zustand).
• Backend: Node.js/Express REST API plus Socket.IO for real-time messaging.
• Persistence: MongoDB (via Mongoose).
• External service: Cloudinary for user image uploads.
File Structure
• client/ – React code organized into pages, components, constants, lib (axios helper), store (Zustand).
• server/ – Express entry point (index.js), controllers (auth, message), routes, middleware (JWT auth), models (User, Message), lib (db connection, socket setup, Cloudinary).
Main Components
a. Frontend SPA
• Pages (Home, Login, Signup, Profile, Settings)
• Components (Navbar, ChatContainer, MessageInput, etc.)
• State stores (useAuthStore, useChatStore, useThemeStore)
b. Backend API Server
• REST API endpoints (/auth, /messages) handled by authControllers & messageControllers
• JWT auth middleware
• Socket.IO server instance
• DB connector via db.js
• Cloudinary integration via cloudinary.js
c. Database
• MongoDB (User & Message collections)
d. External Services
• Cloudinary (image uploads)
Relationships and Data Flows
• Frontend → Backend (HTTP/REST via Axios) for signup, login, profile fetch, message history.
• Frontend ↔ Backend (WebSocket via Socket.IO) for real‐time message send/receive.
• Backend → Database (MongoDB) to persist/fetch users & messages.
• Backend → Cloudinary for storing/retrieving uploaded avatars or images.
Architectural Patterns & Design Principles
• SPA (decoupled client + server)
• MVC‐style on server (routes → controllers → models)
• Middleware for auth enforcement
• State management (Zustand) on client
• Real-time publish/subscribe via Socket.IO