Use this template to initialize your MongoDB, Express, React, and Node.js web application or website with a basic structure and starter code stylized with Chakra UI.
Work In Progress
- Download Node.js.
- Download the nodemon package globally.
- Download MongoDB Community Server.
- Create a
.env
file in the root directory to hold environment variables. (dotenv module)- LOGGED_IN=true - log in upon server refresh for user development
- DEV_USER_ID=[MongoDB _id] - MongoDB _id of a record to automatically log in with
- Edit the name of your database by editing the
DB_NAME
constant inindex.js
. - Edit metadata information for SEO and data accuracy in:
client/public/index.html
client/public/manifest.json
client/public/robots.txt
client/public/sitemap.xml
package.json
README.md
- Run
npm install
in both the root andclient
directories to install packages.
- Ensure that your MongoDB server is running locally for database functionality.
- Run
nodemon
in the root directory while developing to automatically refresh your back-end (Node.js server) after editing. - Run
npm start
in theclient
directory while developing to automatically refresh front-end (React app) after editing. - Work on back-end by editing
models
,routes
, andindex.js
. - Visit
http://localhost:3000/
(React app) to see front-end changes.- The React App uses a proxy to port 4000, so you may fetch Express routes like
/users
.
- The React App uses a proxy to port 4000, so you may fetch Express routes like
Run npm start
in the client
directory to start the React app at port 3000.
Run npm start
in the root directory to start the Node server at port 4000.
- The
auth
directory contains Passport.js configurations. (Work In Progress) - The
client/public
directory contains front-end assets and site metadata. - The
client/src
directory contains React front-end. - The
models
directory contains MongoDB models. - The
routes
directory contains routes for endpoints and API calls.
- Create a MongoDB Atlas database and collection and copy your connection URI.
- Create a Heroku app and enable automatic deployment to your repository.
- Set environment variables for your Heroku app.
- MONGO_URI - MongoDB Atlas connection URI
- SESSION_SECRET - Express session secret
- Chakra UI v1.1.2
- Express v4.x
- Mongoose v5.12.2
- @chakra-ui/react - main styling
- bcryptjs - password-hashing
- body-parser - essential for express
- chalk - colorful terminal output
- compression, cors, helmet - essential middleware
- dotenv - environment variables
- express - essential
- express-session - sessions
- lodash - coding utility
- method-override - enabling methods for the client
- mongoose - database functionality
- nodemon - development quality of life
- passport - authentication
- react-query - client-side api fetching
- validator - formatting validation
- More detailed starter code
- Additional example pages
- Sign up and log in pages
- Passport.js authentication
- Email-encryption and forgot password functionality
- Full database functionality
- Additional example pages
- Can I Use... - Browser support tables for HTML5, CSS3, etc
- Coolors Color Picker
- Font Awesome Icons Gallery
- Google Fonts
- Hero Patterns - Customizable SVG background patterns
- Lorem Ipsum Generator
- Placeholder.com - Free image placeholder service
- Regex Expression Tester
- Scale - Free and customizable vector illustrations
- SRI Hash Generator