How mollygit001/summer-mern works
Project type and purpose
• This is a full-stack MERN-style web application (“MERN Summer Project”).
• Purpose: provide secure authentication (email/password & Google OAuth), role-based user management, link CRUD with click-tracking analytics, and payment/credit subscription workflows. The UI is React + Tailwind, backend is Node/Express + MongoDB.
File structure
• Top-level:
• public/ + index.html → static assets served to client
• src/ → React UI (components, pages, Redux store, config, utilities)
• server/ → Express API (controllers, routes, middleware, models, services, scripts)
• config files: vite.config.js, eslint.config.js
• server/src follows an MVC-style layering:
• routes → map endpoints to controllers
• middleware → auth, authorization, validation
• controller → business logic entrypoints organized by domain (auth, user, links, payments)
• services → helper modules (emailService)
• model → Mongoose schemas (Users, Links, Clicks)
• constants/utilities
• Client src uses Redux Toolkit (features/form), React Router (ProtectedRoute, Can), and component-based pages/layouts.
Insights from the README
• Key architectural points:
• JWT in HTTP-only cookies for auth
• Role-based access control
• Google OAuth & Payments (likely Stripe or similar via server/paymentController)
• Two .env contexts (client vs server)
• Tech Stack: React, Redux Toolkit, Tailwind, Express, MongoDB, Mongoose, bcryptjs, Google OAuth, ESLint
a. Main components
• Client (Browser/React + Vite Dev Server)
• API Server (Node.js + Express)
• Authentication Service (JWT issuance, Google OAuth flow)
• Business Domain Services (UserService, LinkService, PaymentService, EmailService)
• Data Layer (MongoDB database)
• External Services
• Google OAuth Provider
• Email Provider (SMTP/SendGrid)
• Payment Gateway (Stripe/PayPal)
b. Relationships & interactions
1. User → Browser UI → Redux → React components → Axios HTTP calls →
2. Express API Routes → Auth Middleware → Controller → Service → Model → MongoDB
3. AuthController ↔ JWT issuance & cookie set
4. authController ↔ Google OAuth external flow
5. paymentController ↔ Payment Gateway external API
6. emailService ↔ Email Provider API
7. analytics: Link clicks increment Clicks collection
c. Architectural patterns
• Layered Architecture (Client / API Layer / Service Layer / Data Layer)
• MVC-style on server
• Redux for client-side state management
• RBAC implemented via middleware (authorizeMiddleware, Can component)
• Separation of concerns: controllers vs services vs models
d. Key technologies
• Frontend: React, Redux Toolkit, React Router, Tailwind CSS, Vite
• Backend: Express, Mongoose, JWT, bcryptjs, dotenv
• Database: MongoDB
• External: Google OAuth, SMTP or transactional email, Payment Gateway
Detailed capture of architectural elements
• Single MongoDB instance behind all models.
• Call out RBAC: authorizeMiddleware on server + ProtectedRoute/Can on client.
• Click-tracking: Link redirect endpoint increments Clicks model.