This repository contains the codebase for the Addis-School project.
Please notice that the project does not include a mongoDB connection setup. The connection setup procedure varies from environment to environment:
- Local Development: You are required to create a
config.js
file within the config directory, which should export yourdb.uri
connection. An example of this setup is provided inconfig/config.example.js
. This file will be ignored by git, ensuring the safety of your database credentials upon deployment. - Production: As the config file does not get pushed during deployment, you need to specify your database URI in Heroku. Follow the instructions in this tutorial to set the URI in Heroku. Make sure to name the environment variable "DB_URI".
This repository demonstrates the application of MERN stack technology and includes a descriptive file structure as a base. The project is aimed at clear readability and the application of good coding practices.
The project contains both the client and server applications; therefore, there will be Node modules in two separate places. The locations are as follows:
- addis-school
- school-api/package.json
- school-dashboard/package.json
A script embedded in the package.json
makes this application ready to be deployed to Heroku. This script automatically handles the build and deployment of the app. For more information about Heroku deployments, refer to the resources provided at the end of this file.
-
public
- Holds all static filessrc
assets
- Holds assets such as images, docs, and fontscomponents
- Includes all the different components that constitute our viewsviews
- Correspond to a unique page on the website i.e. Home or AboutApp.js
- Renders all our browser routes and different viewsindex.js
- Renders the react app by renderingApp.js
.
package.json
- Defines npm behaviors and packages for the client
-
config
- Holds configuration files, like mongoDB URIcontrollers
- Holds all callback functions that each route will callmodels
- Contains data modelsroutes
- Contains HTTP to URL path associations for each unique URLtests
- Contains all server testsserver.js
- Defines npm behaviors and packages for the client
Within the project directory, the provided scripts aid in running the project during different stages of development:
-
npm run-script dev
- Runs both the client and server applications in development mode. Access the client application here. -
npm run-script client
- Runs only the client application in development mode. Access the client application here. -
npm run build
- Bundle React in production mode and optimizes the build for the best performance. This does not need to be run if deploying to Heroku, as it is handled by theheroku-postbuild
script. Refer to the deployment section for more information.
To get additional information, check the following resources:
- Create React App documentation
- Connect to MongoDB
- Guide to deploy a full-stack web app to Heroku
- React documentation
If npm run build
fails to minify, move to this link.