How ankitsinghsisodya/bit-mitra works
Project type and purpose
• This is a full-stack social media web application (BIT-MITRA) with two main parts:
• Frontend: React + Redux SPA for users to view feeds, profiles, send messages
• Backend: Node.js/Express REST API + Socket.io for real-time chat
• Purpose: allow user registration/login, profile management, CRUD on posts/comments/likes, direct messaging, real-time notifications.
File structure
• Top-level directories:
• backend/
– controllers/ (message, post, user) – route handlers
– routes/ (message.route.js, post.route.js, user.route.js)
– models/ (user, post, comment, conversation, message) – Mongoose schemas
– middlewares/ (isAuthenticated, multer)
– socket/ (socket.js) – real-time logic
– utils/ (db connection, Cloudinary, data URI)
– index.js – Express app entry point
• frontend/
– src/components – page and UI components
– src/redux – slices and store
– src/hooks – custom data-fetch hooks
– public/index.html, vite.config.js, tailwind.config.js
• Config files: package.json, .gitignore in both dirs, ESLint, PostCSS.
Extract insights from the README
• REST API endpoints for users, posts, comments, likes
• JWT authentication via middleware
• Real-time features built with Socket.io
• Media storage via Cloudinary
• Data persisted in MongoDB
Main components
a. Frontend client
– React SPA (pages: Feed, Profile, Chat, etc.)
– Redux store for global state (authSlice, postSlice, chatSlice, socketSlice, etc.)
– HTTP client (Axios/fetch) for REST API
– WebSocket client (Socket.io-client) for real-time events
b. Backend server
– Express.js API layer
• Controllers: UserController, PostController, MessageController
• Routes: /api/users, /api/posts, /api/messages
• Middlewares: Authentication (JWT), File Upload (multer)
– Socket.io server for real-time chat/notifications
– Utility modules: DB connection, Cloudinary integration
c. Database
– MongoDB Atlas (collections: users, posts, comments, conversations, messages)
d. External services
– Cloudinary for image/video uploads
– (Optional) CDN for serving static assets
e. Authentication & Security
– JWT tokens passed in HTTP headers and on Socket.io handshake
Relationships and data flows
• Frontend → HTTP REST → Backend API → MongoDB
• Frontend ← HTTP REST ← Backend API ← MongoDB
• Frontend ↔ WebSocket ↔ Backend Socket.io server
• Backend → Cloudinary API for file uploads → returns URL → stored in MongoDB
• Client stores JWT locally → sends in Authorization header / Socket handshake
Architectural patterns & design principles
• Layered architecture (Presentation → API → Business logic → Data)
• MVC‐inspired structure on the backend (models, controllers, routes)
• Component and hook-based architecture on the frontend
• Redux for centralized state management
• Separation of concerns: REST vs. WebSocket sub-systems
• Use of middleware for cross-cutting concerns (auth, file handling)