/app

A Web app that supports mentorship programs at Visionary Education Foundation (远见教育基金会).

Primary LanguageTypeScriptGNU Affero General Public License v3.0AGPL-3.0

远图教育平台

远图 is a web app that supports mentorship programs at Visionary Education Foundation (远见教育基金会), developed by VEF volunteers.

Getting Started

  1. Install node.js and yarn.
  2. Install postgresql, start it locally, and create a database called yuanjian. Aternatively, use a hosted Postgres solution such as Neon.
  3. 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.
  4. Run yarn to install dependency packages.
    • If you run into error "$VERCEL_ENV" was unexpected, see this doc.
  5. Run yarn migrate-database to initialize the database.
  6. Run yarn dev to start local server. By default it will listen on localhost:3000.
  7. Visit the local server from broswer. Sign up with your personal email address.
    • When prompted to enter a verification code, find the "token": "..." string from yarn dev's command-line output and enter the token as the code.
  8. Run yarn gen-test-data to finish setup and populate test data.
  9. If you use MacOS, run chmod ug+x .husky/* to activate husky/git hooks.

Code Structure

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 of src/shared,
  • files in src/api must not refer to files outside of src/api or src/shared, and
  • files outside of src/api must not refer to files in src/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;
Loading

Testing

  1. 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 this doc.
  2. See this doc for end-to-end testing.

More Documentation

Browse the docs folder.