├── .gitignore ├── README.md ├── assetREADME.md ├── atlasUrl.png ├── clusterPassword.png ├── networkAccess.png └── renderDeployBackendSetup.png ├── client ├── .env ├── .gitignore ├── README.md ├── debug.log ├── package.json ├── public │ ├── index.html │ └── style.css └── src │ ├── App.js │ ├── components │ ├── admin │ │ ├── categories │ │ │ ├── AddCategoryModal.js │ │ │ ├── AllCategories.js │ │ │ ├── CategoryContext.js │ │ │ ├── CategoryMenu.js │ │ │ ├── EditCategoryModal.js │ │ │ ├── FetchApi.js │ │ │ └── index.js │ │ ├── dashboardAdmin │ │ │ ├── Action.js │ │ │ ├── Customize.js │ │ │ ├── DashboardCard.js │ │ │ ├── DashboardContext.js │ │ │ ├── FetchApi.js │ │ │ ├── TodaySell.js │ │ │ └── index.js │ │ ├── index.js │ │ ├── layout │ │ │ └── index.js │ │ ├── orders │ │ │ ├── Actions.js │ │ │ ├── AddCategoryModal.js │ │ │ ├── AllOrders.js │ │ │ ├── FetchApi.js │ │ │ ├── OrderContext.js │ │ │ ├── OrderMenu.js │ │ │ ├── SearchFilter.js │ │ │ ├── UpdateOrderModal.js │ │ │ └── index.js │ │ ├── partials │ │ │ ├── AdminFooter.js │ │ │ ├── AdminNavber.js │ │ │ └── AdminSidebar.js │ │ └── products │ │ │ ├── AddProductModal.js │ │ │ ├── EditProductModal.js │ │ │ ├── FetchApi.js │ │ │ ├── ProductContext.js │ │ │ ├── ProductMenu.js │ │ │ ├── ProductTable.js │ │ │ └── index.js │ ├── index.js │ └── shop │ │ ├── auth │ │ ├── AdminProtectedRoute.js │ │ ├── CartProtectedRoute.js │ │ ├── Login.js │ │ ├── LoginSignup.js │ │ ├── ProtectedRoute.js │ │ ├── Signup.js │ │ └── fetchApi.js │ │ ├── dashboardUser │ │ ├── Action.js │ │ ├── DashboardUserContext.js │ │ ├── FetchApi.js │ │ ├── Layout.js │ │ ├── SearchFilter.js │ │ ├── SettingUser.js │ │ ├── Sidebar.js │ │ ├── UserOrders.js │ │ ├── UserProfile.js │ │ └── index.js │ │ ├── home │ │ ├── HomeContext.js │ │ ├── Mixins.js │ │ ├── OrderSuccessMessage.js │ │ ├── ProductByCategory.js │ │ ├── ProductCategory.js │ │ ├── ProductCategoryDropdown.js │ │ ├── SingleProduct.js │ │ ├── Slider.js │ │ ├── index.js │ │ └── style.css │ │ ├── index.js │ │ ├── layout │ │ ├── PageNotFound.js │ │ ├── index.js │ │ └── layoutContext.js │ │ ├── order │ │ ├── Action.js │ │ ├── CheckoutPage.js │ │ ├── CheckoutProducts.js │ │ └── FetchApi.js │ │ ├── partials │ │ ├── Action.js │ │ ├── CartModal.js │ │ ├── FetchApi.js │ │ ├── Footer.js │ │ ├── Mixins.js │ │ ├── Navber.js │ │ ├── index.js │ │ └── style.css │ │ ├── productDetails │ │ ├── Action.js │ │ ├── AllReviews.js │ │ ├── Details.js │ │ ├── FetchApi.js │ │ ├── Mixins.js │ │ ├── ProductDetailsContext.js │ │ ├── ProductDetailsSection.js │ │ ├── ProductDetailsSectionTwo.js │ │ ├── ReviewForm.js │ │ ├── Submenu.js │ │ ├── index.js │ │ └── style.css │ │ └── wishlist │ │ ├── FetchApi.js │ │ ├── Mixins.js │ │ ├── SingleWishProduct.js │ │ └── index.js │ ├── index.js │ └── serviceWorker.js └── server ├── .env ├── .gitignore ├── app.js ├── config ├── db.js ├── function.js ├── keys.js └── uploadFolderCreateScript.js ├── controller ├── auth.js ├── braintree.js ├── categories.js ├── customize.js ├── orders.js ├── products.js └── users.js ├── middleware └── auth.js ├── models ├── categories.js ├── customize.js ├── orders.js ├── products.js └── users.js ├── package.json └── routes ├── auth.js ├── braintree.js ├── categories.js ├── customize.js ├── orders.js ├── products.js └── users.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | uploads 3 | images 4 | package-lock.json 5 | img -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Project Demo 2 | 3 | [![Alt text](https://img.youtube.com/vi/lXk14qt2D28/0.jpg)](https://www.youtube.com/watch?v=lXk14qt2D28) 4 | 5 | ## Getting Started 6 | 7 | These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. 8 | 9 | ### Prerequisites 10 | 11 | NPM / Yarn and Node.js installed 12 | 13 | ### .env 14 | 15 | In the server > .env file, you can find some information. Please use your own API key for future use, as this key may not work in the future. 16 | 17 | ``` 18 | BRAINTREE_MERCHANT_ID=your_id 19 | BRAINTREE_PUBLIC_KEY=your_public_key 20 | BRAINTREE_PRIVATE_KEY=your_private_key 21 | ``` 22 | 23 | ### Installing 24 | 25 | Installing NPM modules on both client and server folders 26 | 27 | Execute these commands from the project directory 28 | 29 | ``` 30 | cd client && npm install 31 | ``` 32 | 33 | ``` 34 | cd server && npm install 35 | ``` 36 | 37 | ### Running the app 38 | 39 | Open a terminal on server directory 40 | 41 | ``` 42 | npm run start:dev 43 | ``` 44 | 45 | and open another terminal on client directory 46 | 47 | ``` 48 | npm run start 49 | ``` 50 | 51 | Access the web app at http://localhost:3000/ 52 | 53 | ### Deploying the backend server to render 54 | 55 | Follow these setps 👇👇 56 | 57 | 1. Create your render account in https://render.com/ 58 | 2. Connect your github to render and give the project permission for that 59 | 3. Then create a new Web Service and add your repo (your repo must be look like this repo's folder structure like frontend and backend both in that repo) 60 | 4. For deploying this, every change will be in this `render-deploy-backend` branch. So don't change your `.evn` from master branch. 61 | 5. You have to change your database to local to mongodb atlas. Because in this deployment we are not creating db server. So we will be using mongo atlas url. So find your mongodb cloud url with database which will look like this: `mongodb+srv://myusername:myclusterpassword@mycluster.mongodb.net/ecommerce?retryWrites=true&w=majority` 62 | and 63 | goto the `render-deploy-backend` branch 64 | and goto `.env` file and replace the first variable to your latest mongodb cloud url like this: 65 | `DATABASE=mongodb+srv://myusername:myclusterpassword@mycluster.mongodb.net/ecommerce?retryWrites=true&w=majority` 66 | Don't just put this url. Your url will be different. You will find it in your mongo cluster setting. 67 | The old variable will be like this: `DATABASE=mongodb://127.0.0.1:27017/ecommerce 68 | ` and your new one should look like this: 69 | `DATABASE=mongodb+srv://myusername:myclusterpassword@mycluster.mongodb.net/ecommerce?retryWrites=true&w=majority` 70 | you can find the mongo url by goto the mongodb atlas website and goto your database and you can find a connect button and click on that you will see the url. And modify the url quite like my one with your secret info. 71 | N.B: And you must need to provide the cluster password not your account password! So find your cluster password from database access menu in mongodb atlast cloud and change accoding to you. Here I provide all image's that you can undarstand better 72 | ![Alt Text](assetREADME.md/atlasUrl.png) 73 | ![Alt Text](assetREADME.md/clusterPassword.png) 74 | ![Alt Text](assetREADME.md/networkAccess.png) 75 | 76 | 6. Then come to render website. Give all of the imformations I set in the image below just change the name of your project and then must be change the branch name to `master` to `render-deploy-backend` 77 | 78 | 7. This is the setup for render 79 | ![Alt Text](assetREADME.md/renderDeployBackendSetup.png) 80 | 81 | 8. After all the setup you finished create the web service and It will deploy the project. 82 | 83 | You can deploy frontend into vercel or netlify also. Thanks 84 | 85 | `Build with 💛 by Hasan` 86 | -------------------------------------------------------------------------------- /assetREADME.md/atlasUrl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasan-py/MERN_Stack_Project_Ecommerce_Hayroo/5fbc0a49a3e08d8186065044c21a1e9aabd7a5c7/assetREADME.md/atlasUrl.png -------------------------------------------------------------------------------- /assetREADME.md/clusterPassword.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasan-py/MERN_Stack_Project_Ecommerce_Hayroo/5fbc0a49a3e08d8186065044c21a1e9aabd7a5c7/assetREADME.md/clusterPassword.png -------------------------------------------------------------------------------- /assetREADME.md/networkAccess.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasan-py/MERN_Stack_Project_Ecommerce_Hayroo/5fbc0a49a3e08d8186065044c21a1e9aabd7a5c7/assetREADME.md/networkAccess.png -------------------------------------------------------------------------------- /assetREADME.md/renderDeployBackendSetup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hasan-py/MERN_Stack_Project_Ecommerce_Hayroo/5fbc0a49a3e08d8186065044c21a1e9aabd7a5c7/assetREADME.md/renderDeployBackendSetup.png -------------------------------------------------------------------------------- /client/.env: -------------------------------------------------------------------------------- 1 | REACT_APP_API_URL=http://localhost:8000 2 | -------------------------------------------------------------------------------- /client/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | debug.log 25 | -------------------------------------------------------------------------------- /client/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 2 | 3 | ## Available Scripts 4 | 5 | In the project directory, you can run: 6 | 7 | ### `npm start` 8 | 9 | Runs the app in the development mode.
10 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 11 | 12 | The page will reload if you make edits.
13 | You will also see any lint errors in the console. 14 | 15 | ### `npm test` 16 | 17 | Launches the test runner in the interactive watch mode.
18 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 19 | 20 | ### `npm run build` 21 | 22 | Builds the app for production to the `build` folder.
23 | It correctly bundles React in production mode and optimizes the build for the best performance. 24 | 25 | The build is minified and the filenames include the hashes.
26 | Your app is ready to be deployed! 27 | 28 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 29 | 30 | ### `npm run eject` 31 | 32 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 33 | 34 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 35 | 36 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 | 38 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 | 40 | ## Learn More 41 | 42 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 43 | 44 | To learn React, check out the [React documentation](https://reactjs.org/). 45 | 46 | ### Code Splitting 47 | 48 | This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting 49 | 50 | ### Analyzing the Bundle Size 51 | 52 | This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size 53 | 54 | ### Making a Progressive Web App 55 | 56 | This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app 57 | 58 | ### Advanced Configuration 59 | 60 | This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration 61 | 62 | ### Deployment 63 | 64 | This section has moved here: https://facebook.github.io/create-react-app/docs/deployment 65 | 66 | ### `npm run build` fails to minify 67 | 68 | This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify 69 | -------------------------------------------------------------------------------- /client/debug.log: -------------------------------------------------------------------------------- 1 | [1102/070315.777:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) 2 | [1102/210721.012:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) 3 | [1106/143808.324:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3) 4 | -------------------------------------------------------------------------------- /client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.5.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "axios": "^0.20.0", 10 | "bootstrap": "^4.5.2", 11 | "braintree-web-drop-in-react": "^1.2.1", 12 | "moment": "^2.29.0", 13 | "notistack": "^3.0.1", 14 | "react": "^16.13.1", 15 | "react-dom": "^16.13.1", 16 | "react-router-dom": "^5.2.0", 17 | "react-scripts": "3.4.1" 18 | }, 19 | "scripts": { 20 | "start": "react-scripts start", 21 | "build": "react-scripts build", 22 | "test": "react-scripts test", 23 | "eject": "react-scripts eject" 24 | }, 25 | "eslintConfig": { 26 | "extends": "react-app" 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /client/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Hayroo 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | -------------------------------------------------------------------------------- /client/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useReducer } from "react"; 2 | import Routes from "./components"; 3 | import { LayoutContext, layoutState, layoutReducer } from "./components/shop"; 4 | 5 | function App() { 6 | const [data, dispatch] = useReducer(layoutReducer, layoutState); 7 | return ( 8 | 9 | 10 | 11 | 12 | 13 | ); 14 | } 15 | 16 | export default App; 17 | -------------------------------------------------------------------------------- /client/src/components/admin/categories/CategoryContext.js: -------------------------------------------------------------------------------- 1 | export const categoryState = { 2 | categories: [], 3 | addCategoryModal: false, 4 | editCategoryModal: { 5 | modal: false, 6 | cId: null, 7 | des: "", 8 | status: "", 9 | }, 10 | loading: false, 11 | }; 12 | 13 | export const categoryReducer = (state, action) => { 14 | switch (action.type) { 15 | /* Get all category */ 16 | case "fetchCategoryAndChangeState": 17 | return { 18 | ...state, 19 | categories: action.payload, 20 | }; 21 | /* Create a category */ 22 | case "addCategoryModal": 23 | return { 24 | ...state, 25 | addCategoryModal: action.payload, 26 | }; 27 | /* Edit a category */ 28 | case "editCategoryModalOpen": 29 | return { 30 | ...state, 31 | editCategoryModal: { 32 | modal: true, 33 | cId: action.cId, 34 | des: action.des, 35 | status: action.status, 36 | }, 37 | }; 38 | case "editCategoryModalClose": 39 | return { 40 | ...state, 41 | editCategoryModal: { 42 | modal: false, 43 | cId: null, 44 | des: "", 45 | status: "", 46 | }, 47 | }; 48 | case "loading": 49 | return { 50 | ...state, 51 | loading: action.payload, 52 | }; 53 | default: 54 | return state; 55 | } 56 | }; 57 | -------------------------------------------------------------------------------- /client/src/components/admin/categories/CategoryMenu.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useContext } from "react"; 2 | import { CategoryContext } from "./index"; 3 | import AddCategoryModal from "./AddCategoryModal"; 4 | import EditCategoryModal from "./EditCategoryModal"; 5 | 6 | const CategoryMenu = (props) => { 7 | const { dispatch } = useContext(CategoryContext); 8 | 9 | return ( 10 | 11 |
12 |
13 | {/* It's open the add category modal */} 14 |
17 | dispatch({ type: "addCategoryModal", payload: true }) 18 | } 19 | className="cursor-pointer rounded-full p-2 flex items-center justify-center text-gray-100 text-sm font-semibold uppercase" 20 | > 21 | 27 | 32 | 33 | Add Category 34 |
35 |
36 | 37 | 38 |
39 |
40 | ); 41 | }; 42 | 43 | export default CategoryMenu; 44 | -------------------------------------------------------------------------------- /client/src/components/admin/categories/EditCategoryModal.js: -------------------------------------------------------------------------------- 1 | import React, { Fragment, useContext, useState, useEffect } from "react"; 2 | import { CategoryContext } from "./index"; 3 | import { editCategory, getAllCategory } from "./FetchApi"; 4 | 5 | const EditCategoryModal = (props) => { 6 | const { data, dispatch } = useContext(CategoryContext); 7 | 8 | const [des, setDes] = useState(""); 9 | const [status, setStatus] = useState(""); 10 | const [cId, setCid] = useState(""); 11 | 12 | useEffect(() => { 13 | setDes(data.editCategoryModal.des); 14 | setStatus(data.editCategoryModal.status); 15 | setCid(data.editCategoryModal.cId); 16 | 17 | // eslint-disable-next-line react-hooks/exhaustive-deps 18 | }, [data.editCategoryModal.modal]); 19 | 20 | const fetchData = async () => { 21 | let responseData = await getAllCategory(); 22 | if (responseData.Categories) { 23 | dispatch({ 24 | type: "fetchCategoryAndChangeState", 25 | payload: responseData.Categories, 26 | }); 27 | } 28 | }; 29 | 30 | const submitForm = async () => { 31 | dispatch({ type: "loading", payload: true }); 32 | let edit = await editCategory(cId, des, status); 33 | if (edit.error) { 34 | console.log(edit.error); 35 | dispatch({ type: "loading", payload: false }); 36 | } else if (edit.success) { 37 | console.log(edit.success); 38 | dispatch({ type: "editCategoryModalClose" }); 39 | setTimeout(() => { 40 | fetchData(); 41 | dispatch({ type: "loading", payload: false }); 42 | }, 1000); 43 | } 44 | }; 45 | 46 | return ( 47 | 48 | {/* Black Overlay */} 49 |
dispatch({ type: "editCategoryModalClose" })} 51 | className={`${ 52 | data.editCategoryModal.modal ? "" : "hidden" 53 | } fixed top-0 left-0 z-30 w-full h-full bg-black opacity-50`} 54 | /> 55 | {/* End Black Overlay */} 56 | 57 | {/* Modal Start */} 58 |
63 |
64 |
65 | 66 | Add Category 67 | 68 | {/* Close Modal */} 69 | dispatch({ type: "editCategoryModalClose" })} 72 | className="cursor-pointer text-gray-100 py-2 px-2 rounded-full" 73 | > 74 | 81 | 87 | 88 | 89 |
90 |
91 | 92 |