Skip to content

Commit 0722352

Browse files
Surjit Kumar SahooSurjit Kumar Sahoo
authored andcommitted
add application structure
1 parent 8ce592d commit 0722352

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

docs/1.architecture/5.how-to-structure-react-application.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ sidebar_position: 5
1111

1212
```txt title="sample folder structure for YouTube"
1313
YouTube/
14-
├── layouts/ // <------- only high-level page layouts, they dont know any of the feature details
15-
├── pages/ // <--------- Pages are what get displayed on different routes, Pages are constructed using several features
16-
├── routes/ // <-------- Top level routes, feature level sub routes should be maintained in feature level
17-
├── common/ // <-------- common components, helpers, hooks etc all go here, these will be used throughout all the features
14+
├── layouts/ <------- only high-level page layouts, they dont know any of the feature details
15+
├── pages/ <--------- Pages are what get displayed on different routes, Pages are constructed using several features
16+
├── routes/ <-------- Top level routes, feature level sub routes should be maintained in feature level
17+
├── common/ <-------- common components, helpers, hooks etc all go here, these will be used throughout all the features
1818
└── features/
19-
├── player/ // <----- All the player related code (components, hooks, states, apis, helpers, configs) go inside this folder
20-
│ ├── index.ts // <--- Public API: exports only the high-level components
21-
│ ├── defaultPlayer // <--- the default main video player
22-
| | ├── hooks/ // <---- default player hooks (if any)
23-
| | ├── helpers/ // <---- default player helper functions
24-
| | ├── defaultPlayer.tsx // <------- component code
19+
├── player/ <----- All the player related code (components, hooks, states, apis, helpers, configs) go inside this folder
20+
│ ├── index.ts <--- Public API: exports only the high-level components
21+
│ ├── defaultPlayer <--- the default main video player
22+
| | ├── hooks/ <---- default player hooks (if any)
23+
| | ├── helpers/ <---- default player helper functions
24+
| | ├── defaultPlayer.tsx <------- component code
2525
| | ├── defaultPlayer.test.tsx
2626
| | ├── defaultPlayer.css
27-
| | └── index.ts // <---- exports the default player component.
28-
│ ├── miniPlayer // <------ minimized player, only shows thumbnail, title, duration and progress
29-
│ ├── pipPlayer // <------- picture in picture player
30-
| ├── helpers/ // <--- common player helper functions
31-
| ├── api/ // All the player APIs
27+
| | └── index.ts <---- exports the default player component.
28+
│ ├── miniPlayer <------ minimized player, only shows thumbnail, title, duration and progress
29+
│ ├── pipPlayer <------- picture in picture player
30+
| ├── helpers/ <--- common player helper functions
31+
| ├── api/ All the player APIs
3232
│ └── hooks/
33-
│ └── useCurrentlyPlaying // <--- provides live data of currently playing video, progress, duration, title etc.
33+
│ └── useCurrentlyPlaying <--- provides live data of currently playing video, progress, duration, title etc.
3434
|
35-
└── chat/ // <-------- All the chat / comments related code goes here
35+
└── chat/ <-------- All the chat / comments related code goes here
3636
├── comments
3737
└── liveChat
3838
```
@@ -43,15 +43,15 @@ In the above example, all the files are neatly separated. chat components should
4343

4444
```txt title="Bad folder structure example"
4545
YouTube/
46-
├── components/ // <------------ All the components kept together: all mixed up!
46+
├── components/ <------------ All the components kept together: all mixed up!
4747
│ ├── player.tsx
4848
│ ├── player.test.tsx
4949
│ ├── miniPlayer.tsx
5050
│ ├── miniPlayer.test.tsx
5151
│ ├── chat.tsx
5252
│ ├── chat.test.tsx
5353
│ └── ...
54-
├── routes // <---------------- All the routes defined together: all mixed up!
54+
├── routes <---------------- All the routes defined together: all mixed up!
5555
├── utils
5656
├── hooks/
5757
│ ├── useChatGroups.ts

0 commit comments

Comments
 (0)