Flex Toolkit is a comprehensive Python command-line interface (CLI) tool and library that provides a powerful collection of utilities for modern development workflows. From cloud storage management to media processing, authentication, and data handling, FlexTK streamlines complex tasks with an intuitive interface and extensive feature set.
- Firebase Authentication: Complete user management with email/password, phone number authentication
- Token Management: JWT token encoding/decoding and validation
- Secure Configuration: Encrypted configuration storage with password protection
- Multi-Provider Support: Google Cloud Storage, BlackBlaze B2, AWS S3
- Google Drive Integration: Full API support for file upload/download, folder management, permissions
- Firestore Database: Complete Firestore operations with document CRUD operations
- Stripe Integration: Payment intent creation, confirmation, and management
- Secure Transactions: Built-in error handling and logging for payment operations
- Image Processing: Advanced computer vision capabilities with OpenCV
- Face detection using YOLO and SCRFD models
- Person detection with configurable confidence thresholds
- Image conversion, rotation, resizing, and grayscale conversion
- Unsplash API integration for image search and download
- Video Processing: FFmpeg-powered video operations
- Format conversion (MP4, AVI, MOV, MKV, TS)
- Video trimming, cutting, and frame extraction
- Metadata extraction and video analysis
- Audio Processing: Comprehensive audio manipulation
- Format conversion (MP3, WAV, OGG, FLAC, M4A)
- Audio trimming, cutting, and joining
- Metadata extraction and audio analysis
- LibreOffice Integration: Document conversion and processing
- PDF Operations: Document format conversion
- Excel/CSV Handling: Data processing with Pandas integration
- File Operations: Advanced file handling and manipulation
- Network Utilities: HTTP request handling and API interactions
- Schema Validation: Pydantic-based data validation and serialization
- Logging System: Structured JSON logging with configurable levels
- Auto-Installation: Automatic installation of required dependencies (FFmpeg, ImageMagick, LibreOffice)
- Cross-Platform: Support for Windows, macOS, and Linux
- Package Managers: Integration with Chocolatey (Windows) and Homebrew (macOS)
- Python 3.12+
- Poetry (for dependency management)
git clone https://github.com/eslam5464/FlexTK.git
cd FlexTK
pip install poetry
poetry install
poetry shellpip install .# View available commands
flextk --help
# Configure cloud storage
flextk config gcs --bucket_name your-bucket --service_account path/to/service-account.json
# Upload file to Google Cloud Storage
flextk cloud gcs upload-file --file_path local/file.txt --bucket_path remote/path/
# Configure BlackBlaze B2
flextk config bb2 --app_id your-app-id --app_key your-app-keyfrom lib.utils.media.image import ImageProcessingOpenCV
# Initialize image processor
processor = ImageProcessingOpenCV("path/to/image.jpg")
# Detect faces with YOLO
processor.detect_faces_yolo(
output_dir="output/",
confidence_threshold=0.5,
save_individual_faces=True
)
# Detect persons
processor.detect_persons(
output_dir="output/",
save_individual_persons=True
)
# Apply transformations
processor.resize_image(800, 600).convert_to_grayscale().save_image("output/processed.jpg")from lib.storage.buckets.gcs import GCS
from lib.schemas.google_bucket import ServiceAccount
# Initialize Google Cloud Storage
gcs = GCS("bucket-name", "path/to/service-account.json")
# Upload file
gcs.upload_file("local/file.txt", "remote/path/file.txt")
# Download file
gcs.download_file("remote/path/file.txt", "local/downloaded.txt")
# List files
files = gcs.get_files("folder/path/")from lib.auth.firebase import Firebase, FirebaseAuth
from lib.schemas.firebase import FirebaseServiceAccount
# Initialize Firebase
service_account = FirebaseServiceAccount.model_validate(service_account_dict)
firebase = Firebase(service_account)
# Get user by email
user = firebase.get_user_by_email("user@example.com")
# Send notification
firebase.notify_a_device("device_token", "Title", "Message content")
# Authentication
auth = FirebaseAuth("web_api_key")
response = auth.sign_in_email_and_password("email@example.com", "password")from lib.utils.converters.video import convert_video_ffmpeg
from lib.utils.converters.audio import convert_audio_ffmpeg
from lib.utils.media.video import SupportedVideoFormat
from lib.utils.media.audio import SupportedAudioFormat
# Convert video
convert_video_ffmpeg(
"input.avi",
"output/",
SupportedVideoFormat.mp4
)
# Convert audio
convert_audio_ffmpeg(
"input.wav",
"output/",
SupportedAudioFormat.mp3
)flextk/
βββ cli/ # Command-line interface
β βββ cloud_storage/ # Cloud storage commands
β βββ configuration.py # Configuration management
βββ core/ # Core functionality
β βββ config.py # Configuration handling
β βββ helpers.py # Helper functions
β βββ schema.py # Core schemas
βββ lib/ # Main library
β βββ auth/ # Authentication modules
β β βββ firebase.py # Firebase authentication
β βββ payment_gateway/ # Payment processing
β β βββ stripe.py # Stripe integration
β βββ schemas/ # Data validation schemas
β βββ storage/ # Storage providers
β β βββ buckets/ # Cloud bucket implementations
β β βββ firestore.py # Firestore operations
β β βββ google_drive.py # Google Drive integration
β βββ utils/ # Utility modules
β β βββ apps/ # Application management
β β βββ converters/ # Media converters
β β βββ media/ # Media processing
β β βββ operating_systems/ # OS-specific utilities
β βββ wrappers/ # Application wrappers
βββ flex_tk.py # Main CLI entry point
# Set master password for configuration encryption
flextk config set-password
# Configure Google Cloud Storage
flextk config gcs \
--bucket_name your-bucket-name \
--service_account /path/to/service-account.json
# Configure BlackBlaze B2
flextk config bb2 \
--app_id your-app-id \
--app_key your-app-key
# Configure Unsplash API
flextk config unsplash \
--app_id your-app-id \
--access_key your-access-key \
--secret_key your-secret-key- MP4, AVI, MOV, MKV, TS
- MP3, WAV, OGG, FLAC, M4A
- JPEG, PNG, BMP, TIFF, WebP
- Google Cloud Storage
- BlackBlaze B2
- AWS S3
- Google Drive
- YOLO Models: Multiple YOLO versions for face and person detection
- SCRFD Models: State-of-the-art face detection
- Confidence Thresholds: Configurable detection sensitivity
- Batch Processing: Process multiple images efficiently
- Automatic Download: Models downloaded on first use
- Caching: Local model caching for performance
- Multiple Backends: Support for different AI frameworks
- Structured Logging: JSON-formatted logs with metadata
- Multiple Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
- File Rotation: Automatic log file management
- Custom Formatters: Extensible logging configuration
- Custom Exceptions: Domain-specific error types
- Retry Logic: Automatic retry for transient failures
- Graceful Degradation: Fallback mechanisms for failed operations
- Async Operations: Non-blocking I/O for better performance
- Batch Processing: Efficient handling of multiple files
- Memory Management: Optimized memory usage for large files
- Progress Tracking: Real-time progress for long operations
- Operating System: Windows 10+, macOS 10.15+, or Linux (Ubuntu 18.04+)
- Python: 3.12 or higher
- Memory: 4GB RAM minimum (8GB recommended for AI features)
- Storage: 2GB free space (additional space for models and cache)
FlexTK can automatically install these tools when needed:
- FFmpeg: For video/audio processing
- ImageMagick: For advanced image operations
- LibreOffice: For document conversion
- Git: For version control operations
- Encryption: All configuration data is encrypted using Fernet (AES 128)
- Token Management: Secure handling of authentication tokens
- API Keys: Safe storage and transmission of API credentials
- Input Validation: Comprehensive validation using Pydantic schemas
- Use environment variables for sensitive configuration
- Regularly rotate API keys and tokens
- Enable logging for audit trails
- Use secure connections (HTTPS) for all API calls
class ImageProcessingOpenCV:
def __init__(self, image_path: str)
def detect_faces_yolo(self, output_dir: str = None, **kwargs) -> Self
def detect_persons(self, output_dir: str = None, **kwargs) -> Self
def resize_image(self, width: int, height: int) -> Self
def convert_to_grayscale(self) -> Self
def save_image(self, image_path: str) -> Selfclass GCS:
def __init__(self, bucket_name: str, service_account: str)
def upload_file(self, file_path: str, bucket_folder_path: str) -> BucketFile
def download_file(self, bucket_file_path: str, download_directory: str) -> None
def get_files(self, bucket_folder_path: str = "") -> list[BucketFile]
def delete_files(self, file_paths: list[str]) -> Noneclass Firebase:
def __init__(self, service_account: FirebaseServiceAccount)
def get_user_by_email(self, email: str) -> UserRecord
def notify_a_device(self, device_token: str, title: str, content: str) -> bool
def notify_multiple_devices(self, device_tokens: list[str], title: str, content: str) -> int# Install test dependencies
poetry install --with dev
# Run all tests
pytest
# Run with coverage
pytest --cov=lib --cov-report=html
# Run specific test file
pytest tests/test_media_processing.py
# Run tests with verbose output
pytest -vtests/
βββ unit/ # Unit tests
β βββ test_media/ # Media processing tests
β βββ test_storage/ # Storage provider tests
β βββ test_auth/ # Authentication tests
βββ integration/ # Integration tests
βββ fixtures/ # Test data and fixtures
βββ conftest.py # Test configuration
- Batch Processing: Process multiple files simultaneously
- Memory Management: Efficient handling of large media files
- Model Caching: Cache AI models locally to avoid re-downloading
- Parallel Processing: Utilize multiple CPU cores for intensive operations
- Connection Pooling: Reuse connections for multiple operations
- Retry Logic: Automatic retry with exponential backoff
- Chunked Uploads: Handle large files efficiently
- Compression: Optimize transfer sizes
FlexTK supports custom plugins for extending functionality:
# Custom media processor
from lib.utils.media.base import BaseMediaProcessor
class CustomImageProcessor(BaseMediaProcessor):
def process(self, input_path: str, output_path: str) -> None:
# Your custom processing logic
pass# Custom configuration schema
from lib.schemas.base import BaseSchema
class CustomConfig(BaseSchema):
api_endpoint: str
timeout: int = 30
retries: int = 3FlexTK provides comprehensive logging capabilities:
from lib.logger import configure_logging
# Configure logging
configure_logging(level="INFO", format="json")
# Use in your code
import logging
logger = logging.getLogger(__name__)
logger.info("Operation completed", extra={"file_count": 10})- Processing Times: Track operation duration
- Success Rates: Monitor API call success rates
- Error Tracking: Detailed error reporting with stack traces
- Resource Usage: Monitor memory and CPU usage
We welcome contributions to FlexTK! Here's how you can help:
# Fork and clone the repository
git clone https://github.com/eslam5464/FlexTK.git
cd FlexTK
# Install development dependencies
poetry install --with dev
# Install pre-commit hooks
pre-commit install
# Run tests to ensure everything works
pytest- Fork the Project: Create your own fork of the repository
- Create a Feature Branch:
git checkout -b feature/AmazingFeature - Write Tests: Ensure your code is well-tested
- Follow Code Style: Use Black for formatting and isort for imports
- Update Documentation: Update README and docstrings as needed
- Commit Your Changes:
git commit -m 'Add some AmazingFeature' - Push to the Branch:
git push origin feature/AmazingFeature - Open a Pull Request: Submit your changes for review
- Code Formatting: Use
blackandisort - Type Hints: Add type hints to all functions
- Documentation: Write clear docstrings
- Testing: Maintain >90% test coverage
- Performance: Consider performance implications
- π Bug Fixes: Help identify and fix issues
- π New Features: Add new cloud providers or media formats
- π Documentation: Improve examples and guides
- π§ͺ Testing: Increase test coverage
- π§ Performance: Optimize existing functionality
- π Localization: Add support for more languages
Distributed under the MIT License. See LICENSE file for more information.
Eslam Mohamed - LinkedIn
Project Link: GitHub Repository
Documentation: Wiki
Issues: Bug Reports & Feature Requests
- OpenAI: For inspiring AI integration patterns
- Google: For comprehensive cloud APIs
- FFmpeg: For excellent media processing capabilities
- Ultralytics: For YOLO model implementations
- Firebase: For authentication and database services
- Stripe: For payment processing integration
- The Open Source Community: For continuous inspiration and support