How cyy25121/auto-buy works
Project type and purpose
• This is a command-line automation tool (“AUTO BUY”) written in Python that uses Playwright to drive headless (or headed) browsers and automatically purchase items on multiple e-commerce platforms (MOMO, PC Home).
• It’s not a web front-end or a microservice: it’s a local CLI application with platform-specific modules and a core orchestration layer.
File structure
• Top-level files
• main.py – the CLI entrypoint (parses arguments, loads config, kicks off a purchase job)
• .env.example – template for environment variables (credentials, headless flag defaults)
• requirements.txt – Python dependencies (playwright, python-dotenv, pytest, etc.)
• README.md – project overview and usage
• buyer/ package
• base.py – defines the BaseBuyer abstract class and factory logic (Strategy/Factory pattern)
• momo.py – MomoBuyer implementation (login flow, add-to-cart, checkout selectors)
• pchome.py – PChomeBuyer implementation
• utils.py – helper routines (e.g. load .env, timestamp parsing, common error handling)
• tests/ – pytest fixtures and unit tests for BaseBuyer and other logic
README for additional insights
• Confirms use cases (CLI invocation, scheduling purchase, headless/headed browser)
• Emphasizes external dependencies (Playwright, network stability, anti-bot considerations)
Diagramming recommendations
• External entities “MOMO Website”, “PC Home Website” (grey clouds)
CLI → Config Loader → Factory → Buyer → Playwright → External Website
• Denote the Factory/Strategy boundary clearly so it’s obvious where new platforms plug in