diff --git a/.kiro/steering/product.md b/.kiro/steering/product.md new file mode 100644 index 0000000..a3ff293 --- /dev/null +++ b/.kiro/steering/product.md @@ -0,0 +1,29 @@ +# Product Overview + +## Shopify Price Updater + +A Node.js command-line tool for bulk updating Shopify product prices based on product tags using Shopify's GraphQL Admin API. + +### Core Features + +- **Tag-based filtering**: Updates prices only for products with specific tags +- **Dual operation modes**: + - `update`: Adjusts prices by percentage and sets compare-at prices + - `rollback`: Reverts prices using compare-at price values +- **Batch processing**: Handles large inventories with automatic pagination +- **Error resilience**: Continues processing with comprehensive error handling +- **Rate limit handling**: Automatic retry logic with exponential backoff +- **Progress tracking**: Detailed logging to console and Progress.md file + +### Target Users + +- Shopify store owners managing promotional pricing +- E-commerce teams running seasonal sales campaigns +- Developers automating price management workflows + +### Key Value Propositions + +- Reduces manual price update effort from hours to minutes +- Provides rollback capability for promotional campaigns +- Maintains data integrity with validation and error handling +- Offers detailed audit trails through comprehensive logging diff --git a/.kiro/steering/structure.md b/.kiro/steering/structure.md new file mode 100644 index 0000000..72c608e --- /dev/null +++ b/.kiro/steering/structure.md @@ -0,0 +1,71 @@ +# Project Structure + +## Directory Organization + +``` +shopify-price-updater/ +├── src/ # Main application source code +│ ├── config/ # Configuration management +│ │ └── environment.js # Environment variable validation & loading +│ ├── services/ # Business logic services +│ │ ├── shopify.js # Shopify API client & GraphQL operations +│ │ ├── product.js # Product operations & price calculations +│ │ └── progress.js # Progress tracking & logging service +│ ├── utils/ # Utility functions +│ │ ├── price.js # Price calculation & validation utilities +│ │ └── logger.js # Logging utilities & formatters +│ └── index.js # Main application entry point +├── tests/ # Test suites +│ ├── config/ # Configuration tests +│ ├── services/ # Service layer tests +│ ├── utils/ # Utility function tests +│ ├── integration/ # Integration tests +│ └── index.test.js # Main application tests +├── backend/ # Separate backend component (minimal) +│ └── .env # Backend-specific environment config +├── .env # Main environment configuration +├── .env.example # Environment template +├── Progress.md # Generated operation logs +├── debug-tags.js # Standalone tag analysis script +└── test-*.js # Individual test scripts +``` + +## Code Organization Patterns + +### Service Layer Structure + +- **ShopifyService**: API client, authentication, retry logic +- **ProductService**: Product fetching, validation, price updates +- **ProgressService**: Logging, progress tracking, file operations + +### Configuration Management + +- Centralized in `src/config/environment.js` +- Validation at startup with clear error messages +- Environment-specific defaults and overrides + +### Error Handling Strategy + +- Service-level error categorization (rate limits, network, validation) +- Comprehensive retry logic with exponential backoff +- Detailed error logging with context preservation + +### Testing Structure + +- Unit tests for utilities and individual services +- Integration tests for complete workflows +- Mock-based testing for external API dependencies +- Separate test files for different operation modes + +## File Naming Conventions + +- **Services**: `[domain].js` (e.g., `shopify.js`, `product.js`) +- **Utilities**: `[function].js` (e.g., `price.js`, `logger.js`) +- **Tests**: `[module].test.js` or `test-[feature].js` +- **Configuration**: Descriptive names (e.g., `environment.js`) + +## Entry Points + +- **Main Application**: `src/index.js` - Complete price update workflow +- **Debug Tools**: `debug-tags.js` - Tag analysis and troubleshooting +- **Test Scripts**: `test-*.js` - Individual feature testing diff --git a/.kiro/steering/tech.md b/.kiro/steering/tech.md new file mode 100644 index 0000000..23b25b5 --- /dev/null +++ b/.kiro/steering/tech.md @@ -0,0 +1,62 @@ +# Technology Stack + +## Runtime & Dependencies + +- **Node.js**: >=16.0.0 (specified in package.json engines) +- **Core Dependencies**: + - `@shopify/shopify-api`: ^7.7.0 - Shopify GraphQL API client + - `dotenv`: ^16.3.1 - Environment variable management + - `node-fetch`: ^3.3.2 - HTTP client for API requests +- **Development Dependencies**: + - `jest`: ^29.7.0 - Testing framework + +## Architecture Patterns + +- **Service Layer Architecture**: Separation of concerns with dedicated services +- **Configuration Management**: Centralized environment-based configuration +- **Error Handling**: Comprehensive retry logic with exponential backoff +- **Logging Strategy**: Dual output (console + Progress.md file) + +## API Integration + +- **Shopify GraphQL Admin API**: Version 2024-01 +- **Authentication**: Private App access tokens +- **Rate Limiting**: Built-in handling with automatic retries +- **Bulk Operations**: Uses `productVariantsBulkUpdate` mutation + +## Common Commands + +### Development + +```bash +npm install # Install dependencies +npm start # Run with default settings +npm run update # Explicit update mode +npm run rollback # Rollback mode +npm run debug-tags # Debug tag analysis +npm test # Run test suite +``` + +### Environment Setup + +```bash +copy .env.example .env # Create environment file (Windows) +cp .env.example .env # Create environment file (Unix) +``` + +### Testing & Debugging + +```bash +npm run debug-tags # Analyze store tags before running +npm test # Run Jest test suite +``` + +## Environment Variables + +Required variables (see .env.example): + +- `SHOPIFY_SHOP_DOMAIN`: Store domain +- `SHOPIFY_ACCESS_TOKEN`: Admin API token +- `TARGET_TAG`: Product tag filter +- `PRICE_ADJUSTMENT_PERCENTAGE`: Adjustment percentage +- `OPERATION_MODE`: "update" or "rollback"