DEV Community

Discussion on: How To Structure Your App In a Way That Scales.

Collapse
 
jackmellis profile image
Jack

I like the use of the file extension (.component.js, .query.js) to denote the type of a file within a domain. However, personally I prefer to separate my concerns out a bit more.

If I'm looking for something that updates a specific cookie, or fetches some data from an api, for example; I'd probably spend longer digging around all of those feature folders for it than if I had my service layers separate from everything else. I always know my api requests or cookie updates will be in the service layer.

I also like to keep presentational and non-presentational stuff as far apart as possible. The view layer should only be concerned with 2 jobs: rendering data, and emitting events. It should almost operate in a bubble where it doesn't know anything about axios, or fetch, or cookies. The underlying tech is not a presentational concern. But if you put your services directly next to your components, you're tightly coupling the entire stack of your application.

Ack I'm rambling about architecture again! 🤦