How google-agentic-commerce/ap2 works
Project type and purpose
• This is an open-source protocol implementation and demonstration repository for the Agent Payments Protocol (AP2).
• It provides:
• A Python “types” package defining the core AP2 objects (in src/ap2/types).
• A set of Python microservices (under samples/python) that run various agent roles (shopping agent, merchant agent, credentials provider, payment processor) using ADK and Gemini LLM.
• An Android sample app (under samples/android/shopping_assistant) showing a shopping assistant UI that interacts with Python agents via A2A messaging.
• Documentation and scenario scripts demonstrating how to run end-to-end flows.
File structure
• Top-level directories:
• src/ap2/types – protocol object definitions (future PyPI package).
• samples/python – Python scenarios, common utilities, and role-based microservices.
• samples/android – Android demo app structured with Gradle, Jetpack Compose MVVM.
• docs and mkdocs.yml – site documentation for protocol spec, glossary, FAQs.
• .github, pipelines, lint configs – CI/CD, linting, release automation.
• Patterns and configurations:
• Python services share a common library (samples/python/src/common) for A2A message building, HTTP server logic, retry utilities, log watching.
• Each “role” is a standalone Python process (entrypoint __main__.py) that loads agent.json to configure tools and LLM calls.
• Android app is a Compose-based UI with ChatViewModel, A2AClient, repository, and data model layers.
• run.sh scripts orchestrate dependency installation and startup of multiple agents.
README for additional insights
• The README states this is purely a samples repo using ADK & Gemini 2.5 but not requiring them.
• It directs you to scenario readmes and run.sh to launch agents.
• It highlights that src/ap2/types is the protocol’s core object definitions.