A modern, full-stack social media application built with the MERN stack that enables users to create, share, and interact with memories through a beautiful, responsive interface.
- Dual Profanity Filtering System: Implements both
bad-wordsandmint-filterlibraries for comprehensive content filtering - Real-time Content Sanitization: Automatically cleans titles, messages, and comments before storage
- Customizable Blacklist: Easy-to-extend word filtering system for community safety
- Dual Authentication Methods: JWT-based authentication + Google OAuth integration
- Password Security: bcryptjs hashing with salt rounds
- API Rate Limiting: Express rate limiting (100 requests per 15 minutes) to prevent abuse
- Large File Support: Handles image uploads up to 30MB with optimized processing
- Gravatar Integration: Automatic avatar generation from email addresses
- Comment Management: Full CRUD operations on comments with ownership verification
- Smart Search: Multi-criteria search by title, tags, or creator name
- Tag-based Organization: Categorize and filter memories using custom tags
- Pagination: Efficient memory browsing with server-side pagination (8 posts per page)
- Creator Profiles: Dedicated user profile pages showcasing their memories
- Redux State Management: Centralized state with Redux Thunk for async operations
- RESTful API Design: Clean, well-structured Express.js backend
- Component-based UI: Modular React components with Material-UI design system
- ES6+ Modules: Modern JavaScript with ES modules throughout
| Technology | Version | Purpose |
|---|---|---|
| React | 17.0.2 | UI library for building interactive interfaces |
| Redux | 4.2.1 | Predictable state container for JavaScript apps |
| Redux Thunk | 2.4.2 | Middleware for async Redux actions |
| Material-UI | 4.12.4 | React component library following Material Design |
| React Router | 6.20.1 | Declarative routing for React applications |
| Axios | 1.6.2 | Promise-based HTTP client for API requests |
| JWT Decode | 4.0.0 | Decode JSON Web Tokens in the browser |
| Gravatar | 1.8.2 | Generate user avatars from email addresses |
| Moment.js | 2.30.1 | Parse, validate, manipulate, and display dates |
| React Google Login | 5.2.2 | Google OAuth 2.0 authentication component |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 18+ | JavaScript runtime environment |
| Express.js | 4.18.2 | Fast, unopinionated web framework |
| MongoDB | 7.6.3 | NoSQL database for flexible data storage |
| Mongoose | 7.6.3 | MongoDB object modeling for Node.js |
| JWT | 9.0.2 | JSON Web Token for secure authentication |
| bcryptjs | 2.4.3 | Password hashing library |
| Express Rate Limit | 7.1.5 | Basic rate-limiting middleware |
| bad-words | 3.0.4 | Profanity filter library |
| mint-filter | 4.0.3 | Advanced text filtering library |
| CORS | 2.8.5 | Cross-Origin Resource Sharing middleware |
- Concurrently: Run multiple commands concurrently
- Nodemon: Auto-restart server during development
- Jest: JavaScript testing framework
- ESLint: Code linting and quality assurance
- β User registration with email/password
- β Secure login with JWT tokens
- β Google OAuth 2.0 integration
- β Protected routes and API endpoints
- β Session persistence with localStorage
- β Create, read, update, and delete memories
- β Rich text posts with image uploads
- β Tag-based categorization
- β Image upload support (up to 30MB)
- β Base64 image encoding for storage
- β Like/unlike posts (toggle functionality)
- β Comment on posts with real-time updates
- β Edit and delete own comments
- β View user profiles and their memories
- β Search memories by creator
- β Advanced search by title, tags, or creator
- β Filter posts by specific tags
- β Pagination (8 posts per page)
- β Sort posts by creation date (newest first)
- β Responsive design for all devices
- β Automatic profanity filtering (dual system)
- β Content sanitization on create/update
- β Customizable word blacklist
- β API rate limiting protection
- Node.js v14 or higher (v18+ recommended)
- npm or yarn package manager
- MongoDB (local installation or MongoDB Atlas account)
git clone <repository-url>
cd mern-memoriesInstall all dependencies for root, server, and client:
npm run install-allOr install manually:
npm install # Root dependencies
cd server && npm install # Backend dependencies
cd ../client && npm install # Frontend dependenciesCreate a .env file in the server directory:
# MongoDB Connection
# Local: mongodb://localhost:27017/memories
# Atlas: mongodb+srv://username:password@cluster.mongodb.net/memories
MONGODB_URI=mongodb://localhost:27017/memories
# JWT Secret (generate a strong random string)
JWT_SECRET=your_super_secret_jwt_key_min_32_characters
# Google OAuth (optional - for Google sign-in)
# Get from: https://console.cloud.google.com/
GOOGLE_CLIENT_ID=your_google_client_id_here
# Server Port (optional - defaults to 5000)
PORT=5000Run both frontend and backend concurrently:
npm run devThis starts:
- Backend Server:
http://localhost:5000 - Frontend Dev Server:
http://localhost:3000
Or run separately:
npm run server # Backend only (port 5000)
npm run client # Frontend only (port 3000)| Command | Description |
|---|---|
npm run dev |
Start both client and server in development mode |
npm run server |
Start only the backend server |
npm run client |
Start only the frontend development server |
npm run build |
Build the React app for production |
npm run test |
Run server-side tests with Jest |
npm run install-all |
Install all dependencies (root, server, client) |
| Command | Description |
|---|---|
npm start |
Start React development server |
npm run build |
Create production build |
npm test |
Run React component tests |
| Command | Description |
|---|---|
npm start |
Start Express server with nodemon |
npm test |
Run Jest tests in watch mode |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/user/signup |
Register a new user | β |
POST |
/user/signin |
Login existing user | β |
POST |
/user/google |
Google OAuth authentication | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/posts |
Get paginated posts | β |
GET |
/posts/search |
Search posts by query/tags | β |
GET |
/posts/creator |
Get posts by creator name | β |
GET |
/posts/:id |
Get single post by ID | β |
POST |
/posts |
Create a new post | β |
PATCH |
/posts/:id |
Update a post | β |
DELETE |
/posts/:id |
Delete a post | β |
PATCH |
/posts/:id/likePost |
Like/unlike a post | β |
POST |
/posts/:id/commentPost |
Add comment to post | β |
PATCH |
/posts/:id/:commentId/editComment |
Edit a comment | β |
DELETE |
/posts/:id/:commentId/deleteComment |
Delete a comment | β |
Note: All authenticated routes require a valid JWT token in the Authorization header.
mern-memories/
βββ client/ # React Frontend Application
β βββ public/ # Static assets
β β βββ index.html # HTML template
β β βββ _redirects # Netlify redirects config
β β βββ memories.png # App icon
β βββ src/
β βββ actions/ # Redux action creators
β β βββ auth.js # Authentication actions
β β βββ posts.js # Post-related actions
β βββ api/ # API configuration
β β βββ index.js # Axios setup & interceptors
β βββ components/ # React components
β β βββ Auth/ # Authentication UI
β β βββ CreatorOrTag/ # Filtered post views
β β βββ Form/ # Post creation/editing
β β βββ Home/ # Main feed page
β β βββ Navbar/ # Navigation bar
β β βββ Pagination.jsx # Pagination component
β β βββ PostDetails/ # Single post view
β β βββ Posts/ # Post list components
β β βββ Profile/ # User profile page
β βββ constants/ # Application constants
β β βββ actionTypes.js # Redux action type definitions
β βββ images/ # Static images
β βββ reducers/ # Redux reducers
β β βββ auth.js # Auth state management
β β βββ index.js # Root reducer
β β βββ posts.js # Posts state management
β βββ utils/ # Utility functions
β β βββ gravatar.js # Gravatar URL generator
β βββ App.js # Main App component
β βββ index.js # React entry point
β βββ index.css # Global styles
β
βββ server/ # Node.js Backend API
β βββ controllers/ # Route controllers (business logic)
β β βββ posts.js # Post CRUD operations
β β βββ user.js # User authentication logic
β βββ middleware/ # Custom Express middleware
β β βββ auth.js # JWT authentication middleware
β βββ models/ # MongoDB schemas
β β βββ postMessage.js # Post model with comments
β β βββ user.js # User model
β βββ routes/ # API route definitions
β β βββ posts.js # Post endpoints
β β βββ user.js # User endpoints
β βββ test/ # Test files
β β βββ posts.test.js # Post controller tests
β β βββ user.test.js # User controller tests
β βββ index.js # Express server entry point
β βββ env.example # Environment variables template
β βββ package.json # Backend dependencies
β
βββ package.json # Root package.json with scripts
βββ setup.sh # Unix/Linux setup script
βββ setup.bat # Windows setup script
βββ README.md # This file
The React app can be deployed to static hosting platforms:
Netlify (Recommended)
- Build the app:
npm run build - Deploy the
client/buildfolder - Configure redirects in
client/public/_redirects
Vercel
cd client
vercel --prodOther Options: GitHub Pages, AWS S3, Firebase Hosting
Deploy the Express server to platforms supporting Node.js:
Render (Recommended)
- Connect your GitHub repository
- Set environment variables
- Deploy automatically on push
Railway
railway upOther Options: Heroku, DigitalOcean, AWS EC2, Google Cloud Run
Ensure all environment variables are set in your hosting platform:
MONGODB_URIJWT_SECRETGOOGLE_CLIENT_ID(if using Google OAuth)PORT(usually auto-set by platform)
Update the frontend API base URL in client/src/api/index.js to point to your production backend URL.
Run the test suite:
npm run testThe server includes Jest tests for:
- User authentication
- Post CRUD operations
- API endpoint validation
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow existing code style and patterns
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the ISC License.
- Material-UI team for the excellent component library
- MongoDB for the flexible database solution
- React team for the powerful UI framework
- All open-source contributors whose packages made this project possible
For issues, questions, or contributions, please open an issue on the GitHub repository.
Built with β€οΈ using the MERN Stack