This app architecture is inspired by create-react-app with a Node server on Heroku
This app uses :
- React front-end
- NodeJS back-end with Express
- PostgreSQL database
Documentation is located in doc folder.
-
Clone this project from GitHub with
git clone. -
Create an empty PostgreSQL database
-
Add the following environment variables for the server
/folder :
# URI to access database
DATABASE_URL=postgres://username:password@hostname:5432/database_name
# SECRET for JWT authentication
JWT_SECRET=random_64_bits_key
# For development only, add:
# DEV=true- Add the following environment variables for the React
/react-ui/folder with the following variable :
# API hostname
REACT_APP_API_HOST=https://api-hostname.com- Start the server with the following commands (run from the root
/folder of the project) :
- To install dependencies :
npm install - To build a production app :
npm build - To start the app :
npm start
- Add default values in database with SQL command :
Execute SQL statements in doc/first_setup.sql to populate database.
Default credentials for admin account :
- email : [email protected]
- password : test
The app is divided in two parts : the server and the React app.
The dependencies are managed with npm.
The server dependencies are located in package.json located at the root of the project.
The React app dependencies are located in react-ui/package.json
doc : documentation
react-ui : React App
|- public : public ressources
|- src : react app source code
|- assets : ressources
|- components : components for each role, included in pages
|- admin
|- commons
|- dev
|- godfather
|- laureate
|- navigation : navigation components for each role
|- pages : main pages of the app, include components
|- admin
|- godfather
|- laureate
|- ...
|- routes : react routers for each role, handle pages inclusion
|- AdminRouter
|- GodfatherRouter
|- LaureateROuter
|- styles : style files (scss)
|- App.js : React app main component, handle basic routing
|- index.js : React app entry point
|- .env : [optional] .env file with react app .env variables
|- package.json : React app package
server : Node.js server
|- algorithms : python algorithms
|- config :
|- index.js : config variables (secrets...)
|- controllers : api controllers that interract with the database
|- middlewares :
|- authJwt.js : JWT api authentication middleware
|- models : models for the database
|- routes : api routers
|- utils :
|- database.js : database connection
|- index.js : server creation
.env : [optional] .env file with server .env variables
package.json : server package