Core Concepts

App schemas

Application schemas encapsulate all pre-authentication and feature distribution information necessary for your codebase to serve your application directly from the client, eliminating the need for an API calls.

The API will handle the login process and provide a unique Session object for post-authentication logic processing.


Creating app schemas

Use the Backstack dashboard to specify all elements of your application, then download the schema for integration into your codebase.

Schemas are compiled using values from various resources, and the dashboard alerts you when any changes impact an existing applications schema.


Codebase implementation

Incorporate the schema values into your codebase using the method of your choice.

// javascript
<script type="text/javascript" src="configs/app-schema.json"></script>

// react
import {app, uri} from '@/configs/app-schema.json'

...

console.log(app.title, uri.login)

The App Schema object

// app schema object
{
  "schema_version": "0.8.1",
  "app": {
    "id": "app_1234567890",
    "title": "Acme Service",
    "pub_key": "pub_key_1234567890",
    "alow_signup": true,
    ...
  },
  "domains": {
    "dom_1234567890": {
      "title": "App",
      "allow_signup": true,
      ...
      "versions": {
        "ver_1234567890": {
          "title": "App",
          ...
        },
        ...
      },
      "network": {
        "dom_2345678901": {
          "monetized": true
        },
        ...
      }
    },
    ...
  },
  "optional_features": {
    "distribution": {
      "ver_1234567890": [
        "account-invoices",
        ...
      ],
      ...
    },
    "list": {
      "account-invoices": {
        "title": "Account Invoices",
        "description": null
      },
      ...
    }
  },
  "access": {
    "ver_1234567890": {
      "account-versions": {
        "rol_1234567890": "crud",
        ...
      },
      ...
    },
    ...
  },
  "roles": {
    "distribution": {
      "ver_1234567890": [
        "rol_1234567890",
        ...
      ],
      ...
    },
    "list": {
      "rol_1234567890": {
        "title": "Super User",
        "description": "The Super User can do anything on the system."
      },
      ...
  }
}
PropertyTypeDescription
schema_versionstringThe version of the compiled schema.
app.idstringThe application ID,
app.titlestringThe application title.
app.descriptionstringThe application description.
app.pub_keystringThe Backstack public API key for the application.
app.allow_signupBooleanWhether there are domains configured for signup. Use this value to determine displaying signup information during login.
domainsArrayThe application domains. Keys are domain IDs and values are domain details.
domains[domain_id].titleStringThe domain title.
domains[domain_id].descriptionStringTe domain description.
domains[domain_id].allow_signupBooleanWhether the domain allows public signup.
domains[domain_id].signup_helpStringThe domain signup help.
domains[domain_id].versionsArrayAn array of versions configured for the domain. Keys are version IDs and values are additional data.
domains[domain_id].versions[version_id].titleStringThe version title.
domains[domain_id].versions[version_id].descriptionStringThe version description.
domains[domain_id].networkArrayAn array of domains configured as child domains. The session.account.domain_id will be able to create networked accounts in these domains.
domains[domain_id].network[domain_id].monetizedBooleanWhether the network allows fees. Use this value for displaying the fee percentage option during account network creation.
optional_features.distribution[version_id]ArrayKeys are version IDs and values are an array of feature IDs available optionally for the version. Use these values coupled with the optional_features.list data to compile an HTML list for managing account subscriptions.
optional_features.list[feature_id].titleStringThe feature title.
optional_features.list[feature_id].descriptionStringThe feature description.
access[version.id]ArrayKeys are the version IDs and values are an array of feature IDs and the assigned RBAC.
access[version.id][feature_id]ArrayKeys are role IDs and values access permissions.
roles.distribution[version_id]ArrayKeys are version IDs and values are an array of role IDs available for the version. Use these values coupled with the roles.list data to compile an HTML list for managing user roles.
roles.list[role.id].titleArrayThe role title.
roles.list[role.id].descriptionArrayThe role description.

Extracting data from the schema

The schema is structured to offer valuable data with minimal file size.

Sign-up domain selection

Provide a select using the following logic. Show a help div and change the form action with the select onChange() event.

// extracting app schema values for creating a signup domain dropdown

let options = []
Object.keys(domains).map((id) => {
    if (domains[id].allow_signup) {
        options.push({
            value: id,
            label: domains[id].title
        })
    }
})

// select.onChange event
console.log({
  "domainDesc": domains[select.value].description;
  "domainHelp": domains[select.value].help;
});

User role assignment

The following logic will provide for a group of checkboxes when assigning roles.

// extracting app schema values for creating role checkboxes

Object.keys(roles.distribution[session.account.version_id]).map((id) => {
  console.log({
    "name": "roles",
    "value": id,
    "selected": session.user.roles.includes(id),
    "text": roles.distribution[session.account.version_id][id].title + ': ' + roles.distribution[session.account.version_id][id].description
  });
}

Version subscription

Provide radios to allow accounts to change versions. Indicate the current selection.

// extracting app schema values for account versioning options

Object.keys(domains[session.account.domain_id].versions).map((id) => {
  console.log({
    "active": session.account.version_id === id,
    "title": domains[session.account.domain_id].versions[id].title,
    "description": domains[session.account.domain_id].versions[id].description
  });
});

Optional feature subscription

If the accounts version has optional features available, you'll want to offer methods for activating/deactivating them on your page.

// extracting app schema vaues  for creating an optional features list

optional_features.distribution[session.account.version_id].map((id) => {
  console.log({
    "id": id,
    "title": optional_features.list[id].title,
    "description": optional_features.list[id].description,
    "active": session.account.optional_features.contains(id)
  });
});
Previous
Support