An end-to-end, multi-tenant AI shopping assistant platform. Shoppers chat (text and voice) with an AI agent named Leo to discover products and place orders; merchants connect their Shopify store and products sync in; companies embed the agent in their own app via an API + payment webhooks.
Built as a complete, runnable build-along on the @codewithmuh YouTube channel β runs locally end-to-end with one command.
sequenceDiagram
autonumber
actor Shopper as π Shopper (Voice / Text)
participant UI as π₯οΈ Next.js WebApp
participant ASGI as β‘ Daphne / Channels (WS)
participant Agent as π€ Leo Agent (Django)
participant LLM as π§ Claude 3.5 Sonnet
participant DB as ποΈ Postgres & Redis
participant Shopify as ποΈ Shopify Store API
Shopper->>UI: Speaks or types product request
UI->>ASGI: Stream chat packet over WebSocket
ASGI->>Agent: Session state & context lookup
Agent->>LLM: Prompt + Tool Definitions
LLM-->>Agent: Tool Call (search_catalog / place_order)
Agent->>DB: Query inventory / cache
Agent->>Shopify: Sync product stock / create draft order
Shopify-->>Agent: Inventory & checkout confirmed
Agent->>LLM: Tool results
LLM-->>Agent: Natural language + TTS audio response
Agent->>ASGI: Stream tokens + voice chunks
ASGI->>UI: Play audio & render product carousel
UI->>Shopper: Interactive shopping UI & speech
License: source-available under PolyForm Noncommercial 1.0.0 β learn freely, commercial use needs permission. See LICENSE and NOTICE.
ShopAgent serves three kinds of users:
| User | What they do | Where |
|---|---|---|
| π Shoppers | Chat (text + voice) with Leo to discover products, get recommendations, place & track orders | /demo/* |
| πͺ Merchants | Connect a Shopify store, sync products, view orders & inventory | /merchant/* |
| π’ Companies | Embed the agent in their own app via client_id/secret_key + payment webhooks |
/portal/* |
The agent is a Claude tool-use loop with real guardrails: prompt-injection resistance, strict shopping-only scope, content filtering, rate limiting, and per-session order caps.
- Conversational commerce β natural-language product search, recommendations, address capture, order placement and tracking, all through chat.
- Voice mode β optional speech in/out (OpenAI TTS) for a hands-free shopping demo.
- Real Shopify sync β merchants paste an Admin API token; products, variants, prices, images, and live inventory sync in. Stock is decremented back in Shopify on each order.
- Multi-currency β merchant prices are normalized to a single display currency
(
DEFAULT_CURRENCY, defaultUSD) across 11 supported currencies. - Company API + webhooks β embed the agent over WebSocket with
client_id/secret_key;balance_check/chargepayment webhooks let the host app authorize and settle payment. - Safety guards β prompt-injection / jailbreak resistance, off-topic deflection, abuse & content filters, Redis-backed rate limits, max-orders-per-session.
- One-command local dev β
make upboots Postgres, Redis, Django/Daphne, and Next.js, auto-migrates, and seeds demo data.
Backend β Django 5.2 Β· Django REST Framework Β· Channels + Daphne (ASGI/WebSocket) Β· PostgreSQL Β· Redis Β· Anthropic Claude (tool use) Β· JWT auth Β· boto3 (S3) Β· Python 3.10
Frontend β Next.js 16 Β· React 19 Β· Tailwind CSS 4 Β· TypeScript Β· Node 22
Infra (optional) β Terraform for AWS ECS Fargate + RDS + ElastiCache + ALB + ECR + Route53
Prerequisites: Docker (with the Compose v2 plugin) and an Anthropic API key.
# 1. Configure
cp .env.example .env
# β open .env and set ANTHROPIC_API_KEY=sk-ant-...
# 2. Run everything (builds images, migrates, seeds demo data)
make upThen open:
| Role | |
|---|---|
| Shopper (demo) | [email protected] |
| Company portal (Acme) | [email protected] |
| Merchant | [email protected] Β· [email protected] Β· [email protected] Β· [email protected] Β· [email protected] |
Seed data: 5 merchants, 15 products (28 variants), 1 demo API-consumer company (Acme), and demo shoppers.
Try it: open the shopper demo, say "hi", then "show me some headphones" β Leo searches the catalog and renders product cards. Add an address and place an order.
Get real product data on camera for free using a Shopify Partners development store β no paid plan required. Full walkthrough: docs/SHOPIFY_SETUP.md.
TL;DR: free Partners account β dev store β custom app β Admin API token β paste it in the Merchant Portal Connections page β products sync β Leo recommends them in chat.
make up # build + start everything (auto-migrate + seed)
make up-d # same, detached (background)
make down # stop (keeps the database volume)
make reset # wipe everything incl. DB volume, rebuild from scratch
make seed # (re)seed demo merchants, products, company, users
make shopify-sync # re-sync all connected Shopify stores
make migrate # apply database migrations
make superuser # create a Django admin superuser
make logs # tail all logs
make shell # shell into the backend container
Run make with no target for the full menu.
shopagent/
βββ backend/ # Django + DRF + Channels
β βββ agent/ # Claude loop, system prompt, tools, WebSocket consumer, guards
β βββ merchants/ # Merchant accounts + Shopify connections
β βββ companies/ # API-consumer companies (client_id/secret_key), usage logs
β βββ products/ orders/ users/
β βββ integrations/ # shopify.py, s3.py, webhooks.py
β βββ seed/ # demo data seeder
β βββ config/ # settings, ASGI/WSGI, URLs
βββ frontend/ # Next.js 16 app (shopper / merchant / company surfaces)
βββ infra/ # Terraform for AWS (optional β see infra/README.md)
βββ docs/SHOPIFY_SETUP.md # connect a real Shopify dev store
βββ DEPLOYMENT.md # production deployment guide (sanitized placeholders)
βββ docker-compose.yml # base stack
βββ docker-compose.override.yml # local dev (hot reload, auto-seed) β auto-loaded
βββ docker-compose.prod.yml # production overrides
βββ Makefile
All configuration is via environment variables β see .env.example for the documented list. Highlights:
ANTHROPIC_API_KEYβ required, powers Leo.DEFAULT_CURRENCYβ display currency (defaultUSD).OPENAI_API_KEYβ optional, enables voice mode (TTS).AWS_*β optional, re-host synced product images on S3 (falls back to Shopify CDN URLs).NEXT_PUBLIC_API_URL/NEXT_PUBLIC_WS_URLβ backend URLs baked into the frontend.
A Next.js frontend talks to a Django/DRF API over HTTP and to the Claude-powered agent over a WebSocket (Channels + Daphne, with Redis as the channel layer). The agent runs a tool-use loop against the product/order/address tools, and merchant catalogs are populated by the Shopify Admin API sync.
A rendered AWS production topology is in
infra/architecture-diagram.html (open in a browser), with
the editable source in architecture-diagram.excalidraw.
Local dev needs only Docker. For a real AWS deployment (ECS Fargate + RDS + ElastiCache + ALB),
see DEPLOYMENT.md and the Terraform in infra/. All
account-specific values in those docs are placeholders (<AWS_ACCOUNT_ID>, <EC2_HOST>, β¦) β
fill in your own.
This is a teaching codebase. A few things are intentionally simplified and must be hardened before any real commercial deployment:
- Merchant Shopify access tokens are stored in plaintext (
MerchantConnection, markedTODO: encrypt in production) so the data flow is easy to follow on camera. Encrypt them at rest in production (e.g. KMS / Fernet). - Demo credentials and secrets in
.env.exampleare for local use only β generate real, unique secrets for production.
The agent itself ships with solid guardrails (prompt-injection resistance, scope/content
filters, rate limiting) β see backend/agent/.
Built by CodeWithMuh as a practical, build-it-with-Claude-Code tutorial. If this helped you, subscribe: youtube.com/@codewithmuh.
PolyForm Noncommercial License 1.0.0 β source-available. Learn, fork, and build noncommercially for free; commercial use requires permission. See LICENSE and NOTICE. Commercial licensing inquiries: [email protected].