App Configuration
Relevant source files
The following files were used as context for generating this wiki page:
The MarketSage application configuration encompasses system-level settings, environment variables, browser extension manifests, and user-specific preferences. It serves as the backbone for managing security thresholds, API interactions, and cross-platform compatibility for Chinese marketplaces like Temu, AliExpress, and DHgate.
Centralized configuration ensures that components such as the SmartShoppingAssistant and the MarketplaceMonitoringDashboard operate within defined performance and security bounds. This module governs how the application initializes, validates its environment during builds, and persists user settings across sessions.
Core Application Settings
The primary configuration logic is encapsulated in the AppConfig class, which implements a singleton pattern to provide a single point of access for application constants and environmental overrides.
Configuration Hierarchy
The application categorizes settings into four main domains: Security, Cache, API, and Monitoring.
The following table outlines the default values defined within the core configuration:
| Category | Parameter | Default Value | Description |
|---|---|---|---|
| Security | maxLoginAttempts | 3 | Maximum failed logins before lockout |
| Security | sessionTimeout | 3600 | Session duration in seconds |
| Cache | product TTL | 86,400,000 ms | 24-hour cache for product data |
| API | timeout | 5000 ms | Maximum wait time for API responses |
| Monitoring | maxErrorRate | 0.05 | 5% error rate threshold for alerts |
Sources: src/config/AppConfig.ts:4-46
Manifest and Environment Configuration
As a Chrome extension, MarketSage relies on manifest.json for environment permissions and script injection rules. This configuration defines the boundaries of the extension's interaction with host marketplaces.
Platform and Permission Scoping
The extension is configured to interact specifically with three major platforms.
Sources: src/manifest.json:7-25
Build Verification
MarketSage employs a verification script (verify-build.js) that acts as a pre-build configuration validator. It ensures the environment meets strict requirements before compilation.
- Dependency Checks: Validates presence of
react,rxjs, and@tensorflow/tfjs. - TypeScript Strictness: Verifies that
compilerOptions.strictis enabled intsconfig.json. - Component Integrity: Confirms critical files like
StateManager.tsandErrorHandler.tsexist.
Sources: scripts/verify-build.js:31-90, package.json:20
User and Security Tier Configuration
Configuration is not static; it scales based on the user's authentication state and security tier. The EnhancedApp component manages this stateful configuration.
Security Levels
Users are assigned levels that unlock specific configuration capabilities:
- Basic: Standard protection settings.
- Enhanced: Enables advanced threat detection and history.
- Premium: Unlocks AI-powered analysis, detailed security reports, and real-time scanning.
Sources: src/popup/components/protect/EnhancedProtectSection.tsx:23-28, src/popup/components/EnhancedApp.tsx:18-24
User Preference Schema
The configuration for user preferences includes UI settings and security toggles.
Platform Selectors and API Endpoints
To handle varying marketplace structures, the application uses a PlatformConfig interface to define selectors for data extraction.
export interface PlatformConfig {
name: Platform;
baseUrl: string;
selectors: {
price: string;
title: string;
seller: string;
shipping: string;
description: string;
specifications: string;
};
}
Sources: src/common/types/index.ts:108-120
Summary
The App Configuration in MarketSage is a multi-layered system that transitions from static build-time validation and manifest permissions to dynamic, tier-based user preferences. By centralizing these settings in AppConfig.ts and enforcing them through verify-build.js, the system maintains high standards for security and marketplace compatibility while allowing for granular user customization of AI-powered features.