How daniserrano7/telegram-clone works
Project Type and Purpose
• This is a full-stack messaging application inspired by Telegram. The project consists of a real-time chat system, complete with user authentication, file uploads, and dynamic message functionalities.
• The frontend is built with React (TypeScript) using Zustand for state management and Tailwind CSS for styling. The backend is built with NestJS (Node.js) and uses WebSockets (Socket.io) for real-time communication, along with PostgreSQL (accessed via Prisma) for data storage.
Analyzing the File Structure
• Top-level directories include:
• server – Contains the backend REST API, WebSocket gateways, authentication, chat, user, database, and file upload logic.
• web – Contains the React frontend application including components, pages, services and state stores.
• shared – Contains reusable DTOs and types shared between the server and web.
• The presence of Docker configuration files, docker-compose, and environment files indicate support for containerization and deployment.
• The server directory clearly splits functionalities into modules such as auth, chat, user, db, and upload; showing an MVC or modular architecture.
• The web directory groups resources by components, hooks, stores, and pages, which is typical for a modern React codebase.
Key Components
a. Frontend (web):
• Components: UI elements (chat interface, authentication pages, settings, etc.)
• State Management: Zustand-based stores for auth, chat, user, etc.
• Services: Communication with backend via REST and WebSocket channels.
• External assets: Tailwind CSS, React components, and client-side routing.
b. Backend (server):
• Core Engine: NestJS application with modular structure.
• Modules:
• Auth Module (handles JWT-based authentication),
• Chat Module (manages chat functionalities and WebSocket communications),
• User Module (handles user management and statuses),
• Upload Module (manages file/file system storage),
• DB Module: Manages database interactions, using Prisma and PostgreSQL.
• WebSockets: Real-time communication gateway via Socket.io.
• Database: PostgreSQL (schema and migrations managed in the prisma folder).
• Additional: Configuration files (Docker, ESLint, Prettier) for consistency and deployment.
c. Shared Resources:
• Contains shared DTOs and interfaces used by both the frontend and backend to ensure consistency.
Architectural Patterns & Design Principles
• Separation of Concerns: Frontend and backend are separated completely, communicating via API endpoints and Socket.io.
• Real-Time Communication: Highlight use of WebSockets for chat features, including typing indicators and status updates.