# ckothapa03-pixel/shopping-agentic-ai-mcp architecture

> Architecture diagram of the GitHub repository ckothapa03-pixel/shopping-agentic-ai-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ckothapa03-pixel/shopping-agentic-ai-mcp
- Repository: https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp

## Overview

Shopwise is a Streamlit storefront using existing SQLite databases, with an optional Gemini shopping assistant. The main user journey runs from browsing and account access through cart and wishlist management to confirmed COD checkout and order review. Separate branches cover product discovery/recommendations and the assistant’s read-only catalog tools, with optional local document retrieval. The graph emphasizes documented call ownership and README-described capabilities; some UI and checkout internals were not sampled, so their links are limited to explicit documentation.

Main entry points: [`app/mcp/mcp_server.py`](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/mcp/mcp_server.py) (MCP server), [`app/db/database.py`](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/database.py) (Shopping SQLite), [`app/db/user_data.py`](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/user_data.py) (Cart and wishlist data), [`app/ui/product_card.py`](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/product_card.py) (Product cards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Storefront UI"]
  node_web["Streamlit app<br/>[web_app.py]"]
  node_catalog["Catalog browsing<br/>[catalog.py]"]
  node_catalog_data["Catalog presentation<br/>[catalog_data.py]"]
  node_product_card["Product cards<br/>[product_card.py]"]
  node_auth_ui["Login UI<br/>[auth.py]"]
  node_cart_ui["Cart UI<br/>[cart_pages.py]"]
  node_checkout_ui["Checkout UI<br/>[checkout_page.py]"]
  node_orders_ui["Order views<br/>[orders_page.py]"]
  node_accounts_ui["Account pages<br/>[account_pages.py]"]
  node_addresses_ui["Address pages<br/>[address_pages.py]"]
  node_wishlist_ui["Wishlist page<br/>[wishlist_page.py]"]
  node_chat_ui["Chat interface<br/>[chat_submission.py]"]
  node_image_helper["Product images<br/>[product_images.py]"]
end

subgraph group_shopping["Shopping flows"]
  node_authentication["Authentication<br/>[authentication.py]"]
  node_cart_rules["Cart rules<br/>[cart.py]"]
  node_checkout_policy["Checkout confirmation<br/>[confirmation.py]"]
  node_money["Money and coupons<br/>[money.py]"]
end

subgraph group_data["SQLite data"]
  node_products["Product repository<br/>[products.py]"]
  node_user_data["Cart and wishlist data<br/>[user_data.py]"]
  node_checkout_repo["Order creation"]
  node_orders_repo["Order repository"]
  node_addresses_repo["Address repository"]
  node_identity_repo["Identity mapping<br/>[identity.py]"]
  node_database[("Shopping SQLite<br/>[database.py]")]
  node_accounts_db[("Accounts SQLite")]
end

subgraph group_assistant["AI assistant"]
  node_agent["Gemini agent<br/>[agent.py]"]
  node_chat_runtime["Chat runtime<br/>[chat_runtime.py]"]
  node_permissions["Tool permissions"]
  node_mcp_client["MCP client tools<br/>[mcp_tools.py]"]
end

subgraph group_mcp["MCP tools"]
  node_mcp_server["MCP server<br/>[mcp_server.py]"]
  node_product_tool["Catalog adapter<br/>[products_tool.py]"]
end

subgraph group_retrieval["Document retrieval"]
  node_rag["Local retrieval<br/>[retrieval.py]"]
end

node_shopper(("Shopper"))
node_gemini{{"Gemini service"}}

node_shopper -->|"uses"| node_web
node_web -->|"renders"| node_catalog
node_web -->|"renders"| node_auth_ui
node_catalog -->|"loads"| node_catalog_data
node_catalog -->|"renders"| node_product_card
node_catalog_data -->|"queries"| node_products
node_product_card -->|"updates"| node_cart_rules
node_product_card -->|"persists"| node_user_data
node_product_card -->|"resolves image"| node_image_helper
node_auth_ui -->|"authenticates"| node_authentication
node_authentication -->|"links identity"| node_identity_repo
node_authentication -->|"reads account"| node_accounts_db
node_cart_ui -.->|"loads and saves"| node_user_data
node_wishlist_ui -.->|"loads and saves"| node_user_data
node_addresses_ui -.->|"manages"| node_addresses_repo
node_checkout_ui -.->|"submits confirmed order"| node_checkout_repo
node_checkout_repo -->|"calculates totals"| node_money
node_checkout_repo -->|"writes order and stock"| node_database
node_orders_ui -.->|"views orders"| node_orders_repo
node_accounts_ui -.->|"manages account"| node_authentication
node_user_data -->|"reads and writes"| node_database
node_products -->|"reads catalog"| node_database
node_orders_repo -->|"reads orders"| node_database
node_addresses_repo -->|"reads and writes"| node_database
node_identity_repo -->|"reads mapping"| node_database
node_chat_ui -->|"submits request"| node_chat_runtime
node_chat_runtime -->|"runs chat"| node_agent
node_agent -->|"discovers and calls"| node_mcp_client
node_agent -->|"requests response"| node_gemini
node_agent -->|"checks tools"| node_permissions
node_mcp_client -->|"filters tools"| node_permissions
node_mcp_client -.->|"uses stdio server"| node_mcp_server
node_mcp_server -->|"guards operations"| node_permissions
node_mcp_server -->|"dispatches catalog search"| node_product_tool
node_product_tool -->|"queries products"| node_products
node_mcp_server -->|"reads catalog"| node_products
node_mcp_server -->|"dispatches user tools"| node_user_data
node_mcp_server -->|"dispatches retrieval"| node_rag
node_rag -->|"reads and writes chunks"| node_database

click node_web "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/web_app.py"
click node_catalog "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/catalog.py"
click node_catalog_data "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/catalog_data.py"
click node_product_card "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/product_card.py"
click node_auth_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/auth.py"
click node_cart_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/cart_pages.py"
click node_checkout_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/checkout_page.py"
click node_orders_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/orders_page.py"
click node_accounts_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/account_pages.py"
click node_addresses_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/address_pages.py"
click node_wishlist_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/wishlist_page.py"
click node_chat_ui "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/chat/chat_submission.py"
click node_authentication "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/authentication.py"
click node_cart_rules "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/cart.py"
click node_checkout_policy "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/confirmation.py"
click node_money "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/money.py"
click node_products "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/products.py"
click node_user_data "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/user_data.py"
click node_checkout_repo "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/checkout_repository.py"
click node_orders_repo "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/order_repository.py"
click node_addresses_repo "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/address_repository.py"
click node_identity_repo "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/identity.py"
click node_database "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/database.py"
click node_agent "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/agent.py"
click node_chat_runtime "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/chat_runtime.py"
click node_permissions "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/tool_permissions.py"
click node_mcp_client "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/mcp/mcp_tools.py"
click node_mcp_server "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/mcp/mcp_server.py"
click node_product_tool "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/tools/products_tool.py"
click node_rag "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/rag/retrieval.py"
click node_image_helper "https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/product_images.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_catalog,node_catalog_data,node_product_card,node_auth_ui,node_cart_ui,node_checkout_ui,node_orders_ui,node_accounts_ui,node_addresses_ui,node_wishlist_ui,node_chat_ui,node_image_helper toneBlue
class node_authentication,node_cart_rules,node_checkout_policy,node_money toneAmber
class node_products,node_user_data,node_checkout_repo,node_orders_repo,node_addresses_repo,node_identity_repo,node_database,node_accounts_db toneMint
class node_agent,node_chat_runtime,node_permissions,node_mcp_client toneRose
class node_mcp_server,node_product_tool,node_shopper,node_gemini toneIndigo
class node_rag toneTeal
```

## Components

### Storefront UI

- [Streamlit app](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/web_app.py): `app/ui/web_app.py`
- [Catalog browsing](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/catalog.py): `app/ui/catalog.py`
- [Catalog presentation](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/catalog_data.py): `app/ui/catalog_data.py`
- [Product cards](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/product_card.py): `app/ui/product_card.py`
- [Login UI](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/auth.py): `app/ui/auth.py`
- [Cart UI](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/cart_pages.py): `app/ui/cart_pages.py`
- [Checkout UI](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/checkout_page.py): `app/ui/checkout_page.py`
- [Order views](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/orders_page.py): `app/ui/orders_page.py`
- [Account pages](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/account_pages.py): `app/ui/account_pages.py`
- [Address pages](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/address_pages.py): `app/ui/address_pages.py`
- [Wishlist page](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/wishlist_page.py): `app/ui/wishlist_page.py`
- [Chat interface](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/chat/chat_submission.py): `app/ui/chat/chat_submission.py`
- [Product images](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/ui/product_images.py): `app/ui/product_images.py`

### Shopping flows

- [Authentication](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/authentication.py): `app/shopping/authentication.py`
- [Cart rules](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/cart.py): `app/shopping/cart.py`
- [Checkout confirmation](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/confirmation.py): `app/shopping/confirmation.py`
- [Money and coupons](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/shopping/money.py): `app/shopping/money.py`

### SQLite data

- [Product repository](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/products.py): `app/db/products.py`
- [Cart and wishlist data](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/user_data.py): `app/db/user_data.py`
- [Order creation](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/checkout_repository.py): `app/db/checkout_repository.py`
- [Order repository](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/order_repository.py): `app/db/order_repository.py`
- [Address repository](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/address_repository.py): `app/db/address_repository.py`
- [Identity mapping](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/identity.py): `app/db/identity.py`
- [Shopping SQLite](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/db/database.py): `app/db/database.py`
- **Accounts SQLite**

### AI assistant

- [Gemini agent](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/agent.py): `app/agent/agent.py`
- [Chat runtime](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/chat_runtime.py): `app/agent/chat_runtime.py`
- [Tool permissions](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/agent/tool_permissions.py): `app/agent/tool_permissions.py`
- [MCP client tools](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/mcp/mcp_tools.py): `app/mcp/mcp_tools.py`

### MCP tools

- [MCP server](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/mcp/mcp_server.py): `app/mcp/mcp_server.py`
- [Catalog adapter](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/tools/products_tool.py): `app/tools/products_tool.py`

### Document retrieval

- [Local retrieval](https://github.com/ckothapa03-pixel/shopping-agentic-ai-mcp/blob/main/app/rag/retrieval.py): `app/rag/retrieval.py`

### Other components

- **Shopper**
- **Gemini service**

## Connections

- Shopper → Streamlit app: uses (evidence: `README.md`)
- Streamlit app → Catalog browsing: renders (evidence: `README.md`)
- Streamlit app → Login UI: renders (evidence: `README.md`)
- Catalog browsing → Catalog presentation: loads (evidence: `app/ui/catalog.py`)
- Catalog browsing → Product cards: renders (evidence: `app/ui/catalog.py`)
- Catalog presentation → Product repository: queries (evidence: `app/ui/catalog_data.py`)
- Product cards → Cart rules: updates (evidence: `app/ui/product_card.py`)
- Product cards → Cart and wishlist data: persists (evidence: `app/ui/product_card.py`)
- Product cards → Product images: resolves image (evidence: `app/ui/product_card.py`)
- Login UI → Authentication: authenticates (evidence: `app/ui/auth.py`)
- Authentication → Identity mapping: links identity (evidence: `app/shopping/authentication.py`)
- Authentication → Accounts SQLite: reads account (evidence: `app/shopping/authentication.py`)
- Cart UI → Cart and wishlist data: loads and saves (evidence: `README.md`)
- Wishlist page → Cart and wishlist data: loads and saves (evidence: `README.md`)
- Address pages → Address repository: manages (evidence: `README.md`)
- Checkout UI → Order creation: submits confirmed order (evidence: `README.md`)
- Order creation → Money and coupons: calculates totals (evidence: `app/db/checkout_repository.py`)
- Order creation → Shopping SQLite: writes order and stock (evidence: `app/db/checkout_repository.py`)
- Order views → Order repository: views orders (evidence: `README.md`)
- Account pages → Authentication: manages account (evidence: `README.md`)
- Cart and wishlist data → Shopping SQLite: reads and writes (evidence: `app/db/user_data.py`)
- Product repository → Shopping SQLite: reads catalog (evidence: `app/db/products.py`)
- Order repository → Shopping SQLite: reads orders (evidence: `app/db/order_repository.py`)
- Address repository → Shopping SQLite: reads and writes (evidence: `app/db/address_repository.py`)
- Identity mapping → Shopping SQLite: reads mapping (evidence: `app/db/identity.py`)
- Chat interface → Chat runtime: submits request (evidence: `app/ui/chat/chat_submission.py`)
- Chat runtime → Gemini agent: runs chat (evidence: `app/agent/chat_runtime.py`)
- Gemini agent → MCP client tools: discovers and calls (evidence: `app/agent/agent.py`)
- Gemini agent → Gemini service: requests response (evidence: `app/agent/agent.py`)
- Gemini agent → Tool permissions: checks tools (evidence: `app/agent/agent.py`)
- MCP client tools → Tool permissions: filters tools (evidence: `app/mcp/mcp_tools.py`)
- MCP client tools → MCP server: uses stdio server (evidence: `README.md`)
- MCP server → Tool permissions: guards operations (evidence: `app/mcp/mcp_server.py`)
- MCP server → Catalog adapter: dispatches catalog search (evidence: `app/mcp/mcp_server.py`)
- Catalog adapter → Product repository: queries products (evidence: `app/tools/products_tool.py`)
- MCP server → Product repository: reads catalog (evidence: `app/mcp/mcp_server.py`)
- MCP server → Cart and wishlist data: dispatches user tools (evidence: `app/mcp/mcp_server.py`)
- MCP server → Local retrieval: dispatches retrieval (evidence: `app/mcp/mcp_server.py`)
- Local retrieval → Shopping SQLite: reads and writes chunks (evidence: `app/rag/retrieval.py`)
