Skip to main content

A Python library for common features in application development.

Project description

dtPyAppFramework

License Python 3.10+

Quality Gate Status Security Rating Reliability Rating Maintainability Rating Vulnerabilities Bugs

dtPyAppFramework is a comprehensive Python framework library designed as the foundation for creating robust Python applications. It provides enterprise-grade features including layered configuration management, multi-cloud secrets storage, advanced multi-processing task management, sophisticated logging with nested support for spawned processes, singleton pattern utilities, and application path management.

๐Ÿš€ Key Features

  • ๐Ÿณ Container Mode: Full containerization support with --container flag for Docker, Kubernetes, and container orchestration
  • โš™๏ธ Layered Configuration: Multi-tier configuration system with working directory, user, and system-level settings
  • ๐Ÿ” Multi-Cloud Secrets: Seamless integration with AWS Secrets Manager, Azure Key Vault, and local encrypted storage
  • ๐Ÿ“ฑ AbstractApp Foundation: Complete application framework with command-line parsing, logging, and lifecycle management
  • ๐Ÿ”„ Advanced Multiprocessing: Process spawning, task coordination, and nested logging for parallel execution
  • ๐Ÿ“ Sophisticated Logging: Cross-process synchronized logging with color coding and automatic rotation
  • ๐Ÿ›ก๏ธ Security Framework: Comprehensive validation, encryption, and secure file handling
  • ๐Ÿ“ Path Management: Automatic application directory structure and resource management
  • ๐Ÿ”ง Singleton Utilities: Thread-safe singleton pattern implementation with parameter support

๐Ÿ“ฆ Installation

From PyPI (Future)

pip install dtPyAppFramework

Development Installation

# Clone the repository
git clone <repository-url>
cd dtPyAppFramework

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install in development mode
pip install -e .

๐Ÿ Quick Start

Basic Application

Create a simple application using the AbstractApp foundation:

from dtPyAppFramework.application import AbstractApp
import logging

class MyApplication(AbstractApp):
    def define_args(self, arg_parser):
        """Define custom command-line arguments"""
        arg_parser.add_argument('--task', default='hello', 
                              help='Task to perform')

    def main(self, args):
        """Main application logic"""
        logging.info(f"Running task: {args.task}")
        
        # Access configuration
        app_name = self.settings.get('app.name', 'MyApp')
        logging.info(f"Application: {app_name}")
        
        # Your application logic here
        
# Create and run the application
if __name__ == "__main__":
    app = MyApplication(
        description="My Sample Application",
        version="1.0.0",
        short_name="my-app",
        full_name="My Sample Application",
        console_app=True
    )
    app.run()

Container Mode

For containerized deployments (Docker, Kubernetes):

# Enable container mode with simplified directory structure
app.run()  # Use --container flag or set CONTAINER_MODE=true

# Or detect container environment automatically
if os.path.exists('/.dockerenv'):
    os.environ['CONTAINER_MODE'] = 'True'

๐Ÿ”ง Core Framework Components

๐Ÿณ Container Mode

Full support for containerized deployments with simplified directory structure:

  • Simplified Paths: All directories (config/, data/, logs/, temp/) in working directory
  • Single Config Layer: No multi-tier configuration in container mode
  • Environment Detection: Automatic detection of Docker/Kubernetes environments
  • Volume Mounting: Designed for persistent volume mounting
# Enable container mode
python app.py --container
# or
export CONTAINER_MODE=true && python app.py

โš™๏ธ Layered Configuration Management

Multi-tier configuration system with automatic merging:

  • Working Directory: ./config/config.yaml
  • User Level: User-specific configurations
  • System Level: System-wide configurations (standard mode only)
# config.yaml example
app:
  name: "MyApp"
  debug: false
secrets:
  azure:
    vault_url: "https://vault.vault.azure.net/"
logging:
  level: "INFO"
  console_colors: true

๐Ÿ” Multi-Cloud Secrets Management

Unified interface for multiple secret storage backends:

  • AWS Secrets Manager: Full boto3 integration
  • Azure Key Vault: azure-keyvault-secrets support
  • Local Encrypted Storage: cryptography-based local secrets
  • Environment Variables: SEC/ prefix resolution
# Usage example
settings = Settings()
api_key = settings.get('SEC/api_key', 'default-key')
settings.secret_manager.set_secret('db_password', 'secret123')

๐Ÿ“ Advanced Logging System

Sophisticated logging with cross-process support:

  • Nested Logging: Each spawned process gets its own namespace
  • Color Coding: Console output with colorlog integration
  • Log Rotation: Automatic file rotation and management
  • Cross-Process Sync: Synchronized logging between parent/child processes

๐Ÿ”„ Multiprocessing Framework

Advanced process management and task coordination:

  • Process Spawning: Managed subprocess creation with psutil
  • Task Coordination: Process pool management and task distribution
  • Resource Monitoring: Memory and CPU usage tracking
  • Cleanup Handling: Automatic process cleanup and resource management

๐Ÿ›ก๏ธ Security Features

Comprehensive security framework:

  • File Validation: Secure file operations and path validation
  • Encryption: Local secret encryption with cryptography
  • Access Control: Platform-specific permission handling
  • Error Handling: Secure error reporting without information leakage

๐Ÿ“š Samples and Examples

Comprehensive samples are available in the ./samples/ directory:

Each sample includes detailed README documentation with setup instructions, usage examples, and best practices.

๐Ÿ—๏ธ Project Structure

dtPyAppFramework/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ dtPyAppFramework/           # Main framework source
โ”‚       โ”œโ”€โ”€ application.py          # AbstractApp base class
โ”‚       โ”œโ”€โ”€ paths/                  # Application path management
โ”‚       โ”œโ”€โ”€ settings/               # Configuration and secrets
โ”‚       โ”œโ”€โ”€ security/               # Security framework
โ”‚       โ”œโ”€โ”€ logging/                # Advanced logging system
โ”‚       โ”œโ”€โ”€ decorators/             # Singleton and utilities
โ”‚       โ”œโ”€โ”€ process/                # Multiprocessing framework
โ”‚       โ””โ”€โ”€ resources/              # Resource management
โ”œโ”€โ”€ samples/                        # Usage examples
โ”œโ”€โ”€ tests/                          # Comprehensive test suite
โ”œโ”€โ”€ docs/                           # Documentation (RST format)
โ””โ”€โ”€ requirements.txt                # Core dependencies

๐Ÿ”ง Development

Running Tests

# Run full test suite
pytest

# Run with coverage
pytest --cov=src/dtPyAppFramework

# Watch mode for development
pytest-watch

Core Dependencies

PyYAML~=6.0.2                     # Configuration parsing
colorlog~=6.9.0                   # Console color coding
psutil~=6.1.0                     # Process management
cryptography~=44.0.0              # Local encryption
boto3~=1.35.54                    # AWS integration
azure-identity                    # Azure authentication
azure-keyvault-secrets            # Azure Key Vault
pytest~=8.3.3                     # Testing framework
InquirerPy                        # Interactive CLI prompts

๐Ÿ“– Documentation

๐Ÿค Contributing

We welcome contributions! Please see our contributing guidelines for:

  • Code style and standards (Python 3.12+)
  • Testing requirements (pytest with full coverage)
  • Documentation standards (RST format)
  • Sample creation guidelines

๐Ÿ“„ License

This project is licensed under the MIT License.

๐Ÿ“ง Support

For questions, bug reports, or feature requests:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dtpyappframework-4.4.0.tar.gz (116.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dtpyappframework-4.4.0-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

Details for the file dtpyappframework-4.4.0.tar.gz.

File metadata

  • Download URL: dtpyappframework-4.4.0.tar.gz
  • Upload date:
  • Size: 116.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dtpyappframework-4.4.0.tar.gz
Algorithm Hash digest
SHA256 57b915b1175a3b403427a0ada24abb8f0fcad5d55775a4a756016af4b9298dfd
MD5 08b7b33a590c8273b3a7c5e4a7c47f73
BLAKE2b-256 bc8a05136bf9a40e4d0463a7826d76f283493ab56464887b3c13e5ead8acb618

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtpyappframework-4.4.0.tar.gz:

Publisher: publish-to-pypi.yml on Digital-Thought/dtPyAppFramework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dtpyappframework-4.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dtpyappframework-4.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ae486a8b2df7d32a95fa2eedd9a8aa11861201f0750c2dc9ea3aaccaf92b804
MD5 08bbfb6097ce9d0a0859533c34c1c9a4
BLAKE2b-256 aee61d9c02665aa76af4dcf14e05351e84512c8940d014fb4d107ec56771548f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtpyappframework-4.4.0-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Digital-Thought/dtPyAppFramework

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page