JD Social Network empowers users to connect, share, and engage seamlessly with friends from all around the globe. This web application utilizes a React frontend enhanced with Redux, an Express.JS backend server to handle MVC functionalities and user authentication and authorization, and a MongoDB non-relational database to store user, post, and comment information.
- Navbar: Top navigation bar offering easy access to essential features.
- CreatePost/CreateComment: Component for creating new posts, including optional image attachments.
- LikePost and LikeComment: Components responsible for handling likes on posts and comments.
- AcceptFriend:Component facilitating the acceptance or deletion of friend requests.
- Post/Comment: Modal component displaying detailed information about a specific post/comment.
- Homebar: Sidebar component for quick navigation to home, profile, watch, marketplace, gaming, and feeds.
- Profile: Component rendering user profiles, posts, and interactions.
- Friendbar: Sidebar component displaying the user's friends.
This is the backend server for a social media platform implemented using Node.js, Express, and MongoDB. The server provides RESTful API endpoints for user authentication, post creation, comments, friend requests, notifications, and more.
- config/passport.js: Configuration file for Passport authentication strategies, including JWT strategies.
- userModel.js: Defines the user schema for MongoDB.
- postModel.js: Defines the post schema for MongoDB.
- commentModel.js: Defines the comment schema for MongoDB.
- authentication.js: Handles user authentication, signup, login, and logout.
- profile.js: Manages user profiles, friend lists, and profile picture changes.
- post.js: Handles post-related functionalities, such as creating posts, liking posts, and retrieving posts.
- comment.js: Manages comments on posts, including creation and liking.
- search.js: Provides functionality for searching users.
- request.js: Handles friend requests, cancellations, and acceptances.
- notifications.js: Manages user notifications.
- routes/: Defines API routes using express.Router().
apiRouter.js: Aggregates all routes from different controllers.
- app.js: Main entry point for the application. Configures the Express app, connects to MongoDB, and sets up middleware.
Node.js: Server-side JavaScript runtime Express: Web application framework for Node.js MongoDB (Mongoose): Database for storing user information, posts, and comments Passport: Authentication middleware for Node.js JWT (JSON Web Token): Used for user authentication
- User Authentication: Supports user signup, login, and logout with password hashing.
- Profile Management: Allows users to update their profile information and change profile pictures.
- Friendship System: Handles friend requests, cancellations, acceptances, and unfriending.
- Posts and Comments: Users can create posts, comment on posts, and like posts and comments.
- Notifications: Users receive notifications for friend requests, post comments, and likes.
- express: Framework for building web applications.
- mongoose: MongoDB object modeling for Node.js.
- morgan: HTTP request logger middleware.
- passport: Authentication middleware.
- cors: Middleware for enabling Cross-Origin Resource Sharing.
- session: Express session middleware for managing user sessions.
User authentication is handled using Passport middleware. Sessions are managed through the express-session middleware.
Connects to MongoDB using mongoose. Uses the dbURI and sessionSecret from environment variables.
Listens on port 8000 after successfully connecting to the database.
Configures middleware such as morgan for logging, express.json() and express.urlencoded() for handling request bodies, and cors for enabling cross-origin requests.
- Session Handling: Configures session management using express-session. Uses a session secret from the environment variables.
- Passport Configuration: Initializes and configures Passport for user authentication. Requires the passport and ./config/passport modules.
- Routing: Utilizes the apiRouter for handling various API endpoints. All API routes are defined in the apiRouter module.