Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ADR 0009 for frontend directory structure #27

Merged
merged 1 commit into from
May 16, 2023
Merged
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
70 changes: 70 additions & 0 deletions adr/0009-frontend-directory-structure-and-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# 9. Frontend directory structure and architecture

Date: 2023-05-16

## Status

Accepted

## Context

Our software project has a frontend that needs to be organized to facilitate maintenance, scalability, modularity, and ease of navigation. The current directory structure is outdated and hard to manage. As software engineers, we propose a new directory structure based on some criteria.

We studied [Redux' documentation](https://redux.js.org/faq/code-structure/) about common patterns for project structures.

Most of the discussion happened reviewing [web/#1355](https://github.com/trento-project/web/pull/1355).

## Decision

We propose the following new directory structure for the frontend of our software project:
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add some link to the react docs?
https://redux.js.org/faq/code-structure/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doin' this right now :D


```
assets/js
├── app.js
├── common
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be a good idea to define what this common holds.
According redux docs:

/common contains truly generic and reusable utilities and components.

Maybe we can put this sentence as paragraph below, so we have a written and aknowledged agreement hehe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're totally right 👍

│   ├── Banners
│   ├── Button
│ │   ├── Button.js
│ │   ├── Button.stories.js
│ │   ├── Button.test.js
│   │ └── index.js
│   ├── ListView
│   ├── Modal
│   ├── ObjectTree
│   ├── Table
│   ├── Tags
│   └── Tooltip
├── pages
│   ├── AboutPage
│   ├── ChecksCatalog
│   ├── ClusterDetails
│   ├── DatabaseDetails
│   ├── DatabasesOverview
│   ├── ExecutionResults
│   ├── Health
│   ├── HealthSummary
│   ├── Home
│   └── HostDetails
├── hooks
├── lib
├── state
│   ├── sagas
│ │   ├── clusters.js
│ │   ├── clusters.test.js
│   │ └── index.js
│   ├── selectors
│ │   ├── clusters.js
│ │   ├── clusters.test.js
│   │ └── index.js
│   ├── clusters.js
│   ├── clusters.test.js
└── trento.jsx
```

Note that `/common` contains truly generic and reusable utilities and components.

## Consequences

There may be some overhead associated with restructuring the frontend, such as updating dependencies, fixing references, or rewriting some parts of the application. However, in the long term, this new directory structure will ensure an organized and efficient system that can be easily maintained, scaled, and navigated. The new structure will also facilitate collaboration between developers as they will have a better understanding of where everything is located.

We have one drawback: action creators related to sagas now live along with slices and action creators generated by redux-toolkit. We found reasonable to have action creators all stuffed in one specific place, but it is well understood that it might not be the case for everyone.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this exactly mean?
That the content we have now in actions folder goes to the reducers file?
Each of the action respectively with the domain file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, we can squash all together 👍