How drishti2904/talkify-video_calling_chat_app works
Project type and purpose
• Talkify is a full-stack MERN (MongoDB, Express.js, React, Node.js) real-time chat and one-on-one video call application for language learners.
• Key features: JWT-based authentication, friend management, real-time messaging/video via GetStream.io, efficient client caching with TanStack Query, theming via Tailwind CSS + DaisyUI.
File structure
• Top level:
• backend/ (Express server)
• frontend/ (React app)
• package.json (root scripts, if any)
• backend/src:
• controllers (auth, chat, user) – MVC pattern
• models (User, FriendRequest) – Mongoose ODM
• lib (db.js → Mongo connection, stream.js → GetStream server SDK init)
• middleware (auth.middleware.js → JWT validation)
• routes (auth.route.js, chat.route.js, user.route.js)
• server.js (app entry point)
• frontend/src:
• pages (Login, SignUp, Home, Friends, Chat, Call, Notifications, Onboarding)
• components (Navbar, Sidebar, ChatLoader, PageLoader, CallButton, FriendCard, etc.)
• lib (api.js → REST calls wrapper, axios.js, utils.js)
• hooks (useAuthUser, useLogin, useSignup, useLogout)
• store (useThemeStore – Zustand or similar)
• constants, index.css, main.jsx, index.html
• config: Vite, ESLint, PostCSS, Tailwind
Extract additional insights from README
• Backend uses JWT for stateless authentication, Bcrypt for hashing, Mongoose for data persistence, GetStream.io server SDK to create/query chat channels and generate video tokens.
• Frontend initializes GetStream Chat client with SDK and API key, uses TanStack Query for data fetching/caching.
• The real-time channel is entirely managed by GetStream; backend’s chat.controller handles backend-only operations (e.g., moderation, server-side channel creation, friend requests).
Main components & their relationships
A. Client (Browser)
• React components & pages
• TanStack Query (data layer)
• GetStream Chat client SDK
• Axios calls → REST API
B. API Gateway (Express Server)
• Routes: /auth, /user, /chat
• Controllers → business logic
• Middleware → JWT auth
• stream.js → calls GetStream API
• db.js → connects to MongoDB
C. Data Store
• MongoDB (Collections: users, friend_requests)
D. External Service
• GetStream.io
• Chat & messaging channel management
• Video call signaling/Signaling tokens
E. Optional: Hosting/Env
• Environment variables (.env in backend and frontend)
• Deployed on e.g., Heroku/Vercel, Mongo Atlas
1. User ↔ React UI
2. React UI → REST API (via axios/api.js)
3. REST API → MongoDB (db.js, Mongoose models)
4. REST API → GetStream.io (stream.js)
5. React UI ↔ GetStream Chat SDK (Websocket over Stream’s hosted infra)
6. Data caching flows inside React via TanStack Query
Architectural patterns & design principles
• Layered architecture (Presentation / API / Data)
• MVC on the backend (Routes → Controllers → Models)
• Component-based UI on the frontend
• Stateless REST for auth/data, delegated real-time comms to GetStream
• Single responsibility: each controller handles one domain; hooks abstract authentication; lib folders centralize cross-cutting concerns
Elements
• Clear labels for each component (e.g., “AuthController”, “ChatPage.jsx”, “GetStream Chat Client SDK”)
• REST calls (Frontend → Backend)
• DB queries (Backend → MongoDB)
• External API calls (Backend → GetStream REST API)
• Websocket streams (Frontend ↔ GetStream Chat)
• Rectangles for code modules (e.g., controllers, pages)
a. Sketch two columns: Frontend (left), Backend (center), External/DB (right).
• UI Pages → Components → Hooks → API client → Stream SDK.
c. In Backend column, list:
• Incoming request → Middleware → Routes → Controllers → Libs → Models
• From API client → Express Route, label “HTTP POST /login” etc.
• From Controllers → MongoDB, label “Mongoose query”
• From Controllers → Stream SDK, label “Stream REST call”
• From React UI → Stream Chat SDK, label “WebSocket chat/video”
f. Authentication flow: annotate JWT generation (AuthController → client), JWT attached in headers (every API call via axios).
Detail without over-splitting
• Folder’s role but group leaf files (e.g., group all components under “Components”).
• Precise flows for chat vs REST.