Skip to content

Structure

David Park edited this page Oct 19, 2023 · 2 revisions

Structure

Frontend

  • All the files for frontend work are in frontend/src.
  • frontend/src/component contains all the React components for frontend pages.
  • frontend/src/api/ contains all api files which are used for communication between frontend and backend.

Backend

Three main folders for backend include:

  1. Models in backend/models
  2. Routes in backend/routes
  3. Services in backend/services

Flow of Data

  • In order for frontend pages to communicate with backend (such as database), the flow of data is router -> handler -> actual functions (business logic)
  • For example, in order to create a new Stakeholder model, the data flow would be:
    • Call createStakeholder function in stakeholderAPI, which is in frontend/api.
    • To handle the API call, the router in routes/stakeholder.js will call handler, which is in services/stakeholder/stakeholder.js.
    • The createStakeholderHandler function will first do validation in order to check if the user has correct access.
    • If the validation fails, the attempt to create a new Stakeholder model will fail.
    • If the validation succeeds, it will call createStakeholder function, which creates the stakeholder model.

Models

  • Models represent the various types of abstract objects in database that are used for the project.
  • It includes Group, Person, Ownership, etc.

Routes

  • Routes represent the routers for API calls.
  • They decide on which backend function (handler) they will use to handle an API call.
  • loader/express.js are used.

Services

  • Services represent handlers, which are business logic (functions) that does actual work that can modify the database (backend).
Clone this wiki locally