Skip to content

Latest commit

Β 

History

History

FolderStructure

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Β 
Β 

Folder Structure

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.