When creating an app for the first time, the folder structure of the application will look as follows:

📁  my-app
├── 📄  README.md
├── 📄  composer.json # scandipwa dependencies
├── 📁  i18n # translations file
├── 📁  magento # magento related config
|  ├── 📁  etc
|  |  └── 📄  view.xml
|  ├── 📄  registration.php
|  └── 📄  theme.xml
├── 📁  node_modules # npm dependencies are installed here
├── 📄  package.json # main config file
├── 📁  public 
├── 📁  src # where you can put your code
└── 📄  yarn.lock

<aside> ➡️ The public and src folders are empty. Do not panic! You will use them to create overrides. The application should compile with them being empty!

</aside>

ScandiPWA theme src structure

ScandiPWA theme (aka. your parent theme) has the same root folder structure, but much more files in the src folder. They are structured as follows:

📁  src
├── 📁  component # a place for all components
├── 📁  query # a place for GraphQL queries
├── 📁  route # a place for all root pages
├── 📁  store # a Redux store declarations
├── 📁  style # defines certain global styles
├── 📁  type # a PropType declaroations
├── 📁  util # all utility functions
├── 📄  index.js # application entrypoint
└── 📄  service-worker.js # service worker entrypoint

More information about the structure and contents of these folders:

How to work with components?

How to Work with Redux?

How to work with queries?

The util Directory

Some util directories, such as Address, Cart, Currency, Menu, Price, and Product, facilitate working with certain kinds of data. Others define commonly-needed functionality:

<aside> ➡️ The util directory in ScandiPWA contains various utility functions that don't belong in the other categories

</aside>

eFor example, the util directory of the ScandiPWA parent theme:

util directory Purpose
Auth Responsible for user authentication
BrowserDatabase Convenience methods for accessing the browser's local storage with a simpler API
CSS CSS manipulation. E.g. a utility for setting a CSS variable. This is useful if you want to be able to dynamically edit theme colors from the admin panel.
Extensions Implements a part of the plugin mechanism
FormPortalCollector Works with form data
History Exports a history object using the history library.
Media Utility for working with media URLs
Mobile Functions that help determine the browser device, and whether it is a mobile device.
Polyfill Defines polyfills. Currently includes the smoothscroll polyfill
Promise Implements a cancelable promise
Query Defines tools to work with GraphQL queries
Request Defines tools to work with Requests
Url Tools to work with URLs and parse them.

The style directory

<aside> ✅ While each component may have its own style, some styles are globally defined

</aside>

ScandiPWA defines certain global styles. These are defined in SCSS in the style directory, which contains 3 subdirectories, as well as a file that imports all the styles from them.

CMA (Create Magento App) structure

CMA structure is similar to the default Magento folder structure, but with a package.json file in the root directory. For more details, refer to the official CMA guide.

<aside> ✅ When overriding the theme or creating plugins, you are allowed to override util files to add functionality, or to create your own.

</aside>