Last edit:  Apr 19, 2019

Contributors:  Slashek pavelloz diana-lakatos

You develop your site (write code) in your codebase in your local environment.

Required directory structure

In order to correctly communicate with the platformOS engine and API, your codebase should be organized into a specific directory structure. The root directory of your project should contain the marketplace_builder directory.

Recommended directories and files inside the marketplace_builder and modules/<module name> directories

Directory/file File type Explanation Learn more
.marketplace-kit Configuration file that specifies available endpoints. Usually, you want to have at least two endpoints – staging and production. Development Workflow
assets asset Directory for static assets, like fonts, images, stylesheets, and scripts. Assets
authorization_policies Liquid Directory for .liquid files that contains Authorization Policy configuration files. Authorization Policies define rules that control whether a user has access to a form or page. Authorization Policies
custom_model_types YAML Directory for .yml files that define Custom Model Types. Custom Model Types define custom objects, including their fields and associations and allow you to create persistence containers for your custom forms. Models
form_configurations Liquid Directory for .liquid files that define Form Configurations. Form Configurations define forms including their fields, validation, redirects, and callbacks. Each of the Liquid files should include configuration (including associated Authorization Policies, Notifications, etc.), along with Liquid code which renders HTML. Forms
graph_queries GraphQL Directory for .graphql files, each defining one GraphQL Query. GraphQL queries retrieve information from or insert information into the databases. Retrieved information is made available in Liquid. GraphQL
notifications Liquid Directory for files that define Notifications, which then can be associated with Form Configuration. Notifications
views/pages Liquid Directory for files that define pages, the most essential building blocks of a platformOS site. Views
views/layouts Liquid Directory for layouts. Layouts are wrappers around your page content. They ensure consistent outer content for similarly designed pages. Views
views/partials Liquid Directory for partials – reusable snippets of Liquid code usually used to render HTML. Views
translations YAML Directory for .yml files of Translations for multilingual sites, also used to define date format, or flash messages. Each file is a map of translations which can be used in your pages via Liquid. Translations
user_profile_types YAML Directory for .yml files that define User Profiles. Each instance includes one user role, called ‘default’, so each instance needs to include the default.yml file inside this directory. Users
user.yml YAML A yml file containing properties for all users Users

Files in your codebase

Views: pages, layouts, and partials

Views are divided into three categories in your codebase, each with a mandatory subdirectory: layouts, pages, and partials.

Pages are the most essential building blocks of a platformOS site, that define content displayed at a given path. Each page is represented by a single file with a .liquid extension.

platformOS allows Liquid pages to be used to create many different types of endpoints beyond HTML, such as JavaScript, JSON, PDF, RSS, XML, etc. The page type can be specified in the page configuration.

Layouts are Liquid views that store code that would normally repeat on a lot of pages and is surrounding page content (e.g. header, footer). Without layouts, pages would share a lot of duplicated code, and changing anything would become a very time consuming and error prone process. You can create as many layouts as you need, and decide which page uses which layout.

Partials (partial templates) allow you to easily organize and reuse your code by extracting pieces of code to their own files. They help you improve code readability and follow the principle of DRY (Don’t Repeat Yourself). You can parameterize partials and use them in various places, e.g. layouts, pages, Authorization Policies, Form Configurations.

Example directory structure of views with sample files:

└── views
    ├── layouts
    │   ├── 1col.html.liquid
    └── pages
    │   ├── home.html.liquid
    │   ├── unauthorized.html.liquid
    └── partials
        ├── layout
            ├── constants.liquid
            ├── foot.liquid
            ├── footer.liquid
            ├── head.liquid
            ├── header.liquid


Assets are files that can be served by an HTTP web server without any backend/server processing. They are usually Javascript files, stylesheets (CSS), documents (HTML, pdf, doc), fonts, or media (audio, video) files.

Although only the assets directory is required and you can put your assets there, we recommend you further organize your assets into subdirectories inside the assets directory, e.g. images, scripts for Javascript files, styles for CSS files, etc. This is also how the marketplace-kit init command will create the codebase.

Example directory structure of assets with sample files:

└── assets
    ├── fonts
    └── images
    │   ├── favicon.ico
    └── scripts
    │   ├── app.js
    │   ├── vendor.js
    └── styles
        ├── app.css
        ├── vendor.css


Just like in every web application, HTML forms are essential in platformOS. Because using plain HTML forms can get difficult to maintain with complex data structures, we provide multiple tools that make working with forms much easier.

Form Configurations are the main tool for rendering forms, persisting data, and sending notifications (email/SMS/API) in a secure and customizable way.

They give you full control when defining:

  • which fields for a defined resource can be persisted
  • what authorization rules apply to be able to submit the form (i.e. if you want to edit a comment, you might want to specify that only the creator or the administrator is able to do it)
  • what should happen when the form is submitted successfully (i.e. without validation errors), e.g. send an email/SMS Notifications or API call to a third party system
  • where the user should be redirected

On top of that, you can define callbacks (either synchronous or asynchronous) for further modifications to the system using GraphQL mutations. For example, you can define a signup form that creates User records, and if the user input is valid, also creates a few sample products for them, so that they don’t have to start from scratch.

Example directory structure of form_configurations with sample files:

└── form_configurations
    ├── create_contact_request_form.liquid
    ├── feedback_form.liquid


Users are accounts that any of your users can have. Users are identified by their unique email addresses. You can define properties for all users in the user.yml file.

User Profiles are roles in the application. Each User Profile can be associated with any number of Properties and Custom Model Types. All users are assigned a User Profile named Default. The difference between User Profile and Custom Model Type is that each user can have maximum one profile of a given name (but can have many different profiles), whereas they can have many custom models with the same name. From a practical perspective, it is very simple to create an upsert operation on a UserProfile (i.e. create user profile, or if it exists, update it).

Example directory structure of user_profile_types with sample files:

└── user.yml
└── user_profile_types
    ├── developer.yml
    ├── client.yml


Custom Model Type is an object that describes all Customization objects that belong to it. Think of Custom Model Types as a custom database table, which allows you to build highly customized features. Use them to group Properties, and allow the user to provide multiple values for each of them.

Properties are fields that you attach to a User Profile, Custom Model Type, etc. Think of them as custom database columns (though complex types, like files, photos, and addresses should be treated as separate database tables). We also provide some Properties to jumpstart your development.

Example directory structure of custom_model_types with sample files:

└── custom_model_types
    ├── blog_post.yml


Notifications are messages sent to platformOS users (including admins) when something happens. A message can be an email, SMS, or programmatic call to a 3rd party API.

Notifications can be delayed, and you can use Liquid, GraphQL, and trigger conditions to decide if a notification should be sent. They are a powerful mechanism used for example to welcome new users, follow up after they've added their first item, or reach out to them if they have been inactive for a while.

Example directory structure of notifications with sample files:

└── notifications
    ├── api_call_notifications
    │   ├── ping_example_com_on_user_sign_up.liquid
    └── email_notifications
    │   ├── welcome_user.liquid
    └── sms_notifications
        ├── welcome_user.liquid

Authorization Policies

Authorization Policies allow you to restrict access to forms and pages in a flexible way. Each form or page can have multiple policies attached to it.

Each policy is parsed using Liquid, and the system checks them in order of their appearance in the code. Depending on policy configuration, it redirects the user to a URL provided by the developer if the condition is not met or renders error status, for example 403. You can also add a flash message for the user who failed authorization.

Example directory structure of authorization_policies with sample files:

└── authorization_policies
    ├── example_policy.liquid


You can use platformOS to build sites in any language, and each site can have multiple language versions. Translations are yml files used for multilingual sites but also used to define date formats, flash messages or system-wide default error messages like "can't be blank".

Example directory structure of translations with sample files:

└── translations
    ├── en.yml
    ├── pl.yml


Modules allow code reuse and sharing, while protecting the IP of creators.

Module code is split into 2 directories to protect IP. To create a module, split module code into public and private folders, and place all that code into the modules/MODULE_NAME directory.

These directories have the same structure as the standard marketplace_builder folder, but if developers try to download files after the module has been deployed to an Instance (marketplace-kit pull), they will only see the files from the public folder.

Example directory structure of modules with sample files:

├── modules
		├── private
		│   └── graph_queries
		│       ├── get_customizations.graphql
		│       └── get_pages.graphql
		└── public
		    └── views
		        └── pages
		            └── admin.liquid


We are always happy to help with any questions you may have. Check out our Help page, or contact us.