FelixHenninger / lab.js

Online research made easy
https://lab.js.org/
Other
246 stars 109 forks source link

refactor - global : new folder structure #66

Closed rbalet closed 4 years ago

rbalet commented 4 years ago

What would you like

A new folder structure

I'm coming from angular and I'm struggling a little bit with th actual folder structure. I hope it will make sens, but I want to add this issue so, maybe, we could debate with some react developers about the right good folder structure. I know I still have a lot to learn here :)

I've already published a folder structure for angular that we can use. I also had a look at this article which was talking about how the guy was structuring his react project.

So, here is a quick proposal (I'm not a react pro and hope it will make sense, if not then I excuse myself '^^).

src
├── assets (will contain flask_micro.png & logo.blue.png if it is still used)
├── components (*components)
├── layouts (*layouts - further explenation)
├── pages (*pages)
├── core (*core)
│ └── logic
└── store (store.js)
├── actions
└── reducers

I see the problem that will arrise about paths, but once we will have update to typescript, we would be able to use path from our tsconfig.json file and it will make everything much more cleaner :)

Further explanation :

*components the actual folder, I also wanted to add a fragment folder (I explain the difference here), but it isn't really react standard

*layouts We already have a layout folder but it is quite static, what I would do is :

Doing it like this would help us :

  1. Remove the sidebar in one click (if we want to hide it when we are on smaller laptop)
  2. Adding into the sidebar-content some specificity (useful for #51 and #56)

*pages I cannot find the main page '^^ I thought at the beginning that it was the App folder but doesn't look like, is this folder still used? Objective : put our page here, so when someone starts working on the repo he would be able to see directly where the app start, also see that we have only one page and so on. (this folder isn't that important, but could be useful if the app need another page or so one)

*core Contains global function that our app need to run, will make sense later if we add interfaces, although I'm not really sure how to organize it in this project. I also added the logic folder inside (can possibly don't make any sense '^^)

Well, I hope I didn't tell too much foolish things.

FelixHenninger commented 4 years ago

Hej Raphaël, and many thanks for your feedback! I for sure hear you regarding the folder structure -- there's for sure some potential for improvement here, and it's valuable to get an outside perspective, so let's cease this opportunity!

I think you might find it interesting to look at the folder structure for create-react-app to get started, because they describe the code entry point we use (src/index.js). There are also countless articles about structuring redux apps, which (to my mind) resemble our code much more closely than the article linked above.

Here are a couple of quick thoughts: First, we have quite a number of the folders you propose already, simply because some are standards in the React (or rather Redux) world, such as actions and reducers. Regarding the other differences:

Ok, so much for now -- I hope things make slightly more sense, and helps you navigate the code a little better. I'm in principle open to restructuring, but as with many things I would ask you to do a cost/benefit analysis: I personally have a strong preference for working on specific functionality, and I would encourage you to work with the code a bit, and let's fix things as specific pain points become clear. I realize that you are used to a different project structure, please understand that I'm used to what we have right now 🙂.

Kind regards, and thanks again for your feedback!

-Felix

rbalet commented 4 years ago

I think only the cost/benefit analysis make the difference here and I completely agree with you.
I'm closing the Issue for the moment :)