API Backend

If you are doing any module development, you'll want to become familiar with the backend API. Everything that the core of SonicJs uses is exposed in the API. The Backend API is organized into a collection of services. Although there are roughly 2 dozen services, you will typically only need to be familiar with a few of them for most module development scenarios. 

Let's start by reviewing a list of each service and what it does.

Service List


Admin Service - The admin service is responsible for rendering the admin UI page.


Asset Service - The asset service is responsible for processing the css and js files used by the site. It is responsible for minimizing assets for production. The assets that are loaded for the site are combined from various sources: 1) your themes assets.yml file. 2) Assets from the enabled modules 3) CSS for sections managed in the page builder


Auth Service - The auth service is responsible for registering and logging in users


Backup-Restore Service - The backup-restore service is responsible for restoring data from SonicJs' json based data backup system


Backup Service - The backup service is responsible for backing up all database data into json files (one for each db record) and then zipping them up.


Breadcrumb Service - The breadcrumb service is responsible for generating site breadcrumbs


Cache Service - The cache service uses NodeCache. It allows data and content, such as rendered pages to be cached, thus dramatically improving performance.


Content Service - The content service is respoinsible for the actual rendering of pages. This is the service that processes secions, rows, column and triggers the modeuls in each column to be rendered.


Crypto Service - The crypto service exposes the encrypt and decrypt methods, primarily for safely storing user password


CSS Service - The css service processes the template file and support front end css updates from the page builder. It also manages merging in section styles into the main template.css file


DAL Service - The DAL service is the data access layer of SonicJs. You will typically use the dataServie as it take the user session and the user's role into account. However, there are a few instances where you may need to access the DAL directly such as scheduled jobs. Alsway attempt to use the dataSerivce first and use the dalService only as a last resort.


Data Service - The data service is the primary service used for access SonicJs' persistence layer. It generates the graphql queries that are executes on SonicJs' api layer. It passes along any necessary session data along with the data related paramwters.


Email Service - The email service is responsible for sending transactional emails. It currently uses sendgrid but can easily be expanded to include other email providers.


Emitter Service - The emitter service is the foundation of SonicJs' hook system. It uses the event-emitter design pattern to manage the hooks that can be utilized in other services and modules.


File Service - The service is responsible for filesystem IO operations.


Form Service - The form service is responsible for generating the data entry forms that are used both on the front end and back end aministratice sections. SonicJs uses form.io, an open source form generator.


Formatting Service - The formatting serivce is responsible for simple formatting needs of the system. IE date formats, title formating, etc


Global Service - The global service is responsible for managing global variables used throughout SonicJs.


Helper Service - The heloper service is a set of utiliites used throught SonicJs. IE: slugify, validateEmail, generateRandomString, etc


Install Service - The install service is run when SonicJs first starts up. It is responsible for making sure the your database contains certain must-have records. It also contain so migration examples.


Media Service - The media service is respoinsible managing site assets such as images and videos. It can manage assets on the file system or Amazon S3.


Menu Service - The menu service is respoinsible for managing site menus. It processes menu hierachys, for example it can determine if the 1st level menu item should be set to active if a child item is presently being viewed by the user.


Migration Service - The migration service is respoinsible for managing data migrations. SonicJs rarely needs to run site migration from one version to another due to its simple data model.


Module Service - The module service is resposible for managing the SonicJs' module system. It is one of the more complex services in SonicJs. It process the modules at system startup and provides all necessary function of each module throught it's life cycle.


Page Builder Service - The page builider service is resposible for all back end aspects of the front end page builder.


S3 Service - The S3 service is used to manage asset's on Amazon's S3 service.


Shared Service - The shared service is resposible for a few helper sytle functions.


Site Settings Service - The site settings service adds the site settings data object to each request for use in downstream processes.


Test Service - The test service is contains utilities that accomadate Cypress end to end testing


Theme Service - The theme service is adds runtime data for use in theme rendering. IE it provides the current year for use in the site footer.


Url Service - The url service manage the in-memory url table used for mapping routes to services


User Service - The user service manages site users, including role checking


View Service - The view service processes views. This service provides integration with the Handlebars view engine.