React | Application Structure Part I
Published: 2020-12-21 22:39:22

Hello developers! In my last blog, we learn how to run your new React App and how to organize your ideas. We used <code>create-react-app</code> to create our application and all the structure was already done for us. That's amazing and really helpful, but we need to understand the purpose of these files. Today we will discuss two of these folders:<br> 
<i> 1.node_modules </i>
<i> 2.public </i>


After your app is created the structure should look something like this:<br> 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/wqgkqo50an4enuv6v01r.png)<br>

Folder <strong>#1</strong>: <strong>node_modules</strong> This folder is where packages installed by NPM or Yarn will live. In other words, they are just dependencies and sub-dependencies that you have added to your project. 

Folder <strong>#2</strong>: <strong>public</strong> is where your static files live. Your public folder is the root folder that gets distributed by the web server in the end. If you're not sure if a file belongs in this folder think about if the file is not imported by your JavaScript application and must maintain its file name. If the answer is yes, then your file belongs to the public folder. Files in the public directory will always keep the same file name in production. In this folder, we have one of the most important files in your application. This file is:
-  <strong>index.html</strong>. This file is the <strong>ONLY</strong> html page in your project. Your index.html file should look something like this:<br>
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mgba90xe79b4dd22xqn2.png)<br>

As we know JavaScrip allows us to create single-page applications. The index.html file is your single-page. We won't add <strong> ANY </strong> HTML code here. We would do that later in different files. But how that would work you ask yourself! Can you spot this tiny line of code in the file?
<pre><code>id="root"</code></pre>
This line is super important because there is where you will place your React application. I would show you that later, don't you worry! One last thing. You can modify this file by importing libraries such as Bootstrap but that's the only thing you should modify. 

Another file on this directory worth mentioning is: 
-  <strong>manifest.json</strong>.This is a JSON file that tells the browser about your Progressive Web Application and how it should behave when installed on a desktop or mobile device. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hfqmjn2hddcl5miam99s.png)

A typical manifest file includes the app name, icons, and the URL that should be opened when the app is launched. Manifest files are supported in Chrome, Edge, Firefox, UC Browser, Opera, and the Samsung browser. Safari has partial support.

One more thing you could find in this folder is the pictures for your application. Like your <code>create-react-app</code> application is so small the files are just added to this folder because they are minimal. For example, it should look like this: 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/q3y4pmdygtos86chdqhk.png)

As your app continues to grow, you will need a little more organization for your icons or images. A good idea is to create sub-folders by container, in that case, you would know exactly where that image belongs in your application. The structure should look:

<pre><code>
|-public
  |-images
    |-App 
      |-image1.png
</code></pre>

...and that's it for today! In Part II of this series <i>React | Application Structure</i> we would be discussing the <strong>src</strong> folder and a couple of another important files inside your React Application. Thank you for reading and until next week!

Merry Christmas! 🎄