跳到主要内容

Development Guide

This guide will help you get started with the development of the project.

Frontend​

Installation​

  1. Ensure you have node and pnpm installed.

  2. After cloning the repository, run the following command. This will install all dependencies as well as build all local packages.

    cd ./ui
    pnpm install
    // This command will help you create the tools you need for good front-end code validation to ensure that the code style
    pnpm setup-lint
  3. To start a development server, run pnpm start. now, your browser should already open automatically, and autoload http://localhost:3000. you can also manually visit it.

  4. To switch API, you can modify the ui/.env.development file and then re-run pnpm start. If you're just using it yourself, we recommend creating a .env.development.local file that defines the address of the api you're going to use.

Code conventions​

  • Most important: Look around. Match the style you see used in the rest of the project. This includes formatting, naming files, naming things in code, naming things in documentation, etc.
  • We do have Prettier (a formatter) and ESLint (a syntax linter) to catch most stylistic problems. If you are working locally, you can run pnpm setup-lint, which will help you initialize your husky and pre-commit files, which will automatically help you check your commits during the commit phase. Or just run pnpm lint and pnpm prettier to fix most code formatting.
  • No runtime errors Before submitting the code, please ensure that there will be no errors when running locally. This will greatly reduce the workload of review.
frontend package structure
.
├── cmd
├── configs
├── ...
└── ui (front-end project starts here)
├── build (built results directory, usually without concern)
├── public (html template for public)
├── scripts (some scripting tools on front-end project)
├── src (almost all front-end resources are here)
├── assets (static resources)
├── common (project information/data defined here)
├── components (all components of the project)
├── hooks (all hooks of the project)
├── i18n (Initialize the front-end i18n)
├── pages (all pages of the project)
├── router (Project routing definition)
├── services (all data api of the project)
├── stores (all data stores of the project)
├── utils (all utils of the project)
├── plugins (UI Plugin Development & Debugging Directory)

Backend​

Installation​

  1. Ensure you have golang installed.

  2. After cloning the repository, run the following command for build.

    go mod download
    go run cmd/answer/main.go init -C ./answer-data
  3. Visit http://localhost to see the installation page and complete the installation.

  4. Run the following command to start the server.

    go run cmd/answer/main.go run -C ./answer-data

Code conventions​

We recommend that you follow uber's Golang Guidelines code style.

backend package structure
.
├── cmd (main binary)
├── configs (default configuration)
├── docs (swagger documentation)
├── i18n (International translation)
├── internal
├── base (Basic component without service attributes)
├── conf (Configuration)
├── constant (constant)
├── data (database/cache)
├── handler (request/response handler)
├── middleware (http middleware)
├── pager (Pagination)
├── reason (error reason key use to translator)
├── server (http server)
├── translator (translator for translate international)
└── validator (validator for validate request)
├── cli (binary commands)
├── controller (request handler controller for user)
├── controller_backyard (request handler controller for admin)
├── entity (all entity about database table)
├── install (installation related)
├── migrations (upgrade related)
├── repo (database/cache operations)
├── router (http router)
├── schema (request/response schema)
└── service (business logic)
├── pkg (tools or third party)
└── ui (frontend)