PESocial is a full-stack social media application built using the MERN stack (MongoDB, Express, React, Node.js). This platform allows users to connect with friends, share posts, like and comment on content, and maintain their profiles.
- User Authentication: Secure sign-up and login functionality
- Profile Management: Create and edit personal profiles
- Posts: Create, view, like, comment on, and delete posts
- Friend Management: Add and remove friends
- Real-time Search: Powered by Algolia for fast content discovery
- Dark/Light Mode: Toggle between visual themes
- Responsive Design: Works seamlessly across devices
- Notifications: Get notified when users interact with your content
- Comments System: Engage in conversations through post comments
- Image Uploads: Share images with your posts
- Friend Recommendations: Discover new connections
- Profile Customization: Personalize your profile with images and details
- React.js
- Redux Toolkit for state management
- Material-UI for components and styling
- React Router for navigation
- Formik & Yup for form validation
- React Dropzone for file uploads
- Algolia InstantSearch for search functionality
- Node.js & Express.js
- MongoDB with Mongoose ODM
- JWT for authentication
- Multer for file handling
- Algolia for search functionality
- bcrypt for password encryption
- Node.js (v14 or higher)
- MongoDB database (local or Atlas)
- Algolia account for search functionality
-
Navigate to the server directory:
cd server -
Install dependencies:
npm install -
Create a
.envfile in the server directory with the following variables:MONGO_URL=your_mongodb_connection_string PORT=3001 JWT_SECRET=your_secret_key -
Start the server:
npm startThe server will run on port 3001 by default.
-
Navigate to the client directory:
cd client -
Install dependencies:
npm install -
Start the development server:
npm startThe React app will run on port 3000 by default.
- Create an account on Algolia
- Create an index named
posts_index - Update the Algolia application ID and API keys in:
server/updateAlgolia.jsclient/src/algoliaConfig.js
- Run the Algolia update script to populate your search index:
cd server node updateAlgolia.js
server/
│
├── controllers/ # Route controllers
│ ├── auth.js # Authentication logic
│ ├── posts.js # Post management
│ ├── users.js # User operations
│ ├── notifications.js # Notification management
│ └── friendController.js # Friend management
│
├── data/ # Sample data for development
│
├── middleware/
│ └── auth.js # JWT authentication middleware
│
├── models/ # MongoDB schema models
│ ├── Post.js
│ ├── User.js
│ └── Notification.js
│
├── public/ # Static files
│ └── assets/ # Uploaded images and media
│
├── routes/ # API routes
│ ├── auth.js
│ ├── posts.js
│ ├── users.js
│ ├── friends.js
│ └── notifications.js
│
├── .env # Environment variables
├── index.js # Main server file
└── updateAlgolia.js # Script to update Algolia search index
client/
│
├── public/ # Static files
│
├── src/
│ ├── components/ # Reusable UI components
│ │ ├── FlexBetween.jsx
│ │ ├── Friend.jsx
│ │ ├── UserImage.jsx
│ │ └── WidgetWrapper.jsx
│ │
│ ├── scenes/ # Page components
│ │ ├── homePage/
│ │ ├── loginPage/
│ │ ├── navbar/
│ │ ├── profilePage/
│ │ └── widgets/ # Widget components
│ │
│ ├── state/ # Redux store setup
│ │ ├── index.js
│ │ └── api.js
│ │
│ ├── algoliaConfig.js # Algolia client configuration
│ ├── App.js # Main React component
│ ├── index.css # Global styles
│ ├── index.js # Entry point
│ └── theme.js # MUI theme configuration
│
├── .env # Environment variables
└── package.json # Dependencies and scripts
POST /auth/register- Register a new userPOST /auth/login- Login a user
GET /users/:id- Get user informationGET /users/:id/friends- Get user's friendsPATCH /users/:id/:friendId- Add or remove a friendPUT /users/:userId- Update user profile
GET /posts- Get all postsGET /posts/:userId/posts- Get posts by a specific userPOST /posts- Create a new postPATCH /posts/:id/like- Like/unlike a postPOST /posts/:id/comment- Comment on a postDELETE /posts/:id/delete- Delete a post
POST /friends/add- Add a friendPOST /friends/accept- Accept a friend request
GET /notifications- Get user notifications
PESocial uses JWT (JSON Web Tokens) for authentication:
- User registers or logs in through the frontend
- Server validates credentials and returns a JWT token
- Frontend stores the token in Redux state
- Token is included in Authorization header for authenticated requests
- Server middleware validates the token for protected routes
- Set up a MongoDB Atlas database
- Deploy the Node.js server to services like Heroku, Render, or AWS
- Set environment variables in your deployment platform
- Build the React app:
npm run build - Deploy the build folder to services like Netlify, Vercel, or Firebase Hosting
- Configure environment variables for the production build
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add some amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details