Skip to content
codewithmuhPublic

About

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.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

9 Commits

Folders and files

πŸ›οΈ ShopAgent

GitHub Release Stars Forks License YouTube
Claude 3.5 Sonnet Django Channels Next.js 16 Shopify

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
Loading

License: source-available under PolyForm Noncommercial 1.0.0 β€” learn freely, commercial use needs permission. See LICENSE and NOTICE.


What's inside

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.


✨ Features

  • 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, default USD) across 11 supported currencies.
  • Company API + webhooks β€” embed the agent over WebSocket with client_id/secret_key; balance_check / charge payment 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 up boots Postgres, Redis, Django/Daphne, and Next.js, auto-migrates, and seeds demo data.

🧱 Tech stack

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


πŸš€ Quickstart (β‰ˆ60 seconds)

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 up

Then open:

Surface URL
πŸ›’ Shopper demo (chat with Leo) http://localhost:3000/demo/login
πŸͺ Merchant portal http://localhost:3000/merchant/login
🏒 Company portal http://localhost:3000/portal/login
πŸ§ͺ API playground http://localhost:3000/playground
βš™οΈ Django admin / API http://localhost:8000

Demo logins (all seeded, password demo1234)

Role Email
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.


πŸ›’ Connect a real Shopify store

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 targets

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.


πŸ—‚οΈ Project structure

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

βš™οΈ Configuration

All configuration is via environment variables β€” see .env.example for the documented list. Highlights:

  • ANTHROPIC_API_KEY β€” required, powers Leo.
  • DEFAULT_CURRENCY β€” display currency (default USD).
  • 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.

πŸ›οΈ Architecture

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.


☁️ Deployment

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.


πŸ”’ Security notes (read before shipping)

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, marked TODO: 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.example are 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/.


πŸ“Ί About

Built by CodeWithMuh as a practical, build-it-with-Claude-Code tutorial. If this helped you, subscribe: youtube.com/@codewithmuh.

πŸ“„ License

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].

About

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.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages