How omwanere/social works
Project type and purpose
• This is a modern, full-stack social media application with real-time chat, notifications, posts, comments, user profiles, and theme toggling.
• It uses React/Vite on the frontend and Node.js/Express with MongoDB on the backend, plus Socket.IO for real-time features.
File structure
• Top-level directories:
• Backend/ – Express server, controllers, models, routes, middlewares, Socket.IO server, utilities.
• Frontend/ – Vite/React app, components, hooks, Redux slices, Socket context, API helpers, styling configs.
• Patterns:
• Backend follows MVC (models in Backend/models, controllers in Backend/controllers, routes in Backend/routes).
• Frontend uses component-based architecture, Redux for global state, React Router for navigation, custom hooks for data fetching, and a Context for Socket.IO.
• Configuration and deployment hints: .env via dotenv, CORS, cookie-parser, Cloudinary integration, Multer for uploads, Vite config, Tailwind config.
README for additional insights
• Features: authentication (JWT), follow/unfollow, edit profile, posts & comments, real-time messaging and notifications, dark/light mode.
• Tech stack confirmation: React, Redux Toolkit, Express, MongoDB/Mongoose, Socket.IO, Cloudinary, Multer, Axios.
Main components and interactions
a. Frontend Application
• UI Layer: React components (feed, chat page, profile, etc.)
• State Layer: Redux store (AuthSlice, postSlice, chatSlice, socketSlice)
• Networking:
• REST API (Axios) → Backend HTTP endpoints for auth, users, posts, comments.
• WebSocket (Socket.IO Client) ↔ Real-time server for chat & notifications.
b. Backend API Server
• HTTP Layer (Express routes & controllers)
• Real-time Layer (Socket.IO server in Backend/socket/socket.js)
• Business Logic: controllers, middlewares (isAuthenticated, multer for file uploads)
• Utilities: Cloudinary/image uploads, datauri conversion, DB connection helper.
c. Database
• MongoDB via Mongoose models: User, Post, Comment, Conversation, Message.
d. External Services
• Cloudinary for image storage
• (Optional) Any third-party OAuth or analytics if added later.
Relationships and data flows
• Client → Server (HTTP): login/signup, fetch posts, comments, profiles, follow/unfollow.
• Client ↔ Server (WebSocket): real-time chat messages, typing indicators, real-time notifications for likes/follows.
• Server → DB: CRUD operations via Mongoose.
• Server → Cloudinary: upload user images and post media.
Architectural patterns and design principles
• Backend: MVC + service/util layering, stateless JWT authentication, middleware pipeline, single monolithic service.
• Frontend: unidirectional data flow via Redux, container/presentational separation, custom hooks for data fetching, Context API for socket.
• Separation of concerns: UI vs. state vs. networking vs. real-time.