AttentionSnatcher is a full-stack MERN social media platform that provides a space for users to connect, share, and interact online. With its intuitive design and robust feature set, ConnectSphere offers a familiar yet unique social networking experience.
- User Authentication: Secure and efficient sign-up/login with JWT for session management.
- Friendship Management: Send, accept, and remove friend requests to build your network.
- Interactive Feed: Share posts and view updates with support for text, images, and videos.
- Likes and Reactions: Engage with content through likes and reactions.
- Profile Customization: Personalize your profile with photos, bios, and more.
- Dark Mode: Toggle dark mode for a comfortable viewing experience.
- Responsive Design: A layout that adapts to any device for consistent usability.
- Frontend: React.js, Material-UI (MUI)
- Backend: Node.js, Express.js
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens)
- Hosting: Cloud-based hosting for high availability
- on changing the code, we need to delete (drop) the data from mongodb manually.
- go to collections and manually remove each set
- uncomment the fake data inserting lines in sever/index.js
- started with
npm init -yafter installing the packages and dependencies nodemonto run the server (navigate to server dir)npm run clientto run the client (navigate to client dir)
- contains the information to connect to the mongodb db
- our frontend will run on port 3000 and backend on port 3001
- this is where the authentication logic is handled.
- to encrypt the password and the token work
- jwt: a way to send user a web token to deal with the authorisation without revealing the actual information
- the login callback function handles the verification of the user entered login details for logging in.
- not very safe for all use cases.
- A very basic authentication system implemented
new user object is created:
- we encrypt the password
- save it
- when the user tries to log in
- they're gonna provide the password
- we're gonna salt that again and verify with the old hash
- if it is the correct one, give them a json web token (jwt)
sending to the frontend:
- send the user if the above doesn't error out, send a status of 201 (something is created),
- created a json version of the saved user so frontend can comprehend
- contains the path and the routes for every feature (auth feature)
- NOTE: the register route is not in the routes folder as invoking and using that functionality requires the use of 'upload' variable, which is only present in the index.js
- includes all the middleware configurations as well as different package configurations
- middlware: something that runs in-between requests basically functions that run in-between different things
- saving the files to the destination mentioned
- whenver someone uploads a file on our website, it goes to the destination, which is
public/assetsin our case and saves there
- can get all the information about the code (multer) from github repo of multer
- route mentioned is hit
- middleware is used: uploads an image locally into the public/assetes dir (middleware function)
- then the actual logic is hit: register controller (functionality)
- handling of the routes (api) calls from the server
- helps set up the routes and keeps the files organised and clean
- get the user
- get user's friend list
- update user's friend list by adding/removing friends
npm i -g npx
npx create-react-app client
client % npm i react-redux @reduxjs/toolkit redux-persist react-dropzone d otenv formik yup react-router-dom@6 @mui/material @emotion/react @emotion/styled @mui/icons-material
- redux: popular enterprise level state management tool
- redux toolkit
- redux-persist: save to local storage of the browser (no need to register again and again)
- react-dropzone: handles the file upload and file handling in the frontend, to send to backend
- dotenv: for environment variables
- formik: for form handling
- yup: for validation
- react-router-dom@6: handling react router (different routes and pages)
- material ui:
this is where the layouts for different pages and components is set
the .jsx represents files containing react components in them
This is where the common(global) components can go
redux and toolkit information
contains the color palette for the dark and light themes
palette.neutral.mainif in dark mode gives grey[200], else gives grey[500]
- what this file does is, now whenever we need to import anything, we can just put the path starting from '/src/'. as in, we can assume we;re already in src. so no need to mention src
- contains all the themes (colors for background, dark-mode and the light-mode)
- covers the code for all sizes of menus, for the desktop screens and for the mobile screens
- the logo, the search, the buttons in the navbar, etc.
- one of the bigger components of the application for the frontend side
-
This is where the register functionality is handled
-
schemas for the validation
-
initialValueRegister for the initial values of the form
-
the logic behind what happens any time someone clicks submit is handled by the button type: Submit
- (onSubmit) is run -> which is essentially handleFormSubmit