The Nike Search Widget is a comprehensive system that enables intelligent Nike product search and comparison through multiple interfaces. It's built as a Model Context Protocol (MCP) server with custom UI components, designed to integrate seamlessly with ChatGPT's Apps SDK.
graph TB
subgraph "Frontend Layer"
UI[React UI Widget]
HTML[Test Interface]
end
subgraph "API Layer"
MCP[MCP Server]
REST[REST API Server]
SSE[SSE Endpoint]
end
subgraph "Data Layer"
NIKE[Nike.com API]
CACHE[Response Cache]
end
subgraph "Integration Layer"
CHATGPT[ChatGPT Apps SDK]
CLIENT[MCP Client]
end
UI --> MCP
HTML --> REST
MCP --> NIKE
REST --> MCP
SSE --> MCP
CHATGPT --> UI
CLIENT --> SSE
MCP --> CACHE
Primary component - Full-featured MCP server with advanced Nike API integration.
Key Features:
- π Product Search - Multi-parameter search with filters
- π Product Comparison - Side-by-side product analysis
- πΌοΈ Image Processing - Product image extraction and optimization
- π Smart Caching - Response caching for performance
- π‘οΈ Error Handling - Robust error recovery and fallbacks
Architecture:
class NikeSearchMCPServer:
βββ NikeSearchClient # Core API client
βββ search_products() # Main search functionality
βββ get_product_details() # Detailed product info
βββ compare_products() # Product comparison
βββ get_product_images() # Image extractionBridge component - FastAPI wrapper providing REST and SSE endpoints.
Endpoints:
GET /search- Product search via RESTGET /compare- Product comparison via RESTPOST /sse- Server-Sent Events for MCP communicationGET /health- Health check endpoint
Integration Pattern:
FastAPI App
βββ CORS Support # Cross-origin requests
βββ MCP Server Instance # Embedded MCP server
βββ SSE Transport Layer # Real-time communication
βββ Request Validation # Pydantic modelsPresentation layer - Modern React widgets following OpenAI Apps SDK patterns.
Component Hierarchy:
App.tsx (Main Container)
βββ ProductCard.tsx # Individual product display
βββ hooks.ts # OpenAI SDK integration hooks
βββ types.ts # TypeScript definitions
βββ component.tsx # Entry point and mounting
Key Features:
- π Theme Support - Light/dark mode switching
- π± Responsive Design - Mobile-first responsive layout
- β‘ Real-time Updates - Live data synchronization
- π¨ Nike Branding - Official Nike design system
- π External Links - Direct Nike.com integration
Development tool - Comprehensive testing client for MCP endpoints.
sequenceDiagram
participant U as User
participant UI as React Widget
participant MCP as MCP Server
participant N as Nike API
U->>UI: Enter search query
UI->>MCP: search_products(query, filters)
MCP->>N: HTTP request with headers
N->>MCP: Product JSON response
MCP->>MCP: Parse & validate data
MCP->>UI: Structured product list
UI->>U: Rendered product cards
sequenceDiagram
participant U as User
participant UI as React Widget
participant MCP as MCP Server
participant N as Nike API
U->>UI: Select products to compare
UI->>MCP: compare_products(product_ids)
par Parallel API Calls
MCP->>N: Get product 1 details
MCP->>N: Get product 2 details
end
MCP->>MCP: Compare specifications
MCP->>UI: Comparison matrix
UI->>U: Side-by-side comparison
- Python 3.9+ - Core runtime
- MCP Protocol - Model Context Protocol for AI integration
- FastAPI - Modern async web framework
- aiohttp - Async HTTP client
- Pydantic - Data validation and serialization
- React 18 - UI framework with hooks
- TypeScript - Type-safe JavaScript
- ESBuild - Fast bundling and compilation
- CSS-in-JS - Component-scoped styling
- OpenAI Apps SDK - ChatGPT custom app integration
- Server-Sent Events - Real-time communication
- CORS - Cross-origin resource sharing
nikesearch/
βββ π Backend Services
β βββ nikesearch.py # Main MCP server (1554 lines)
β βββ nikesearch_rest.py # REST API wrapper (328 lines)
β βββ test_mcp_client.py # Testing utilities (151 lines)
β βββ main.py # Entry point
β
βββ βοΈ Frontend Components
β βββ web/
β βββ src/
β β βββ App.tsx # Main container (224 lines)
β β βββ ProductCard.tsx # Product display (158 lines)
β β βββ component.tsx # Entry point (26 lines)
β β βββ hooks.ts # SDK integration (100 lines)
β β βββ types.ts # Type definitions (57 lines)
β βββ dist/
β β βββ component.js # Compiled bundle
β βββ test-with-server.html # Local testing interface
β βββ package.json # Node.js dependencies
β
βββ π¦ Configuration
β βββ pyproject.toml # Python project config
β βββ requirements.txt # Python dependencies
β βββ uv.lock # Lock file
β βββ app-manifest.json # OpenAI app manifest
β
βββ π Documentation
βββ README.md
βββ ARCHITECTURE.md # This file
βββ QUICK_START.md
βββ *.md # Additional docs
// Hook-based state management
const toolOutput = useToolOutput(); // Get MCP results
const theme = useTheme(); // UI theme sync
const displayMode = useDisplayMode(); // Layout mode
const [widgetState, setWidgetState] = useWidgetState({});# Standard MCP server structure
server = Server("nike-search")
@server.call_tool()
async def search_products(query: str, **filters) -> CallToolResult:
"""Tool implementation following MCP standards"""
return CallToolResult(content=[TextContent(type="text", text=result)])# Robust API client with fallbacks
class NikeSearchClient:
async def search_products(self, query: str) -> List[NikeProduct]:
# Multiple endpoint strategies
# Error handling and retries
# Response caching
# Data validation# Backend services
uv run python nikesearch.py # MCP server (stdio)
uv run python nikesearch_rest.py # REST API (port 8000)
# Frontend development
cd web && npm run build # Build React components
python3 -m http.server 8080 # Serve test interface- Load Balancing - Multiple MCP server instances
- Caching Layer - Redis for API response caching
- Rate Limiting - Nike API usage optimization
- Monitoring - Health checks and error tracking
- Security - API key management and request validation
All I/O operations use async patterns for optimal performance.
Pydantic models and TypeScript ensure data consistency.
Graceful degradation at every layer.
Smart caching to minimize Nike API calls.
Mobile-first UI with adaptive layouts.
Native OpenAI Apps SDK patterns for seamless ChatGPT integration.
- Parallel API Calls - Concurrent product fetching
- Image Optimization - Lazy loading and fallbacks
- Bundle Splitting - Optimized JavaScript delivery
- Request Deduplication - Avoid redundant API calls
- Memory Management - Efficient data structures
- Input Validation - All user inputs sanitized
- Rate Limiting - Prevent API abuse
- CORS Policy - Controlled cross-origin access
- Error Sanitization - No sensitive data in error messages
- API Key Management - Secure credential handling
This architecture supports both development testing and production deployment, providing a robust foundation for Nike product search and comparison capabilities.