Backend

Shared Libraries

Deep dive into the shared libraries in lib/ that every backend service imports: the database module, response helpers, email senders, search, and notifications.


Database Layer (lib/db.js)

The DB module wraps DynamoDB operations and automatically appends the environment suffix to table names:

MethodDynamoDB OperationDescription
create(item, table)PutItem (conditional)Creates a new item, fails if already exists
getOne(id, table, sortKey?)GetItemGet a single item by primary key
scan(table, filterExpression?)ScanFull table scan with optional filter
updateDB(id, params, table, sortKey?)UpdateItemUpdate specific fields on an item
deleteOne(key, table)DeleteItemDelete a single item
batchGet(keys, table)BatchGetItemFetch multiple items at once
batchWrite(items, table)BatchWriteItemWrite multiple items at once
put(item, table)PutItem (unconditional)Overwrite an item
query(params)QueryRun a query with a key condition

Environment Suffix

Every table name gets the ENVIRONMENT variable appended. In dev, biztechEvents stays biztechEvents. In production, it becomes biztechEventsPROD. This happens inside db.js, so you never need to add the suffix manually.

The updateDB method is smart about DynamoDB reserved words. It automatically aliases attribute names that conflict with reserved words (like name, status, year) using # prefix notation.


Handler Helpers (lib/handlerHelpers.js)

Standard response builders that every handler uses:

HelperStatusWhen to Use
createResponse(code, body)AnyStandard response with CORS headers
inputError(message)400Missing required fields
missingIdQueryResponse()400Missing ID or query parameters
missingPathParamResponse(param)400Missing URL path parameter
notFoundResponse(entity)404Item not found in database
duplicateResponse(entity)409Item already exists
notAcceptableResponse(reason)406Validation failure
checkPayloadProps(body, schema)-Validates required fields and types

All responses include CORS headers (Access-Control-Allow-Origin: *).


Email Helpers

Two email systems:

ModuleServiceUsed For
sesHelper.jsAWS SES v1Simple emails, bulk emails
sesV2Client.jsAWS SES v2Template management (CRUD)
SendGrid (in registrations)SendGridQR code emails, calendar invites

Wraps Algolia for profile search:

import { searchClient } from "./algoliaClient.js";
const index = searchClient.initIndex("blueprint-prod");
const results = await index.search(query);

SNS Notifications (lib/snsHelper.js)

Sends messages to SNS topics, primarily used to notify Slack when new registrations come in.

Previous
Architecture Overview