远图 is a web app that supports mentorship programs at Visionary Education Foundation (远见教育基金会), developed by VEF volunteers.
- Install
node.js
andyarn
. - Install
postgresql
, start it locally, and create a database calledyuanjian
. Aternatively, use a hosted Postgres solution such as Neon. - Create file
.env
in the repository root, and:- If you are an active Yuanjian volunteer, copy content from this Notion page.
- Otherwise, copy content from
.env.template
and configure required fields.
- Run
yarn
to install dependency packages.- If you run into error
"$VERCEL_ENV" was unexpected
, see thisdoc
.
- If you run into error
- Run
yarn migrate-database
to initialize the database. - Run
yarn dev
to start local server. By default it will listen onlocalhost:3000
. - Visit the local server from broswer. Sign up with your personal email address.
- When prompted to enter a verification code, find the
"token": "..."
string fromyarn dev
's command-line output and enter the token as the code.
- When prompted to enter a verification code, find the
- Run
yarn gen-test-data
to finish setup and populate test data. - If you use MacOS, run
chmod ug+x .husky/*
to activate husky/git hooks.
We follow next.js convention:
public |
Static assets. |
src |
Source folder. Files under src but outside of src/api may be executed either in the browser or on the server. |
src/api |
Files to be executed on the server only. |
src/pages |
next.js Page Router. Migrating to App Router remains future work. |
src/shared |
Files shared between src/api and the rest of src . |
tools |
Command-line scripts. |
cypress/e2e |
End-to-end tests. See documentation . |
To prevent security and programming issues, eslint is configured to enforce the following rules:
- files in
src/shared
must not refer to files outside ofsrc/shared
, - files in
src/api
must not refer to files outside ofsrc/api
orsrc/shared
, and - files outside of
src/api
must not refer to files insrc/api
That is, only the dependencies demonstrated below are allowed:
graph TD;
src[the rest of src]-->|ok|src/shared;
src/api-->|ok|src/shared;
- Run
yarn test
to run all unit tests.- If you run into error
TS_NODE_PROJECT' is not recognized as an internal or external command
, see thisdoc
.
- If you run into error
- See this doc for end-to-end testing.
Browse the docs
folder.