Idea of this file is to provide necessary information for:
- Setting up development environment
- How the contribution flow goes
This getting started sections helps you setup and start development environment.
Note: Windows users check what the scripts do and then do it manually :)
npm run dev:install
- Generates
.env
and.env.test
files - Installs depencies
- Applies migrations
- Seeds database
- Generates
Note: Runs script located at
scripts/dev_install.sh
Note: If you want to use
npm run dev
- To stop use CTRL + C in terminal
Note: Runs script located at
scripts/dev_start.sh
Note: To access database directly see Prisma studio
- Create an issue for fix or feature
- Put label
task
, and assign it to current sprint in backlog
- Put label
- Create new branch from
staging
branch- Naming convention for new branch is
#{issue number}/{fix/feat}/{optionally additional information}
- E.g.
#11/fix/duplicate-courses
or#45/feat/add-courses
- Naming convention for new branch is
- Move task to
In Progress
in backlog, then do required changes and push the new branch- Tests are required, refer to definition of done
- Create pull request against
staging
branch- Assign someone from project to review it, and wait for approval
- After pull request is approved, merge it and delete the merged branch
Note: All changes made to
staging
are merged tomain
branch after meeting the client
This helps to identify what to look for when reviewing pull request. Most importantly pull request should be linked to task or set of tasks.
- Code quality
- When reading code you should not have to ask yourself what does this do
- No hard limit for file length, but when it goes over 250 it might be time to split its functionalities
- Code should be splitted to appropriate folders
app
: should not contain much logic, only usage of folderscomponents
andlib
components
: any UI components required byapp
lib
: utilities, third party libs, etc.
- TypeScript
- Should not use
any
type unless it has good reason
- Should not use
- Form validation
- Form validation should use Zod library
- Schema is only defined once and its used in frontend and backend (api folder)
- UI
- The styling should follow same format as other parts of site
- No hardcoded colors, use theme
- UI should be responsive
- Errors should be handled, and the user informed of them (without sensitive data)
- Tests
- Feature has meaningful tests which cover edgecases
- Documentation
- Code itself should be documented (or refactored) if you have to ask yourself what does this do
- If changes to code affect anything in
docs
folder, they should be updated
- Security
- Should trainer or user be able to access this, if not is it prevented?
- No sensitive information in git or logs
- Performance
- Middleground between poorly optimized code and complex algorithms is usually good enough
- Translation keys
- The code includes i18n keys instead of hardcoded strings
- The key naming follows the project's Translation Key Naming Guide
There are two main branches main
and staging
. Main branch is for production. Staging branch
is mostly for developers to test new features in very similar environment as production without the
fear of breaking important things. Here is simple diagram to show branching flow:
graph TD;
A[New feature or fix branch] -->|Merge| B[Staging Branch];
B -->|Merge| C[Main Branch];
C -->|Deploy| D[Production];
B -->|Deploy| E[Staging];
Prisma studio is tool that can be used to visualize and add records to database. Use npx prisma studio
to run it.
- Run
npx prisma migrate dev
, and follow the instructions - Push the generated migration to git
You can also refer to Prisma customizing migrations
- Run
npx prisma migrate dev --create-only
, and follow the instructions. - Edit the generated migration
- For example model
user
hadimage
column which is moved to modeluser_information
asprofile_image
column. In this case you would have to modify themigration.sql
to insertimage
column data toprofile_image
column for correct user id.
- For example model
- Run
npx prisma migrate dev
to apply the changes and verify that the data migration worked - Push the generated migration to git
Course reminders are scheduled with GitHub Actions workflow. For more details see documentation.