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

adminService

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

assetService

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

authService

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

backupRestoreService

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

backupService

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.

breadcrumbsService

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

cacheService

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

contentService

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.

cryptoService

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

cssService

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

dalService

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.

dataService

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.

emailService

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.

emitterService

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.

fileService

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

formService

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.

formattingervice

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

globalService

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

helperService

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

installService

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.

mediaService

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.

menuService

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.

migrationService

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.

moduleService

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.

pageBuilderService

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

s3Service

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

sharedService

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

siteSettingsService

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

testService

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

themeService

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.

urlService

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

userService

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

urlService

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