Finch: Shipping an Embeddable AI Shopping Agent on Serverless AWS That Scales to Zero
How we built Finch, a platform that adds an AI agent to any store with one script tag, on Lambda, API Gateway, DynamoDB, S3, and Amplify. Includes the design decisions that kept idle cost at zero: using DynamoDB as a vector store, separating discovery from truth, and one env var to go from laptop to cloud.
The problem
Walk into a good physical store and a salesperson greets you: "What are you after? For winter? What is your budget?" Thirty seconds later you are holding the right thing. That person is why physical stores convert.
Go online and there is no one. Just a search box that wants exact keywords. Type "something warm and cozy for winter under 150" and you often get zero results, because keyword search cannot weigh a need. So the shopper leaves.
The obvious fix, an AI agent that knows the store, is out of reach for most small and medium businesses. Building, testing, deploying, and managing an agent takes engineers, a four figure budget, and weeks of work. So they ship nothing.
We built Finch to remove that wall. A store turns on a ready made agent, connects its data, and pastes one script tag. No developer, no big bill, no weeks.
What Finch does
Finch ships two prebuilt agents that share one pipeline:
- A Shopping agent that understands vague needs, recommends real products from the store's own catalog with live prices, and adds to cart.
- A Support agent that answers customer questions from the store's own PDFs and policies, and cites the document each answer comes from.
Both are grounded in the business's real data, so they never invent a product, a price, or a policy.
Architecture, fully serverless on AWS
The whole stack scales to zero, so it costs about zero when idle:
S3 (widgets + landing) static, one script tag
|
API Gateway (HTTP API) -> AWS Lambda (Python 3.13)
|-> Amazon DynamoDB tenants, products, doc chunks, carts (+ vectors)
|-> Amazon S3 raw per tenant catalog
|-> LLM provider tool use + grounded answers
Onboarding dashboard: React + Vite on AWS Amplify Hosting
AWS services used: Lambda, API Gateway (HTTP API), DynamoDB, S3, Amplify Hosting, CloudFormation via AWS SAM, and IAM. We also wired Amazon Bedrock (Titan) as a pluggable embeddings provider.
Below are the three decisions that made this cheap and reliable.
Decision 1: DynamoDB as the vector store, no always on search
A managed vector search service has a minimum always on cost. For a hackathon and for small catalogs, that is the wrong trade. Instead we store each product's embedding on the item in DynamoDB and rank with a brute force cosine similarity inside the Lambda that is already warm:
def cosine(a, b):
dot = sum(x * y for x, y in zip(a, b))
na = math.sqrt(sum(x * x for x in a))
nb = math.sqrt(sum(y * y for y in b))
return dot / (na * nb) if na and nb else 0.0
def top_k(query_vec, products, k=5, filters=None):
scored = [
{**p, "_score": cosine(query_vec, p["embedding"])}
for p in products if passes(p, filters) and p.get("embedding")
]
scored.sort(key=lambda p: p["_score"], reverse=True)
return scored[:k]Result: no idle charge, and the swap to a dedicated vector store later is a one file change.
Decision 2: separate discovery from truth
Letting an LLM read a price from a fuzzy vector match is how chatbots hallucinate. So we split the two. Vector search only finds candidates. The exact price and live stock come from the structured DynamoDB record through a separate tool. The model only ever sees tool results, never the raw catalog, so it physically cannot quote a fake price.
The Shopping agent is an LLM tool use loop with five typed tools, each bound to one tenant and session:
tools = { "search_products": lambda query, max_price=None: service.search_products(...), "check_stock": lambda product_id: service.check_stock(...), # source of truth "add_to_cart": lambda product_id, qty=1: service.add_to_cart(...), # get_product, get_cart}Decision 3: one env var from laptop to cloud
Every expensive or account gated dependency sits behind one environment variable, so the same code runs offline and on Lambda. The storage layer is a facade:
if config.BACKEND == "aws": from src.lib import dynamo as _belse: from src.lib import local_store as _b # JSON files, zero AWSput_products = _b.put_productslist_products = _b.list_products# ...FINCH_BACKEND switches JSON files to DynamoDB. FINCH_EMBED switches a local hashed vector to Bedrock Titan. This is what let us build and test the entire pipeline while AWS credits and Bedrock verification were still pending.Infrastructure as code with AWS SAM
One template.yaml defines the whole stack: 7 Lambdas, 4 DynamoDB tables (on demand, a Global Secondary Index to resolve a widget key to a tenant, and TTL on carts), an S3 bucket, and least privilege IAM roles.
ChatFn: Type: AWS::Serverless::Function Properties: Handler: src.handlers.chat.handler Runtime: python3.13 Policies: - DynamoDBReadPolicy: { TableName: !Ref ProductsTable } - DynamoDBCrudPolicy: { TableName: !Ref CartsTable } Events: Chat: { Type: HttpApi, Properties: { Path: /chat, Method: POST } }Deploy is one command:
sam build && sam deploy --stack-name finch --region ap-south-1 \ --resolve-s3 --capabilities CAPABILITY_IAMThe one line a store pastes
The widget is vanilla JavaScript in a Shadow DOM, isolated from the host site's CSS. It finds the store's own search bar, adds an AI glow, and shows grounded results in a dropdown:
<script src="https://.../v.js?key=YOUR_KEY" defer></script>That is the whole installation. Multi tenant from the first line: the publishable key resolves to a tenant through the DynamoDB GSI, and every row is partitioned by tenant_id.
What scales to zero really buys you
DynamoDB is pay per request, Lambda scales to zero, S3 is static. There are no servers to manage and nothing running when idle. For a small business that means the AI line item costs about nothing until a customer actually uses it. For us it meant the free tier covered the entire build.
Try it and the code
- Landing page and live dashboard, plus all resources, are in the repo.
Built for the First Commit, Bharat Builds Tour hackathon by WeMakeDevs and AWS.
AWS, Serverless, AWS Lambda, Amazon DynamoDB, AI, Generative AI, Hackathon
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article