phucpnt / frontend-react-multiple-app-structure

Frontend reactjs structure with multiple app (monorepo)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gettings started

  • On the root folder of project run the following command:
    • npm install
  • Run the following command:
    • npm run bootstrap

Development

  • npm run storybook
    • Go to the storybook and start developing there.
  • For each packages eg. pizza, chicken
    • Go to packages/{module}

Technical stacks

  • nodejs 12
  • yarn
  • lerna
  • webpack
  • storybook
  • reactjs
  • redux
  • jss (css in js)
  • react router
  • prettier (used with vscode)
  • eslint (used with vscode)
  • dockerfile (used for deploying frontend server)

The code structure

This package use monorepos approach. Each frontend packages will be organized as below:

  • /packages/sub1/src
    • /components ← presentation UI component, it should not contains any logic related to the data the business logic
      Each component defined should come with attached stylesheet.
      Use JSS for stylesheet
    • /containers ← stateful UI container, which orchestrating different components and connect to redux store
      The business logic should be defined here
    • /redux ← manage the state of redux store
      • /store.js ← master store should be defined here including the middleware of redux
      • /**.js ← more sub state setup defined here We would follow the Ducks setup. You can check more reference here
    • /util ← utility files with supportive functions
    • /app.js ← the root app
  • /packages/shared/src
    • This is where we promote the common components into this module. Those components should be mature enough to be used across difference packages

How the product would be built

  • The source code would be built by the Webpack.
    • The webpack build configuration can be access on ./webpack.config.js
    • You can run yarn run build, check the generated folder build-assets to see the final assets of the build
  • The deployment pipeline is setup by devops but you can read the ./Dockerfile to understand how the container is built
    • Note: you need to check with pipeline setup by devops for the correct and up-to-date build steps.

About

Frontend reactjs structure with multiple app (monorepo)


Languages

Language:JavaScript 93.0%Language:CSS 4.3%Language:SCSS 1.6%Language:HTML 0.6%Language:Dockerfile 0.4%Language:Shell 0.1%