# Main development concepts ## The commercetools Frontend approach commercetools Frontend allows developers and business users (for example, marketing managers) to collaborate on creating, maintaining, and optimizing the frontend for their commerce website. In commercetools Frontend, business users are responsible for creating and managing website pages and content. To do this, they use the [Studio](/frontend-studio/overview.md), which is the commercetools Frontend management interface. On the other hand, developers are responsible for developing what business users need to create and manage the website pages and content. Developers are also responsible for optimizing the performance of the commercetools Frontend project. This approach requires that business users and developers agree on a clear configuration for their commercetools Frontend project early in the development process. This way, developers can optimize the development based on use cases, and business users can autonomously create and manage the website pages and content. Within commercetools Frontend, all page changes are independent from code deployments, including changes to the data displayed as well as to the structure of the page. Furthermore, commercetools Frontend allows developers to choose the frontend development pattern, style, and approach they prefer. For further information, see the [development constraints](/frontend-development/development-concepts.md#development-constraints). ## Build a website page Components, Data Sources, and Actions are the required elements to build a website page with commercetools Frontend. Developers create them and business users use them in the Studio to build the website pages. ### Components Components are configurable and reusable elements used to build [the structure of website pages](/frontend-development/how-to-slice-a-commerce-site-into-components), they are similar to [presentational components](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0) or [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components). commercetools Frontend Components are React components that receive and display data as configured by business users in the Studio. Each Component consists of the two following files, which developers write and maintain in their commercetools Frontend project GitHub repository: - JavaScript source code file. This is the entry point, it is a React component that receives some special props. - JSON configuration file. It defines the Component configuration options that are available in the Studio. In particular, it determines which aspects of the Component can be configured and how, and which Data Sources are connected to the Component. An example of a Component is a product slider, for which it is possible to configure the title, the number of products displayed, and the Data Source from which product data is read. A commercetools Frontend Component can be made up of multiple small React components, depending on developer preferences and on the size of the Component. To [develop Components](/frontend-development/creating-a-frontend-component) you can follow any frontend development pattern (for example, styled components, CSS, and presentational components). Components are called `tastics` in the code base. ### Data Sources Data Sources return data that is then displayed on the website pages through Components. Data Sources are decoupled from Components, therefore no deployment is needed to manage the data displayed on a page and business users can autonomously do it. Data Sources are JavaScript/TypeScript functions that: 1. Fetch data from external APIs (for example, a headless commerce system). 2. Simplify the fetched data to what is required by commercetools Frontend. 3. Return data in a structure that Components can use. Data Sources receive the user session, user configuration, and project configuration and then return data. Data Sources can optionally use the user context (user groups, flags, locale, etc.) and the context in which they are used (page, URL, locale, etc.). Therefore, there is great potential in optimizing the retrievable data for specific use cases. Each Data Source has a configuration schema that defines what can be configured for the Data Source from the Studio. An example of Data Source is a product list fetched from a headless commerce system, for which it is possible to configure search queries, categories, or price ranges. #### Components and Data Sources decoupling The decoupling of Components from Data Sources is meant to make business users independent in managing the website pages so that developers are not involved in daily frontend changes. This way, developers can focus on improving Components and Data Sources. The trade-off of this decoupling is that pages cannot be optimized by hand, since business users can edit any page without interacting with the development team. ### Actions Websites don’t only display data, they also perform actions. commercetools Frontend Actions perform actions on external APIs (for example, a headless commerce system) and return a response if needed. Actions are JavaScript/TypeScript functions that retrieve data from the frontend and have access to the user context and project configuration. An example of Action is adding a product to the cart. ### How Components, Data Sources, and Actions work The entry Component is often a basic Component retrieving data and calling other Components which implement the visuals, as in the following example of a product slider. For further information on the product slider code, see the [code on GitHub](https://github.com/FrontasticGmbH/scaffold-b2c/blob/main/frontend/components/commercetools-ui/organisms/product/product-slider/index.tsx). You can implement a product slider following atomic design principles as we did, or you can follow different implementation patterns. ```js title="Product slider sample code" import { Product } from '@commercetools/frontend-domain-types/product/Product'; import ProductSlider, { ProductSliderProps, } from 'components/commercetools-ui/organisms/product/product-slider'; import { Tastic } from 'types/tastic'; function ProductSliderTastic({ data, }: Tastic<{ items: Product[] }, ProductSliderProps>) { if (!data?.data?.dataSource?.items) return
No products found.
; return