Languages: English | Русский
Python service for managing email funnels for Testizer.com based on MySQL data and Brevo API integration.
- Automated Funnel Management: Automatically identifies test candidates and adds them to email funnels
- Brevo Integration: Seamless integration with Brevo API for contact management
- Purchase Tracking: Tracks certificate purchases and updates funnel analytics
- Conversion Analytics: Built-in reporting system for funnel conversion metrics
- Dry Run Mode: Safe testing without affecting production data
- Docker Support: Containerized deployment ready
- Comprehensive Testing: Full test coverage with pytest
- Python 3.11 or higher
- MySQL database access (MODX)
- Brevo API key
- Virtual environment (recommended)
- Clone the repository:
git clone git@github.com:AmaLS367/testizer_email_funnels.git
cd testizer_email_funnels- Create and activate virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install -r requirements.txt- Configure environment:
Copy-Item .env.example .env
# Edit .env with your database and Brevo credentials- Run the service:
python -m app.mainThe service can be run in Docker for easier deployment and consistency across environments.
docker build -t testizer-funnel-engine .docker run --rm --env-file .env testizer-funnel-engineFor detailed Docker usage instructions, see:
testizer_email_funnels/
├── app/ # Main application entry points
│ ├── main.py # Primary job orchestrator
│ └── report_conversions.py # Conversion reporting CLI
├── analytics/ # Analytics and tracking
│ ├── tracking.py # Funnel entry management
│ ├── reports.py # Report generation
│ └── report_service.py # Report service layer
├── brevo/ # Brevo API integration
│ ├── api_client.py # HTTP client for Brevo API
│ └── models.py # Brevo data models
├── config/ # Configuration management
│ └── settings.py # Settings loading from environment
├── db/ # Database layer
│ ├── connection.py # MySQL connection management
│ └── selectors.py # Database queries
├── funnels/ # Funnel business logic
│ ├── models.py # Domain models
│ ├── sync_service.py # Funnel synchronization
│ └── purchase_sync_service.py # Purchase tracking
├── logging_config/ # Logging setup
│ └── logger.py # Logging configuration
├── tests/ # Test suite
│ ├── analytics/ # Analytics tests
│ ├── app/ # Application tests
│ ├── brevo/ # Brevo integration tests
│ ├── config/ # Configuration tests
│ ├── db/ # Database tests
│ ├── funnels/ # Funnel tests
│ └── logging_config/ # Logging tests
├── docs/ # Documentation
│ ├── ru/ # Russian documentation
│ ├── en/ # English documentation
│ └── db_analytics_schema.sql # Database schema
├── Dockerfile # Docker image definition
├── .dockerignore # Docker ignore patterns
├── .flake8 # Flake8 configuration (deprecated, using Ruff)
├── pyproject.toml # Project configuration (black, mypy, pytest)
├── requirements.txt # Python dependencies
└── README.md # This file
mysql-connector-python==9.1.0- MySQL database connectivitypython-dotenv==1.0.1- Environment variable managementrequests==2.32.3- HTTP client for Brevo APIpytest==8.3.4- Testing frameworksentry-sdk==2.19.1- Error trackingruff- Fast Python linter (replaces flake8)mypy==1.19.0- Type checkingblack==25.11.0- Code formatting
Required variables in .env:
# Application
APP_ENV=development
APP_DRY_RUN=true
APP_LOG_LEVEL=INFO
# Database
DB_HOST=127.0.0.1
DB_PORT=3306
DB_USER=testizer_user
DB_PASSWORD=change_me
DB_NAME=testizer
DB_CHARSET=utf8mb4
# Brevo
BREVO_API_KEY=your_api_key_here
BREVO_BASE_URL=https://api.brevo.com/v3
BREVO_LANGUAGE_LIST_ID=0
BREVO_NON_LANGUAGE_LIST_ID=0
# Sentry (optional)
SENTRY_DSN=your_sentry_dsn_hereSee .env.example for the complete template.
- Operations Guide - Production deployment and operations
- Analytics Guide - Conversion metrics and reporting
- Docker Guide - Docker deployment instructions
- Deliverability Guide - Email deliverability best practices
- Scheduling Guide - Task scheduling recommendations
- Operations Guide - Production deployment and operations
- Analytics Guide - Conversion metrics and reporting
- Docker Guide - Docker deployment instructions
- Deliverability Guide - Email deliverability best practices
- Scheduling Guide - Task scheduling recommendations
- Analytics Schema -
funnel_entriestable definition
The project includes comprehensive test coverage using pytest.
python -m pytestTests are organized by module:
- Analytics: Funnel tracking and conversion reporting
- Application: Main entry points and CLI tools
- Brevo: API client and models
- Configuration: Settings loading
- Database: Connection and query tests
- Funnels: Synchronization and purchase tracking
- Logging: Configuration tests
The project uses several tools to maintain code quality:
- Black: Automatic code formatting
- Ruff: Fast Python linter
- MyPy: Static type checking
- Pytest: Test execution
Run all checks:
python -m ruff check .
python -m black . --check
python -m mypy .
python -m pytest -m "not integration"Continuous Integration is configured via GitHub Actions:
- Runs on push and pull requests to
main - Tests on Ubuntu and Windows
- Python 3.11 and 3.12
- Checks code formatting, style, types, and runs tests
See .github/workflows/ci.yml for details.
The project follows PEP 8 with Black formatting (88 character line length). Configuration is in pyproject.toml.
All code uses type hints for better maintainability and IDE support. MyPy is used for type checking.
Follow conventional commit format:
feat/: New featuresfix/: Bug fixesdocs/: Documentation changestest/: Test additions/changeschore/: Maintenance tasksops/: Operations/infrastructure
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Ensure all tests pass and code quality checks succeed
- Submit a pull request
For issues and questions, please open an issue on GitHub.