Our main, actual, real repo for the project.
It's a CRM with a different C. This software is used to manage the user's contacts and their relationships, which can be either professional or personal. In addition, it's also may have a instant message feature.
We will follow a trunk-based approach, where developers collaborate on a single branch and avoid creating other long-lived feature branches. We will create a branch, code it, pull request it and merge it. Then we will create another branch to code other part of the software. This avoid merge hell when we finalize the product.
Note: Alway run npm test
on root folder first before create a pull request, even if you changed only frontend. The reason is mongoDB need some time to "wake up" first (as we used free version), so this will make sure that the CI test on Github will run successful. If the npm test
fail and you sure that you don't change anything that may affect it, re-run it a few more times.
Naming convention:
-
For files and folders, use lowercase letter and hyphen between words. Examples:
file-name
,backend
,main-file.js
,src/a-very-long-file-name.js
, etc.. -
For branch, they should have a clear and concise name what they are implementing (should focus on one task at a time). Use hyphen or space between words for better clarity. Example:
mocha-test
,schema DB
,User-Authentication
, etc..
In addition, it's better to commit frequently. This way, we can easily see the reasons for code change and follow the thought process of the developer. Don't mistake between commit and push/pull request though.
Exception: For documentation and README
file (simple text files), you can just push them directly. No need to pull request.
TLDR: Use branching feature, commit a lot and use pull request.
Add .env
file at the root of the project. Fill neccessary information into it (contact Lam if you don't know).
In the project directory, you can run these in the terminal:
To install the neccessary dependencies. Remember to do this in both root folder and /client
folder.
To build static files.
To start the frontend.
To runs the server backend in the development mode.
After run all above commands (ideally in 2 terminals, one for frontend and one for backend), it should open a new web window at localhost:3000
and displayed some frontpage content there.
To runs the Mocha tests in /test
folder.
|__docs/
|__prototypes/
|__test/
|__img/
|__client/ ** THIS IS EVERYTHING FROM THE REACT SIDE **
|__ node_modules/ ** THIS BELONG TO FRONTEND
|__ tons of stuff...
|__ public/
|__ index.html
|__ favicon.ico
|__ etc.
|__ src/
|__ index.js
|__ App.js
|__ etc.
|__ node_modules/ ** THIS BELONG TO BACKEND
|__ stuff...
|__ models/
|__ user.js
|__ event.js
|__ etc.
|__ config/
|__ config.js
|__ routes
|__ userRoutes.js
|__ eventRoutes.js
|__ etc.
|__ .gitignore
|__ .env ** ALTHOUGH GITIGNORED, IT IS REQUIRED
|__ package.json
|__ server.js
|__ etc.
This file is placed at project's root (same as server.js
)
# Backend stuff
port = _____
host = _____
#### DB_CONFIG ####
DB_USER = _____
DB_PASSWORD = _____
DB_URL = _____
DB_NAME = _____
DB_TEST_NAME = _____
# Passport and JWT
PASSPORT_SECRET = _____
# Nodemailer
NODEMAILER_SERVICE = _____
NODEMAILER_USER = _____
NODEMAILER_PASS = _____
Indent space: 2
Variable name: camelCase. Example: smallNumber, dateOfBirth.
Database model name: Start with uppercase. Example: User, Contact, Event.
Use const
when require modules.
For frontend, follow the README.md
in folder client
.
https://www.toptal.com/software/trunk-based-development-git-flow https://www.youtube.com/watch?v=2AIL1c-cJM0&ab_channel=TheFullStackJunkie