Repository structure

From Izara Wiki
Jump to navigation Jump to search

Overview

Standard file and folder for each backend microservice.

Root directory

app

The app folder holds all logic for the service, the files inside this folder are a single serverless/node project.

config

The config folder has files that are shared by both app and resource projects, most per-deploy settings are saved here.

resource

The resource folder is a stand alone serverless/node project that deploys resources that should not change often, deploying as a separate stack gives some protection against damaging resources such as databases when making regular changes to logic.

files

.gitignore

Global .gitignore for entire git project

COPYING

Standard license information

README.md

Landing page when viewing the project on repository host

app project

initial_setup

Offers a method to setup an initial instance of the service.

config.js

Configurable details that will be implemented during initial setup

initialSetup.js

Logic that performs the initial setup, is deployed as a Lambda function and expected to be run once after deployment, after invoked it can be removed or disabled on AWS

src

Per service logic, can be split into subfolders per object or work flow, up to developers

Lambda function filenames

Most Lambda functions have a main function file and one or more handler functions, different handler functions handle different sources and adjust the received request so it enters the main function file with the correct params, and also handle batch processing if the source requires it.

Lambda functions that are part of the same closely tied workflow should have the same filename prefix so they group together.

The main function adds prefix "_Main", handler functions add prefix "_Hdr..." replacing the dots with the handlers source, "Sqs" for SNS>SQS triggers, "Dsq" for direct SQS triggers, "Api" for API Gateway, "Inv" for Lambda direct invoke.

Example filenames for a workflow that has 4 functions that connect with Graph Handler invocations:

  • ThisFunction_Main
  • ThisFunction_HdrSqs
  • ThisFunctionNodeCreated_Main
  • ThisFunctionNodeCreated_HdrSqs
  • ThisFunctionXxNodeUpdated_Main
  • ThisFunctionXxNodeUpdated_HdrSqs
  • ThisFunctionYyNodeUpdated_Main
  • ThisFunctionYyNodeUpdated_HdrSqs


lib

The lib folder stores functions that are used by multiple Lambda functions

schemas

schemas/objectList.js

  • file that lists all object types controlled by this service

schemas/objectRelationships.js

  • file that lists all parent objects and relationship types for objects controlled by the server

schemas/objectFields

  • sub-folder with one file per object type
  • fields for data that is set by a user and stored in state such as a database

schemas/objectCalculatedData

  • sub-folder with one file per object type
  • fields for data that is calculated, may or may not be stored in state

__test__

Holds code that executes local unit tests

resource project

...