{"componentChunkName":"component---src-templates-post-js","path":"/blog/folder-structure-for-front-end-apps","result":{"data":{"markdownRemark":{"frontmatter":{"date":"14 de outubro de 2019","title":"Folder structure for front end apps","description":"Front end structure I've been enjoying working with"},"html":"<h2>Intro</h2>\n<p>There are several ways to structure front end projects and none of them are silver.</p>\n<p>The best structure is where it is clear about each folder you make and what each file is for.</p>\n<p>It needs to be consistent to the point that new people on the team can easily and finally understand everyone who needs to be comfortable with the structure.</p>\n<p>I uploaded on Github a <a href=\"https://github.com/emunhoz/react_boilerplate\">Boilerplate with React + Redux</a> that today makes a lot of sense to me.</p>\n<h2>About my fav stack</h2>\n<ul>\n<li>React</li>\n<li>Redux with Ducks pattern 🦆</li>\n<li>Styled-components 💅</li>\n<li>Axios</li>\n</ul>\n<h2>The structure</h2>\n<h3>Components</h3>\n<p>Starting with the <code class=\"language-text\">components</code> folder: I use all stateless components, ie they only get data to assemble the user interface. There is no business logic in these files nor redux.</p>\n<h3>Containers</h3>\n<p>The <code class=\"language-text\">containers</code> folder is where the main logic with business rules lies. It is also responsible for API requests, redux (if any) and calls the correct components for the view layer.</p>\n<h3>Pages</h3>\n<p>Responsible for assembling the template with all the containers needed to serve the route file and present the final page to the user. There is no logic, no redux. At most, one style file for organizing containers / components on the page.</p>\n<h3>Services</h3>\n<p>The services folder is responsible for organizing API requests. For example, a <code class=\"language-text\">user.js</code> file within this folder would have all functions involving creating, updating, and deleting a user.</p>\n<h3>Store</h3>\n<p>All application state management using <a href=\"https://github.com/erikras/ducks-modular-redux\"><em>ducks pattern</em></a>. The lean way of using ducks as a pattern in redux makes it much easier to build modules without having to. keep creating multiple and multiple files. Its difference with other structures is the union of actions, reducers and types in a single file and this does not mean that their modules will be large, in most cases the modules can have a maximum of 5 or 6 actions.</p>\n<h3>Styles</h3>\n<p>Where is the general style of the application. Where I defined the <a href=\"https://edermunhozsantos.netlify.com/css-grid/\">grid</a> layout, themes, fonts ...</p>\n<h3>Utils</h3>\n<p>And finally, the utils folder are generic functions that can be reused throughout the application: it can have functions that apply masks, parses ...</p>","timeToRead":2}},"pageContext":{"locale":"en","title":"Folder structure for front end apps"}},"staticQueryHashes":["1886018365","764694655"]}