How okanaslan/amazon-purchase-bot works
Main Components
• Entry Point: The core of the application resides in src/app.ts, which begins the program’s execution.
• Configuration Module: src/config.ts reads environment variables and other settings (from .env) and sets parameters such as URL, maximum price, and seller specifications.
• Controllers: For instance, src/controllers/purchaseController.ts serves as the business logic layer that handles the purchase process.
• Utilities: Tools in src/utils (like seleniumUtils.ts) encapsulate interactions with external tools/services—in this case, Selenium and ChromeDriver.
• Types: The src/types.ts file defines shared TypeScript types used across the project.
• Testing: The test directory (and its subdirectories) with Jest configurations and tests like test/controllers/purchaseController.test.ts for validating functionality.
• External Service: ChromeDriver (downloaded from https://chromedriver.chromium.org/downloads) acts as an external dependency to drive browser interactions.
Relationships and Interactions
• The application starts at app.ts, which loads configuration settings from config.ts.
• The purchase controller (purchaseController.ts) encapsulates the main automation logic; it is likely invoked by app.ts.
• The purchase controller makes calls to utilities in seleniumUtils.ts to interact with the ChromeDriver and automate browser actions.
• The testing modules in the test directory mimic or simulate this control flow to verify that the automation operates as expected.
Architectural Patterns and Important Components
• Separation of Concerns: The project distinguishes between configuration (config.ts), control logic (purchaseController.ts), and utility operations (seleniumUtils.ts).
• Modular Design: Each module resides in its own file or directory, which makes it easier to extend or interchange components.
• Automated Testing: The project includes Jest configurations and tests, emphasizing a test-driven development or continuous integration approach.
• External Dependency Integration: The use of ChromeDriver as a dependency indicates that integration with external services (i.e., browser automation) is a key part of the system.