This is a social media web application built using Node.js, Express.js, MongoDB, Passport.js, and JWT for authentication. It allows users to #, log in, post content, and comment on posts. It integrates Google OAuth2.0 authentication for easy sign-ins and uses AJAX for dynamic content updates.
- User Authentication: #, log in, and sign out functionality.
- Google OAuth2.0 Authentication: Allow users to authenticate using their Google accounts.
- Posting: Users can create posts, delete them, and view posts by others.
- Commenting: Users can comment on posts, and view comments made by others.
- AJAX Integration: For seamless and dynamic interactions like posting and deleting posts.
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: Passport.js (Local Strategy + Google OAuth2.0), JWT
- CSS: SASS (Node-SASS Middleware)
- Frontend: EJS for templating, AJAX for asynchronous operations
- Session Management: Express-Session, MongoDB Store
Follow these steps to set up the project locally:
Make sure you have the following installed on your local machine:
git clone https://github.com/yourusername/codeial.git
cd codeial
Run the following command to install the necessary dependencies:
npm install
Ensure MongoDB is installed and running on your local machine. If you don't have MongoDB installed, you can follow MongoDB's installation guide.
Create a .env
file in the root directory and add your config.
Make sure to replace the values with your own credentials for Google OAuth.
npm start
This will start the server at `http://localhost:8000\`.
To enable Google login functionality, create credentials for OAuth 2.0 on the Google Developer Console. Add your redirect URI in the console and update the credentials in your .env
file.
- Users can # using email and password.
- Google OAuth2.0 login is available for easy sign-ins.
- User sessions are handled using Express-Session.
- JWT is used for secure authentication in API routes.
- Users can create posts by entering text in the post creation form.
- Posts are displayed on the home page.
- Users can delete posts if they are the ones who created them.
- Users can comment on posts by entering text in the comment form below each post.
- Comments are displayed dynamically without page reload using AJAX.
- Create Post: When a user submits the form to create a post, the post is added to the DOM without refreshing the page.
- Delete Post: When a user clicks on the "X" button to delete a post, the post is removed from the DOM without a page reload.
- Create Comment: Similar to posts, comments are added dynamically using AJAX when a user submits the comment form.
├── assets
│ ├── css
│ ├── scss
├── config
│ ├── mongoose.js
│ ├── passport-local-strategy.js
│ ├── passport-jwt-strategy.js
│ └── session.js
├── controllers
│ ├── home_controller.js
│ ├── user_controller.js
│ ├── post_controller.js
├── models
│ ├── post.js
│ ├── user.js
│ ├── comment.js
├── routes
│ ├── index.js
│ ├── user.js
│ ├── posts.js
│ ├── comments.js
├── views
│ ├── home.ejs
│ ├── profile.ejs
│ ├── user_sign_up.ejs
│ └── user_sign_in.ejs
├── uploads
│ ├── users
│ │ └── avatar
├── .env
├── package.json
└── server.js
- Fork the repository.
- Create a new branch: `git checkout -b feature-branch`.
- Make your changes.
- Commit your changes: `git commit -m 'Add new feature'`.
- Push to the branch: `git push origin feature-branch`.
- Open a pull request.