How shubhamore/connect-verse works
Project Type and Purpose
• -Verse is a full-stack MERN application: a social media platform enabling user registration, authentication (including Google OAuth), profile management, posting, commenting, liking, connecting with other users, and image handling via Cloudinary.
Main Architectural Components
a. Frontend (React.js SPA)
• React (components under client/src/*)
• Redux Toolkit for state management (client/src/state)
• React Router for navigation (scenes folder)
• Material-UI for UI
• Formik & Yup for forms
• Assets & static files (client/public)
b. Backend (Node.js + Express)
• Express server (server/index.js)
• Controllers (server/controllers/*) implement business logic (auth, user, post, comment)
• Routes (server/routes/*) define RESTful endpoints (/auth, /user, /post)
• Middleware (server/middleware/auth.js) handles JWT verification
• Config (server/config/cloudinary.js) sets up image upload service
c. Database
• MongoDB with Mongoose ODM (server/models/User.js, Post.js)
d. External Services
• Cloudinary for image storage
• Google OAuth (via passport or custom OAuth flow)
e. Authentication & Security
• JSON Web Tokens (JWT) for session management
• Protected routes middleware
f. Deployment
• Render.com hosting for both client and server
Relationships & Data Flow
• User actions in the React UI dispatch Redux actions → async thunks call the Express API → Express routes invoke controllers → controllers interact with MongoDB (via Mongoose models) → responses flow back through Express → Redux state updates → React re-renders.
• Image uploads in the UI → sent to Express → forwarded to Cloudinary → secure URL stored in MongoDB → returned to client.
• Google OAuth: user redirected to Google → OAuth callback to Express → create/validate user in MongoDB → issue JWT.
Architectural Patterns & Design Principles
• Separation of concerns: clear layers (UI, client-side state, API, business logic, data layer)
• RESTful API design for backend
• MVC–like organization on server (routes → controllers → models)
• Component-based design on frontend
• Single Page Application (SPA) pattern
• Use of middleware for cross-cutting concerns (auth, error handling)