Skip to content
Xinyu Li edited this page Dec 12, 2025 · 1 revision

Technical Documentation & Pricing Algorithms

🏗 System Architecture

1. ExchangeRateService (The Backend)

  • Responsibility: Manages all external network communications.
  • Threading: Uses a daemon thread to fetch API data so the GUI never freezes ("ANR" prevention).
  • Timeout: Sets a strict 10s timeout for API requests with automatic error handling.

2. UI/UX Design System

The application uses a custom configured ttk.Style theme to ensure visual consistency:

  • Colors: Apple-style system colors (#007AFF for actions, #F2F2F7 for backgrounds).
  • Ticket Layout: The result area simulates a printed receipt for better readability.

💰 Core Pricing Algorithms

The pricing strategy is defined in calculate_all():

1. Currency Conversion

We use AUD as the base anchor.

  • Cross Rate = (1 / Source_Rate_to_AUD) * Target_Rate_to_AUD

2. Margin Application

A default safety margin is applied to all foreign imports:

  • CONFIG["DEFAULT_MARGIN"] = 0.15 (15% Markup)

3. Member vs. Standard

  • Member Price: Reflects the "True" converted cost plus margin.
    • Bonus: If Recommendation is checked, an extra 10% OFF is applied.
  • Standard Price: Uses a competitive benchmark algorithm anchored to CNY cross-rates (adjusted by factor 0.3) to prevent market underpricing.

⚠️ Error Handling

  • Offline Mode: If the socket connection fails (timeout > 3s), the app enters "Offline Mode" and alerts the user via the Status Bar.
  • Input Validation: The _validate_number callback ensures only valid float numbers can be entered into price fields.