src
βββ common
β β
β β # contains fonts, translation, and other assets
β βββ assets
β β βββ fonts/
β β βββ translations/
β β βββ images/
β β βββ countries.json
β β
β β # reusable generic components
β βββ components
β β βββ Input
β β βββ index.ts
β β βββ Input.module.scss
β β βββ Input.tsx
β β
β β # only global store, sidebar, top loader, user data, etc.
β βββ redux
β β βββ actions.ts
β β βββ index.ts
β β βββ reducer.ts
β β βββ selectors.ts
β β
β β # axios wrappers, reusable generic data transformation utils, etc.
β βββ utils
β β βββ noop.ts
β β βββ round.ts
β β
β β # generic utility types
β βββ types
β β βββ NonEmptyArray.ts
β β βββ Number.ts
β β
β β # reusable generic hooks
β βββ hooks
β β βββ useFastDog.ts
β β βββ useSlowPoke.ts
β β
β βββ styles
β β β
β β βββ index.scss # entry point
β β βββ _reset.scss
β β βββ _functions.scss
β β βββ _mixins.scss
β β β
β β β # could be imported to access colors, variables, functions & mixins
β β β # inside Module's global or local scss, which gets imported in Module.tsx
β β βββ shared.scss
β β β
β β βββ _colors.scss # color variables
β β βββ _variables.scss
β β
β β # global constants like process.env.REACT_APP_ENV goes here
β βββ constants.ts
β
βββ Module
β β
β β # module-specific store subtree which gets imported and nested in a global store
β β # globalStore.module
β βββ redux
β β βββ actions.ts
β β βββ index.ts
β β βββ reducer.ts
β β βββ selectors.ts
β β
β β # module chunk for code-organization purposes, not reusable
β βββ SubModule
β β βββ index.ts
β β βββ SubModule.module.scss
β β βββ SubModule.tsx
β β
β βββ constants.ts # module specific constants (optional)
β βββ domain.ts # could be a folder if there's a lot of decoders/types there
β βββ hooks.ts # could be a folder in case there's a lot of hooks
β βββ index.ts
β βββ Module.module.scss
β βββ Module.tsx
β βββ utils.ts # could be a folder if there's a lot of module-specific utils
β
β # application main module (contains layout, routing, initialization, etc.)
βββ App.tsx
βββ index.tsx # application entry point
The idea behind this folder structure is to organize code according to a speicific module/domain.
This folder/project structure will let developers focus on a specific area they
currently working on. There will be no need to navigate to other folders that
may contain unrelated stuff, everything is under <module-name>
folder.
common
module is very important here and makes a lot of sense. It has a
similar structure to any other module. We can put generic re-usable components
there under components
folder, global utilities like http-client
under
utils
folder and global applications state can be defined under redux
folder. The idea is that usually we write things that are only relevant in some
module and if we encounter something that can be re-used in other modules, this
can go to common
module.