How jigar-sable/instagram-mern works
Project Type & Purpose
• This is a full-stack Instagram clone built with the MERN stack (MongoDB, Express, React, Node.js), augmented by Socket.IO for real-time chat, AWS S3/Cloudinary for image storage, and SendGrid for emails.
• Frontend is a React+Redux SPA, backend is an Express API with REST endpoints and a WebSocket server for messaging.
Core Components
a. Frontend (React/Redux)
• React components under frontend/src/components
• State management via Redux (frontend/src/store.js, actions, reducers)
• Routing via React-Router (frontend/src/Routes)
• UI via TailwindCSS + MUI
b. Backend (Node.js/Express)
• Server entry: backend/app.js (imported by server.js)
• Config & middleware: JWT auth, error handling, async wrapper
• Controllers & Routes: user, post, message, chat
• Utilities: AWS S3 or Cloudinary upload functions, SendGrid email, cookie helper
c. Database
• MongoDB collections for Users, Posts, Chats, Messages (Mongoose models)
d. Real-time Layer
• Socket.IO integrated in backend; clients connect from React to receive/send chat events
e. External Services
• AWS S3 or Cloudinary for image storage
• SendGrid for transactional email (password reset)
f. Deployment
• Frontend deployed on Vercel
• Backend packaged via Procfile (Heroku) or Vercel serverless functions
• Environment variables in backend/config/config.env.example, vercel.json
Relationships & Data Flows
• Browser ↔ React SPA (UI/UX)
• React components dispatch Redux actions → API calls (HTTP) to Express endpoints → Controllers → MongoDB → back to client via JSON
• React initiates a Socket.IO connection to Express server for real-time chat events
• File uploads by client → signed/resigned to AWS S3 or Cloudinary via backend → storage URL stored in MongoDB
• Password reset/email flows via backend → SendGrid
Architectural Patterns & Principles
• Separation of concerns: UI layer, state layer (Redux), API layer, data layer (MongoDB)
• RESTful API design for CRUD operations
• WebSocket pub/sub pattern for messaging
• Middleware chain in Express for auth, error handling, async
• CI/CD / environment-based configs
Detailed Checklist
• Database: MongoDB Atlas (with Mongoose models)
• Storage: AWS S3 / Cloudinary
• Mail: SendGrid
• Deployment annotations: Vercel, Heroku (Procfile), vercel.json