System Design
Learn English by Picture - Python Automation Tool Design & Specification
1. System Overview
1.1 Core Functionality
An automated Python tool that:
Navigates through the specific AnyFlip book (https://anyflip.com/pwubx/ntxc/basic)
Extracts images from each page automatically
Uploads images to Perplexity AI
Generates learning content (drama dialogues) via AI
Saves images and AI responses to organized file paths
1.2 Target Workflow
text
AnyFlip Book → Page Navigation → Image Extraction → Perplexity Upload → AI Generation → File Storage
2. Technical Architecture
2.1 Core Components
text
┌─────────────────────────────────────────────────────────────────┐
│ Python Automation Tool │
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ AnyFlip │ │ Image │ │ Perplexity │ │
│ │ Controller │ │ Processor │ │ AI Client │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
├─────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ File │ │ Logging & │ │ Error │ │
│ │ Manager │ │ Monitoring │ │ Handler │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────────┘
2.2 Technology Stack
Python 3.8+ with async support
Selenium WebDriver for AnyFlip automation
Requests/httpx for Perplexity API integration
Pillow (PIL) for image processing
SQLite/JSON for data storage
Logging for operation tracking
3. Detailed Specification
3.1 AnyFlip Controller Module
python
class AnyFlipController:
- Navigate to: https://anyflip.com/pwubx/ntxc/basic
- Handle Google login authentication
- Page navigation (next/previous, specific page numbers)
- Extract page images (screenshot or element capture)
- Monitor page loading states
- Handle AnyFlip UI interactions
Key Operations:
Page Navigation: Automatic progression through 131 pages
Image Capture: Extract clean page images without UI elements
Content Detection: Identify vocabulary sections and visual content
Error Recovery: Handle network issues, page loading delays
3.2 Image Processor Module
python
class ImageProcessor:
- Clean captured images (remove UI elements)
- Optimize image quality and format
- Generate unique filenames (page_number_content_type.jpg)
- Validate image integrity
- Prepare images for Perplexity upload
3.3 Perplexity AI Client Module
python
class PerplexityClient:
- Authenticate with Perplexity (Google account)
- Upload images automatically
- Generate standardized prompts for vocabulary extraction
- Retrieve AI-generated drama dialogues
- Handle rate limiting and API responses
- Parse and structure AI responses
Standardized Prompt Template:
text
"I want to have a more practical practice to learn English.
I provide an image with many vocabulary on it.
Please create a funny and creative drama with dialogs which will include all the vocabulary.
Please especially highlight these key vocabulary in the image."
3.4 File Manager Module
python
class FileManager:
- Create organized directory structure
- Save images with metadata
- Store AI responses with image mappings
- Generate progress reports
- Handle file naming conflicts
- Create backup and recovery systems
Directory Structure:
text
Learn_English_by_Picture/
├── images/
│ ├── page_001_family/
│ ├── page_002_body/
│ └── ...
├── ai_responses/
│ ├── page_001_family_drama.json
│ ├── page_002_body_drama.json
│ └── ...
├── metadata/
│ ├── page_mapping.json
│ └── progress_tracker.json
└── logs/
└── automation_log.txt
4. Configuration & Settings
4.1 User Configuration
yaml
# config.yaml
anyflip:
url: "https://anyflip.com/pwubx/ntxc/basic"
total_pages: 131
navigation_delay: 2.0
image_capture_delay: 1.5
perplexity:
prompt_template: "standard_vocabulary_drama.txt"
rate_limit_delay: 3.0
max_retries: 3
storage:
base_path: "./Learn_English_by_Picture"
image_format: "jpg"
backup_enabled: true
4.2 Error Handling & Recovery
Network Issues: Automatic retry with exponential backoff
Page Loading: Wait for content to fully load
API Limits: Respect Perplexity rate limits
File System: Handle disk space and permission issues
Session Management: Maintain login states across operations
5. User Interface & Control
5.1 Command Line Interface
bash
# Start automation
python learn_english_bot.py --start --from-page 1 --to-page 131
# Resume from specific page
python learn_english_bot.py --resume --from-page 45
# Check progress
python learn_english_bot.py --status
# Test specific page
python learn_english_bot.py --test-page 10
5.2 Progress Monitoring
Real-time Progress: Current page, images captured, AI responses received
Error Logging: Detailed logs for troubleshooting
Statistics: Success rate, processing time, file sizes
Resume Capability: Continue from last successful operation
6. Implementation Phases
Phase 1: Core Infrastructure
Basic AnyFlip navigation
Image capture functionality
File management system
Error handling framework
Phase 2: Perplexity Integration
AI client implementation
Prompt management
Response parsing
Rate limiting
Phase 3: Advanced Features
Batch processing optimization
Progress tracking and reporting
Configuration management
User interface improvements
7. Security & Best Practices
7.1 Authentication Management
Secure storage of login credentials
Session token management
Automatic re-authentication
Rate limiting compliance
7.2 Data Privacy
Local storage only (no external data transmission)
Secure credential handling
Log file sanitization
Backup encryption
8. Testing & Validation
8.1 Test Scenarios
Single page processing
Multi-page batch processing
Error condition handling
Recovery and resume functionality
Performance benchmarking
8.2 Quality Assurance
Image quality validation
AI response consistency
File integrity checks
Progress tracking accuracy
Does this design meet your requirements?
The tool will:
✅ Work with your specific AnyFlip book URL
✅ Automate the entire workflow (AnyFlip → Image → Perplexity → AI → Storage)
✅ Generate drama dialogues via Perplexity
✅ Save organized files with proper mapping
✅ Handle errors and provide recovery options
✅ Give you full control over the automation process
Next Steps:
Confirm this design meets your needs
I'll start implementing the core modules
We can test with a few pages first
Then scale to the full 131-page automation
Would you like me to proceed with the implementation, or do you have any modifications to this design?