Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,60 @@ _Found it useful? Want more updates?_
Check out our Playground Project located in the `/playground` folder. It contains all source files of the code examples found in the guide. They are all tested with the most recent version of TypeScript and 3rd party type-definitions (like `@types/react` or `@types/react-redux`) to ensure the examples are up-to-date and not broken with updated definitions (It's based on `create-react-app --typescript`).
> Playground project was created so that you can simply clone the repository locally and immediately play around with all the component patterns found in the guide. It will help you to learn all the examples from this guide in a real project environment without the need to create complicated environment setup by yourself.

## Scalable Application Structure

When the app grows, organizing files by feature helps keep module boundaries clear and keeps dependencies directional.

### Goals

- Group files by feature, not by technical type
- Add or remove features with minimal change outside the feature folder
- Enable or disable optional features on demand
- Keep features reusable and pluggable across different Redux applications

### Feature module layout

```bash
src/
app/
store.ts
root-action.ts
root-epic.ts
root-reducer.ts
Comment on lines +71 to +75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the rest of the guide (which references RootAction and RootEpic in the Store Configuration section), it is recommended to include these files in the app/ folder example. This clarifies where the global Redux plumbing resides.

Suggested change
app/
store.ts
root-reducer.ts
app/
store.ts
root-reducer.ts
root-action.ts
root-epic.ts

features/
todos/
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
services.ts
models.ts
components/
containers/
index.ts
Comment on lines +78 to +87

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The dependency direction rules mention services, but this file is missing from the example layout. Also, for consistency with existing examples in this guide (e.g., lines 1545, 1600), models.ts is preferred over types.ts for feature-specific type definitions.

Suggested change
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
types.ts
components/
containers/
index.ts
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
services.ts
models.ts
components/
containers/
index.ts

```

This structure keeps each feature self-contained and exposes only the public API through `features/<feature>/index.ts`.

### Import dependency direction

- dumb components -> feature models
- smart/connected components -> feature selectors + actions -> feature models
- selectors -> feature models
- reducer -> feature actions -> feature models
- side-effects (epics/thunks/sagas) -> feature actions + selectors + services -> feature models
- services -> feature models

If you keep this direction stable, refactoring internals (renaming files, moving private helpers, splitting modules) does not leak outside of the feature module.

### Cross-feature communication rules

- Cross-feature reads should happen via exported selectors only
- Cross-feature writes should happen via exported actions only
- Avoid importing internal files from another feature (import from `index.ts` public API)
- Keep selector dependencies one-way to prevent cyclic coupling between features

## Contributing Guide

You can help make this project better by contributing. If you're planning to contribute please make sure to check our contributing guide: [CONTRIBUTING.md](/CONTRIBUTING.md)
Expand Down
54 changes: 54 additions & 0 deletions README_SOURCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,60 @@ _Found it useful? Want more updates?_
Check out our Playground Project located in the `/playground` folder. It contains all source files of the code examples found in the guide. They are all tested with the most recent version of TypeScript and 3rd party type-definitions (like `@types/react` or `@types/react-redux`) to ensure the examples are up-to-date and not broken with updated definitions (It's based on `create-react-app --typescript`).
> Playground project was created so that you can simply clone the repository locally and immediately play around with all the component patterns found in the guide. It will help you to learn all the examples from this guide in a real project environment without the need to create complicated environment setup by yourself.

## Scalable Application Structure

When the app grows, organizing files by feature helps keep module boundaries clear and keeps dependencies directional.

### Goals

- Group files by feature, not by technical type
- Add or remove features with minimal change outside the feature folder
- Enable or disable optional features on demand
- Keep features reusable and pluggable across different Redux applications

### Feature module layout

```bash
src/
app/
store.ts
root-action.ts
root-epic.ts
root-reducer.ts
Comment on lines +71 to +75

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the rest of the guide, it is recommended to include root-action.ts and root-epic.ts in the app/ folder example.

Suggested change
app/
store.ts
root-reducer.ts
app/
store.ts
root-reducer.ts
root-action.ts
root-epic.ts

features/
todos/
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
services.ts
models.ts
components/
containers/
index.ts
Comment on lines +78 to +87

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including services.ts and using models.ts (for consistency with other examples) would improve the clarity of the feature module layout.

Suggested change
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
types.ts
components/
containers/
index.ts
actions.ts
constants.ts
epics.ts
reducer.ts
selectors.ts
services.ts
models.ts
components/
containers/
index.ts

```

This structure keeps each feature self-contained and exposes only the public API through `features/<feature>/index.ts`.

### Import dependency direction

- dumb components -> feature models
- smart/connected components -> feature selectors + actions -> feature models
- selectors -> feature models
- reducer -> feature actions -> feature models
- side-effects (epics/thunks/sagas) -> feature actions + selectors + services -> feature models
- services -> feature models

If you keep this direction stable, refactoring internals (renaming files, moving private helpers, splitting modules) does not leak outside of the feature module.

### Cross-feature communication rules

- Cross-feature reads should happen via exported selectors only
- Cross-feature writes should happen via exported actions only
- Avoid importing internal files from another feature (import from `index.ts` public API)
- Keep selector dependencies one-way to prevent cyclic coupling between features

## Contributing Guide

You can help make this project better by contributing. If you're planning to contribute please make sure to check our contributing guide: [CONTRIBUTING.md](/CONTRIBUTING.md)
Expand Down