# barchart/aws-lambda-suppressor architecture

> Architecture diagram of the GitHub repository barchart/aws-lambda-suppressor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/barchart/aws-lambda-suppressor
- Repository: https://github.com/barchart/aws-lambda-suppressor

## Overview

This repository is a small Node.js library whose core purpose is to prevent duplicate AWS Lambda event processing. It is not a full application; it is a reusable package that plugs into a larger Lambda framework, especially `@barchart/common-node-js`.

1. **Primary runtime boundary**
   - The package runs inside AWS Lambda execution environments.
   - It receives Lambda `event` objects, derives a stable event identity, and uses DynamoDB as the deduplication store.
   - The architectural boundary is between stateless Lambda handlers and a shared persistence layer used to coordinate suppression across invocations.

2. **Main domain concept: event suppression**
   - The library treats an incoming event as “new” or “already processed.”
   - If the event identity can be inserted into the store, processing is allowed.
   - If the insert fails due to a conditional write conflict, the event is assumed to be a duplicate and should be suppressed.

3. **Validator layer**
   - `lib/dynamo/DynamoMessageValidator.js` is the core implementation that performs the deduplication check against DynamoDB.
   - `lib/dynamo/DynamoLambdaValidator.js` appears to specialize or adapt validation for Lambda-specific usage.
   - These classes are the main integration point for application code, and they fit into a broader validation chain provided by `@barchart/common-node-js`.

4. **Persistence layer**
   - `lib/dynamo/tables/LambdaInvocationsTable.js` encapsulates the DynamoDB table interaction details.
   - The table is the durable registry of previously seen invocation identifiers.
   - This separation keeps the validation logic distinct from the low-level storage schema and write mechanics.

5. **Data flow through the system**
   - Lambda event arrives.
   - A validator extracts or computes a unique identifier from the event.
   - The identifier is written to DynamoDB using a conditional operation.
   - Success means the invocation is first-seen; failure means a duplicate invocation and the handler should short-circuit.

6. **Integration model**
   - The README describes the package as being used by instantiating a `LambdaEventValidator`, adding a `DynamoMessageValidator`, and plugging that validator into a `LambdaHelper`.
   - That means this repository does not own the full Lambda handler lifecycle; it provides a focused validator component that another framework invokes.

7. **Operational support scripts**
   - `scripts/updates/environment-create.js` suggests setup automation for provisioning or preparing the runtime environment.
   - `scripts/updates/set-expiration.js` indicates lifecycle management around record expiry, likely to avoid unbounded growth in the deduplication table.
   - These scripts are operational tooling around the core library rather than part of the runtime path.

8. **Infrastructure assumptions**
   - DynamoDB is the only explicit external stateful dependency.
   - The design relies on conditional writes, which is the key concurrency control mechanism for cross-invocation deduplication.
   - Expiration/TTL handling is likely important because the deduplication key space is temporal, not permanent.

9. **Build and release tooling**
   - `gulpfile.js` implies a build/release workflow managed through Gulp.
   - `buildspec.yml` shows the project is built in AWS CodeBuild.
   - The `.releases` directory indicates a changelog/release-note driven release process, which matters for package distribution but not runtime behavior.

10. **Package shape**
   - `package.json`, `.npmrc`, and `.npmignore` confirm this is published as an npm package.
   - The library is intended to be consumed by other Node.js projects rather than deployed standalone.
   - The MIT license and public npm badge reinforce that it is a reusable infrastructure component.

11. **Suggested architecture diagram focus**
   - Show a Lambda function invoking a validator layer.
   - Show the validator writing to a DynamoDB “invocations” table with conditional put semantics.
   - Show the duplicate-suppression decision returning to the Lambda handler.
   - Optionally show setup/maintenance scripts as an offline operational lane for environment creation and record expiration.

12. **What is intentionally missing**
   - There is no UI, API server, queue consumer framework, or multi-service backend here.
   - The repository’s responsibility is narrow: deduplicate Lambda invocations through a DynamoDB-backed validator abstraction.

Main entry points: [`lib/dynamo/DynamoMessageValidator.js`](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoMessageValidator.js) (Message validator), [`lib/dynamo/tables/LambdaInvocationsTable.js`](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/tables/LambdaInvocationsTable.js) (Invocations table), [`scripts/updates/environment-create.js`](https://github.com/barchart/aws-lambda-suppressor/blob/master/scripts/updates/environment-create.js) (Ops scripts), [`lib/dynamo/DynamoLambdaValidator.js`](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoLambdaValidator.js) (Lambda validator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Lambda validation"]
  node_lambda_handler(("Lambda handler<br/>runtime boundary"))
  node_event_validator["Event validator<br/>integration API"]
  node_dynamo_lambda_validator["Lambda validator<br/>lambda adapter"]
  node_dynamo_message_validator["Message validator<br/>dedupe validator"]
  node_framework["Common Node JS<br/>external framework"]
end

subgraph group_storage["Persistence"]
  node_invocations_table[("Invocations table<br/>dynamo table")]
  node_dynamodb[("DynamoDB<br/>external store")]
end

subgraph group_ops["Operations"]
  node_ops_scripts["Ops scripts<br/>maintenance tooling"]
  node_releases["Release notes<br/>release process<br/>[.releases]"]
end

node_lambda_handler -->|"invokes"| node_event_validator
node_event_validator -->|"includes"| node_dynamo_lambda_validator
node_dynamo_lambda_validator -->|"adapts"| node_dynamo_message_validator
node_dynamo_message_validator -->|"checks"| node_invocations_table
node_invocations_table -->|"writes"| node_dynamodb
node_dynamo_message_validator -.->|"suppresses"| node_lambda_handler
node_dynamo_message_validator -.->|"integrates with"| node_framework
node_ops_scripts -.->|"maintains"| node_invocations_table
node_ops_scripts -.->|"provisions"| node_dynamodb
node_releases -.->|"packages"| node_framework

click node_dynamo_lambda_validator "https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoLambdaValidator.js"
click node_dynamo_message_validator "https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoMessageValidator.js"
click node_invocations_table "https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/tables/LambdaInvocationsTable.js"
click node_ops_scripts "https://github.com/barchart/aws-lambda-suppressor/blob/master/scripts/updates/environment-create.js"
click node_releases "https://github.com/barchart/aws-lambda-suppressor/blob/master/.releases"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_lambda_handler,node_event_validator,node_dynamo_lambda_validator,node_dynamo_message_validator,node_framework toneBlue
class node_invocations_table,node_dynamodb toneAmber
class node_ops_scripts,node_releases toneMint
```

## Components

### Lambda validation

In-process deduplication and validator integration used by Lambda handlers

- **Lambda handler**: runtime boundary · Incoming AWS Lambda invocation that delegates duplicate checking to the library
- **Event validator**: integration API · Host-side validator chain that plugs the suppressor into a larger Lambda framework
- [Lambda validator](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoLambdaValidator.js): lambda adapter · Lambda-specific adapter that participates in the validation flow · `lib/dynamo/DynamoLambdaValidator.js`
- [Message validator](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/DynamoMessageValidator.js): dedupe validator · Core validator that computes identity and checks DynamoDB for duplicates · `lib/dynamo/DynamoMessageValidator.js`
- **Common Node JS**: external framework · Host framework referenced by the package for validator and handler integration

### Persistence

DynamoDB-backed registry of seen invocation identities

- [Invocations table](https://github.com/barchart/aws-lambda-suppressor/blob/master/lib/dynamo/tables/LambdaInvocationsTable.js): dynamo table · Encapsulates the DynamoDB write path and table semantics for seen invocations · `lib/dynamo/tables/LambdaInvocationsTable.js`
- **DynamoDB**: external store · Conditional write store used to coordinate suppression across invocations

### Operations

Offline setup, expiration, and release tooling

- [Ops scripts](https://github.com/barchart/aws-lambda-suppressor/blob/master/scripts/updates/environment-create.js): maintenance tooling · Environment creation and TTL/expiration maintenance utilities · `scripts/updates/environment-create.js`
- [Release notes](https://github.com/barchart/aws-lambda-suppressor/blob/master/.releases): release process · Changelog-driven package release artifacts and publishing history · `.releases`

## Connections

- Lambda handler → Event validator: invokes · Handler delegates event processing to the validator chain
- Event validator → Lambda validator: includes · The framework wires in the Lambda-specific validator
- Lambda validator → Message validator: adapts · Lambda-specific validation is handled by the core message validator
- Message validator → Invocations table: checks · Core validation consults the invocations table for first-seen detection
- Invocations table → DynamoDB: writes · Table abstraction performs conditional persistence in DynamoDB
- Message validator → Lambda handler: suppresses · Duplicate detection returns a decision back to the handler
- Message validator → Common Node JS: integrates with · Validator is designed to plug into the broader Node.js Lambda framework
- Ops scripts → Invocations table: maintains · Operational scripts support setup and expiration management for stored records
- Ops scripts → DynamoDB: provisions · Environment creation and retention tasks act on the backing store
- Release notes → Common Node JS: packages · Release artifacts document and ship the library as a reusable npm package
