# abhay321/lambda-bedrock architecture

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

- Interactive diagram: https://gitdiagram.com/abhay321/lambda-bedrock
- Repository: https://github.com/abhay321/lambda-bedrock

## Overview

1. This repository is a very small AWS serverless application: one Lambda function, deployed with the Serverless Framework, that appears to generate jokes using Amazon Bedrock.

2. The runtime code lives in `handler.js`. That is the application boundary where the Lambda entrypoint is implemented and where any Bedrock API call, prompt construction, and response formatting would happen.

3. `serverless.yaml` is the infrastructure definition. It is the main architectural contract for deployment: function name, runtime, IAM permissions, and any event triggers or resource wiring are defined there rather than in application code.

4. The project is packaged as a Node.js service. `package.json` and `package-lock.json` indicate the Lambda is written in JavaScript and dependency resolution is locked for repeatable deployments.

5. The deployment path is:
   local source code -> Serverless Framework packaging -> AWS Lambda deployment -> AWS execution.
   The README shows the primary workflow is `npm install` followed by `serverless deploy`.

6. The execution path for testing is direct invocation, not a web request. The README uses `serverless invoke local --function generateJokesFunction`, which suggests the function can be run locally without any surrounding web server or API gateway.

7. The likely external service dependency is Amazon Bedrock. Since the repo is named `lambda-bedrock` and the demo output references joke generation, the Lambda probably sends a prompt to a foundation model and returns the model’s text response.

8. The main trust/security boundary is AWS IAM. The Lambda needs permissions to execute and to call Bedrock, and the README explicitly calls out AWS CLI/admin access for deployment.

9. There is no evidence of a database, queue, cache, or frontend in this repo. Architecturally, this is a single-function, stateless compute service with an external AI model dependency.

10. Operationally, the Serverless Framework is the control plane for both local simulation and cloud deployment, while AWS Lambda is the runtime. That makes the repo easy to diagram as one code module, one infrastructure file, and one managed cloud execution target.

11. For an architecture diagram, the key components are:
   - Developer machine / CLI
   - Serverless Framework
   - AWS Lambda function `generateJokesFunction`
   - Amazon Bedrock
   - Optional local invocation path for testing

12. The key data flow is simple: an invoke request reaches the Lambda handler, the handler constructs a prompt/request for Bedrock, Bedrock returns generated text, and the Lambda returns that text as the function response.

Main entry points: [`handler.js`](https://github.com/abhay321/lambda-bedrock/blob/main/handler.js) (Handler), [`package.json`](https://github.com/abhay321/lambda-bedrock/blob/main/package.json) (Node package), [`serverless.yaml`](https://github.com/abhay321/lambda-bedrock/blob/main/serverless.yaml) (Infra spec)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_local["Local machine"]
  node_developer(("Developer<br/>actor"))
  node_serverless["Serverless<br/>cli/tool"]
  node_package["Node package<br/>manifest<br/>[package.json]"]
  node_handler["Handler<br/>lambda code<br/>[handler.js]"]
  node_infra["Infra spec<br/>deploy config<br/>[serverless.yaml]"]
end

subgraph group_aws["AWS"]
  node_lambda["Joke function<br/>aws lambda"]
  node_bedrock(("Bedrock<br/>foundation model"))
end

node_developer -->|"run commands"| node_serverless
node_serverless -->|"install"| node_package
node_serverless -->|"read config"| node_infra
node_serverless -->|"bundle code"| node_handler
node_serverless -->|"deploy"| node_lambda
node_developer -.->|"invoke local"| node_lambda
node_lambda -->|"execute"| node_handler
node_handler -->|"prompt call"| node_bedrock
node_bedrock -->|"generated text"| node_handler
node_handler -->|"response"| node_lambda

click node_package "https://github.com/abhay321/lambda-bedrock/blob/main/package.json"
click node_handler "https://github.com/abhay321/lambda-bedrock/blob/main/handler.js"
click node_infra "https://github.com/abhay321/lambda-bedrock/blob/main/serverless.yaml"

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_developer,node_serverless,node_package,node_handler,node_infra toneBlue
class node_lambda,node_bedrock toneAmber
```

## Components

### Local machine

Source, packaging, and local invocation flow.

- **Developer**: actor · Runs install, deploy, and local invoke commands.
- **Serverless**: cli/tool · Packages and deploys the function, and can invoke it locally.
- [Node package](https://github.com/abhay321/lambda-bedrock/blob/main/package.json): manifest · Declares the Node.js service and locked dependencies. · `package.json`
- [Handler](https://github.com/abhay321/lambda-bedrock/blob/main/handler.js): lambda code · Lambda entrypoint where prompt construction and response formatting happen. · `handler.js`
- [Infra spec](https://github.com/abhay321/lambda-bedrock/blob/main/serverless.yaml): deploy config · Serverless Framework definition for the Lambda, runtime, IAM, and wiring. · `serverless.yaml`

### AWS

Managed cloud runtime and external model service.

- **Joke function**: aws lambda · Deployed Lambda execution environment for generateJokesFunction.
- **Bedrock**: foundation model · External AI model service used to generate joke text.

## Connections

- Developer → Serverless: run commands · Developer uses the Serverless Framework CLI for install, deploy, and local invocation.
- Serverless → Node package: install · npm installs dependencies declared by the package manifest and lockfile.
- Serverless → Infra spec: read config · Serverless Framework reads the infrastructure definition to build the deployment.
- Serverless → Handler: bundle code · The function entrypoint is packaged as the Lambda application code.
- Serverless → Joke function: deploy · The packaged service is deployed to AWS Lambda.
- Developer → Joke function: invoke local · Local invocation simulates the Lambda function without a surrounding web service.
- Joke function → Handler: execute · The Lambda runtime executes the handler entrypoint.
- Handler → Bedrock: prompt call · The handler sends a prompt or request to Amazon Bedrock.
- Bedrock → Handler: generated text · Bedrock returns model output to the handler.
- Handler → Joke function: response · The handler formats and returns the function response.
