This is a general-purpose e-commerce app that can be repurposed to fit a specific product type. It is built with the MERN stack and uses the Stripe API to handle payments.
- npm
- Node.js
- Mongo Database(either local or cloud-based)
- Stripe Account
- Cloudinary Account
-
Create the following environment variables for your server, either by making a
.envfile or adding them to your deployment settings:ACCESS_KEYset to any string. This will be used to authenticate JWT access tokens.REFRESH_KEYset to another string. This will be used to authenticate JWT refresh tokens.FRONTEND_URLset to the client url if client is ran on a separate server (eg. React Development Server). Otherwise, it should be set to the url this project runs on. Used when redirecting from Stripe.STRIPE_SECRETset to the your Stripe account's secret key. Used to create stripe checkout sessions.DATABASEURLset to your MongoDB instance's URI.CLOUDINARY_URLset to your Cloudinary account's API Environment variable, found on your dashboard. Used to identify your account to Cloudinary's api.CLOUDINARY_FOLDERset to the folder you want your images to go to on your Cloudinary account. Before you do this, make sure to create the actual folder under the media library tab.ADMIN_USERNAMEset to the desired username of your admin user.ADMIN_PASSWORDset to the desirect password of your admin user.(Optional)
GOOGLE_CLIENTIDset to your Google API client ID. Add this if you want to include Google OAuth2.0 authentication. -
Next, add these environment variables to your client:
REACT_APP_STRIPE_PUBLISHABLEset to your Stripe account's publishable key. Used to load the stripe client.(Testing)
REACT_APP_BACKEND_URLset to your server's url if you intend to run the client on the React Development Server. This url will be used to proxy http requests to the server.(Optional)
REACT_APP_GOOGLE_CLIENTIDset to your Google API client ID. Add this if you want to include Google OAuth2.0 authentication. -
Run
npm installin the root directory to add all server dependencies. -
Run
npm run buildto add your admin user and set up the client. -
Run
npm startto start the server. If you want to start the React Development Server, you can also runnpm startin the client directory.
Note: You only need to repeat step 5 on subsequent runs.