How varadarajan-m/vi-messenger works
Project Type and Purpose
• VI Messenger is a real-time messaging application that supports personal and group chats with rich features such as AI chat with LLAMA-3, file sharing (multiple formats), message replies, real-time indicators (typing, online/offline), notifications, and PWA capabilities.
• The backend is implemented with Node.js, Express, and Socket.io combined with MongoDB for data persistence.
• The frontend is built with React, TypeScript, Tailwind CSS, and Zustand, providing a responsive and dynamic user interface.
Overall File Structure
• The project is organized into two main directories under the “apps” folder:
• apps/server: Contains all backend code. Notable directories include:
▸ controllers – handling business logic for authentication, chatting, messages, users, etc.
▸ routes – defining API endpoints (auth, chat, message, etc.)
▸ middlewares – handling request validation, authentication, and any additional processing.
▸ models – representing the MongoDB data structures (chat, message, user).
▸ db – managing the database connection.
▸ socket.ts – handling real-time websocket (Socket.io) connections.
• apps/web: Contains the complete frontend React application.
▸ src – includes components for authentication and chat (both private and AI chat), hooks for state management, API calls, utilities, and PWA-related files.
▸ Provided assets, configuration files, and service worker registration for PWA functionality.
a. Main Components:
• Client (Frontend): Represented by the “apps/web” project built in React (with TypeScript, TailwindCSS) that includes UI components, state management through Zustand, and API integrations.
• Server (Backend): Represented by the “apps/server” portion developed with Node.js and Express. It encompasses:
• API Controllers and Routes: Separate modules for handling user authentication, chat operations, messaging, etc.
• Middlewares: For authentication and request processing.
• Socket Management: Real-time communication via Socket.io.
• Database Connectivity: MongoDB connection handled in the “db” module.
• Database: MongoDB serves as the data persistence layer.
• External/AI Service (if applicable): Although implemented internally, the AI chat feature can be highlighted as a processing module (using LLAMA-3) that may interact with additional backend AI services or libraries.
b. Relationships and Data Flow:
• The browser-based client communicates with the server via two primary channels:
• HTTP REST API calls (for actions like login, registration, getting chat history, file uploads, etc.)
• WebSocket (Socket.io) for live messaging, typing indicators, and real-time notifications.
• On the server, API requests are first handled by middlewares (e.g., for authorization) and then routed to the appropriate controllers.
• Controllers interact with the data models to read/write from the MongoDB database.
• The chat and AI features are managed via dedicated modules that process and stream responses back to the client.
c. Architectural Patterns and Principles:
• Separation of concerns is clearly maintained: the frontend and backend are decoupled, each with its own workspace.
• MVC-like separation in the backend: controllers, models, and routes.
• Real-time communication using WebSockets.
• PWA architecture considerations in the frontend (service worker, manifest, offline indicators).
• Modular design: clear separation of utilities, validators, and custom hooks (for React).
d. Relevant Technologies:
• Frontend: React with TypeScript, Zustand (state management), Tailwind CSS, and Vite for bundling.
• Backend: Node.js, Express, Socket.io, TypeScript, and MongoDB.
• Additional libraries: ESLint configurations for code quality, custom validators, custom middlewares, and logger utilities.