Skip to content

Commit 8bf5313

Browse files
Add developer guide and documentation for A2A sample (#30)
* Add comprehensive developer guide for A2A sample This adds a 9-document developer guide for the Cymbal Retail Agent sample: - SKILLS.md: AI assistant context for Claude Code, Gemini CLI, Cursor - DEVELOPER_GUIDE.md: Main entry point with architecture diagram - docs/01-architecture.md: System components and data flow - docs/02-adk-agent.md: ADK framework patterns, tools, callbacks - docs/03-ucp-integration.md: UCP capabilities and negotiation - docs/04-commerce-flows.md: Checkout state machine and payment - docs/05-frontend.md: React components and A2A client - docs/06-extending.md: How to customize the sample - docs/07-operations.md: Testing and troubleshooting * Enhance developer guide with diagrams, user journeys, and explanations - Rename 07-operations.md to 07-testing-guide.md for clarity - Add Mock Store architecture section with replacement guide - Major rewrite of extending guide with 4 user journeys - Add "Why" sections throughout for better readability - Add 9 new Mermaid diagrams across all docs - Update cross-references in DEVELOPER_GUIDE.md and SKILLS.md * Add diagrams and update developer documentation - Add 17 diagrams to assets/diagrams/ for visual documentation - Update docs to use images instead of Mermaid blocks - Add figure captions and proper alignment for all diagrams * Add architecture diagram to DEVELOPER_GUIDE.md * Optimize README and DEVELOPER_GUIDE flow - Add "Next Steps" section to README with links to developer docs - Remove redundant "Components" and "Mock Store" sections from README - Add "About This Guide" section to DEVELOPER_GUIDE with prerequisites - Remove duplicate Quick Start from DEVELOPER_GUIDE Creates smooth developer journey: README (landing) → DEVELOPER_GUIDE (technical entry) → docs/ (deep dives) with forward-only references. * Add glossary, production notes, and documentation improvements * Remove .scripts folder from tracking * Test WebP format for glossary diagrams (86-90% size reduction) * Convert images to WebP and GIF to MP4 (94% size reduction) * Use animated WebP for demo (71% smaller than GIF) * Update SKILLS.md and add references in README and dev guide * update diagram --------- Co-authored-by: Krishna Thota <kcthota@google.com>
1 parent 44b1768 commit 8bf5313

42 files changed

Lines changed: 2714 additions & 39 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

a2a/DEVELOPER_GUIDE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Cymbal Retail Agent - Developer Guide
2+
3+
## TL;DR
4+
5+
- **ADK Agent** with 8 shopping tools (search, checkout, payment) using Gemini 3.0 Flash
6+
- **UCP Integration** for standardized commerce data types and capability negotiation
7+
- **A2A Protocol** for agent discovery and JSON-RPC messaging
8+
9+
## About This Guide
10+
11+
This guide is for developers who want to understand how the sample works internally.
12+
13+
**Prerequisites:** Complete the [Quick Start in README.md](README.md#quick-start) first.
14+
15+
**What you'll learn:**
16+
- System architecture and component responsibilities
17+
- How UCP and A2A protocols integrate with ADK
18+
- The checkout state machine and commerce flows
19+
- How to extend and customize the sample
20+
21+
## Reading Roadmap
22+
23+
Choose your path based on your goal:
24+
25+
| Goal | Start Here | Then Read |
26+
|------|------------|-----------|
27+
| **New to AI agents?** | [Glossary](docs/00-glossary.md) | This guide → 01-architecture |
28+
| **Understand the system** | [Architecture](docs/01-architecture.md) | 02-adk-agent → 03-ucp-integration |
29+
| **Add a new tool** | [ADK Agent](docs/02-adk-agent.md) | 06-extending |
30+
| **Modify checkout flow** | [Commerce Flows](docs/04-commerce-flows.md) | 06-extending |
31+
| **Customize the UI** | [Frontend](docs/05-frontend.md) | - |
32+
| **Debug an issue** | [Testing Guide](docs/07-testing-guide.md) | - |
33+
| **Deploy to production** | [Production Notes](docs/08-production-notes.md) | - |
34+
| **Use AI assistant** | [SKILLS.md](SKILLS.md) | Context for Claude Code, Gemini CLI, Cursor, Codex |
35+
36+
## Architecture
37+
38+
<div align="center">
39+
<img src="assets/diagrams/00_01_architecture_overview.webp" alt="Cymbal Retail Agent Architecture" width="800">
40+
<p><em>System architecture — Chat Client (React + A2A Client) communicates via JSON-RPC to the Cymbal Retail Agent (A2A Server → ADKAgentExecutor → ADK Agent → RetailStore). Discovery endpoints expose agent capabilities and UCP profile.</em></p>
41+
</div>
42+
43+
## Quick Reference
44+
45+
### Key Files
46+
47+
| File | Purpose |
48+
|------|---------|
49+
| `business_agent/src/business_agent/agent.py` | ADK agent + 8 tools |
50+
| `business_agent/src/business_agent/store.py` | Checkout state machine |
51+
| `business_agent/src/business_agent/agent_executor.py` | A2A ↔ ADK bridge |
52+
| `chat-client/App.tsx` | React app + A2A messaging |
53+
54+
### Endpoints
55+
56+
| Endpoint | Purpose |
57+
|----------|---------|
58+
| `GET /.well-known/agent-card.json` | A2A agent discovery |
59+
| `GET /.well-known/ucp` | UCP merchant profile |
60+
| `POST /` | A2A JSON-RPC endpoint |
61+
62+
### State Keys
63+
64+
| Key | Purpose |
65+
|-----|---------|
66+
| `user:checkout_id` | Current checkout session |
67+
| `__ucp_metadata__` | Negotiated capabilities |
68+
| `__payment_data__` | Payment instrument |
69+
70+
## Deep Dive Guides
71+
72+
| Guide | Topics |
73+
|-------|--------|
74+
| [Glossary](docs/00-glossary.md) | Key terms, acronyms, state keys |
75+
| [Architecture](docs/01-architecture.md) | System components, data flow |
76+
| [ADK Agent](docs/02-adk-agent.md) | Tools, callbacks, session management |
77+
| [UCP Integration](docs/03-ucp-integration.md) | Capabilities, profiles, negotiation |
78+
| [Commerce Flows](docs/04-commerce-flows.md) | Checkout lifecycle, payment |
79+
| [Frontend](docs/05-frontend.md) | React components, A2A client |
80+
| [Extending](docs/06-extending.md) | Add tools, products, capabilities |
81+
| [Testing Guide](docs/07-testing-guide.md) | Testing, debugging, troubleshooting |
82+
| [Production Notes](docs/08-production-notes.md) | Security gaps, deployment checklist |

a2a/README.md

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The sample uses **[Google ADK](https://google.github.io/adk-docs/)** (Agent Deve
3939
<b>Complete Shopping Flow</b><br/>
4040
<i>Product search → Add items to Checkout → Payment → Order confirmation</i>
4141
<br/><br/>
42-
<img src="assets/ucp_a2a_demo.gif" alt="UCP A2A Demo" width="800" />
42+
<img src="assets/ucp_a2a_demo.webp" alt="UCP A2A Demo" width="800" />
4343
<br/><br/>
4444
<a href="https://github.com/user-attachments/assets/8d3d17f5-dbcc-4cc8-91b9-2b7d48b3f2df">▶️ Watch the full demo video</a>
4545
</p>
@@ -50,7 +50,7 @@ The sample uses **[Google ADK](https://google.github.io/adk-docs/)** (Agent Deve
5050
<b>System Architecture</b><br/>
5151
<i>How Client, A2A Protocol, Cymbal Retail Agent, and Store interact</i>
5252
<br/><br/>
53-
<img src="assets/architecture_diagram.jpeg" alt="Architecture Diagram" width="900" />
53+
<img src="assets/architecture_diagram.webp" alt="Architecture Diagram" width="900" />
5454
</p>
5555

5656
**Key points:**
@@ -103,13 +103,13 @@ This starts the Cymbal Retail Agent on port 10999. You can verify by accessing:
103103
<td width="50%" align="center">
104104
<b>Agent Card</b><br/><code>/.well-known/agent-card.json</code>
105105
<br/><br/>
106-
<img src="assets/agent_card.png" alt="Agent Card" width="400" />
106+
<img src="assets/agent_card.webp" alt="Agent Card" width="400" />
107107
<br/><i>Declares UCP extension with capabilities</i>
108108
</td>
109109
<td width="50%" align="center">
110110
<b>UCP Profile</b><br/><code>/.well-known/ucp</code>
111111
<br/><br/>
112-
<img src="assets/well_known.png" alt="UCP Profile" width="400" />
112+
<img src="assets/well_known.webp" alt="UCP Profile" width="400" />
113113
<br/><i>Defines supported capabilities & payment handlers</i>
114114
</td>
115115
</tr>
@@ -139,7 +139,7 @@ The Chat Client UCP Profile can be found at http://localhost:3000/profile/agent-
139139
<table>
140140
<tr>
141141
<td width="50%" align="center">
142-
<img src="assets/ucp_a2a_demo.gif" alt="Demo" width="400" />
142+
<img src="assets/ucp_a2a_demo.webp" alt="Demo" width="400" />
143143
<br/><a href="https://github.com/user-attachments/assets/8d3d17f5-dbcc-4cc8-91b9-2b7d48b3f2df">▶️ Watch full video</a>
144144
</td>
145145
<td width="50%" valign="top">
@@ -158,6 +158,19 @@ The Chat Client UCP Profile can be found at http://localhost:3000/profile/agent-
158158
</tr>
159159
</table>
160160

161+
> **Note**: This sample is for demonstration purposes only. See [Production Notes](docs/08-production-notes.md) for security considerations and deployment requirements.
162+
163+
## Next Steps
164+
165+
Ready to understand how it works?
166+
167+
| Goal | Resource |
168+
|------|----------|
169+
| **Understand the architecture** | [Developer Guide](DEVELOPER_GUIDE.md) |
170+
| **Deep dive into code** | [Architecture](docs/01-architecture.md) |
171+
| **Extend the sample** | [Extending Guide](docs/06-extending.md) |
172+
| **AI assistant context** | [SKILLS.md](SKILLS.md) - Context for Claude Code, Gemini CLI, Cursor, Codex |
173+
161174
## What is UCP?
162175

163176
**Universal Commerce Protocol (UCP)** is an open standard that enables interoperability between commerce platforms, merchants, and payment providers. It provides standardized data types for commerce transactions.
@@ -177,40 +190,6 @@ This sample uses the following UCP capabilities:
177190
| **[A2A Protocol](https://a2a-protocol.org/latest/)** | Communication | Agent discovery via Agent Card, JSON-RPC messaging, task management |
178191
| **[UCP](https://ucp.dev)** | Commerce Standard | Standardized product, checkout, payment, and order data types |
179192

180-
## Components
181-
182-
### Cymbal Retail Agent (`business_agent/`)
183-
184-
AI shopping assistant built with Google ADK, exposed via A2A interface with UCP extension.
185-
186-
| File | Purpose |
187-
|------|---------|
188-
| `agent.py` | ADK Agent with Gemini 3.0 Flash + 8 shopping tools |
189-
| `agent_executor.py` | Bridges ADK ↔ A2A protocol |
190-
| `store.py` | Mock RetailStore (products, checkouts, orders) |
191-
| `data/ucp.json` | UCP Profile served at `/.well-known/ucp` |
192-
193-
### Chat Client (`chat-client/`)
194-
195-
React UI (TypeScript, Vite, Tailwind) that communicates via A2A and renders UCP data types.
196-
197-
| File | Purpose |
198-
|------|---------|
199-
| `App.tsx` | A2A messaging + state management |
200-
| `components/` | ProductCard, Checkout, PaymentMethodSelector |
201-
| `profile/agent_profile.json` | Client's UCP capabilities |
202-
203-
## Mock Store
204-
205-
The Cymbal Retail Agent uses an in-memory `RetailStore` to simulate a real backend:
206-
207-
- **Products** - Loaded from `data/products.json` (cookies, chips, fruits, etc.)
208-
- **Checkouts** - Session-based checkout management with line items
209-
- **Orders** - Created when checkout completes successfully
210-
- **Payments** - Mock processor simulates payment flow
211-
212-
Prices are in USD, tax is calculated at 10%, and shipping costs vary by method.
213-
214193
## Related Resources
215194

216195
- [UCP Specification](https://ucp.dev/specification/overview/)

0 commit comments

Comments
 (0)