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.1.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.1-py3-none-any.whl (70.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dtpyappframework-4.4.1.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.1.tar.gz
Algorithm Hash digest
SHA256 c256db753592667591e1c0406b233219c3a48a933ed1864aae619b2d899c904a
MD5 85460c3db69c81727540cae78ed654c7
BLAKE2b-256 ca2f31d727dca1fca6c628d9867cd9c6da25dab9b6fb24cf4ad87b912ea28a0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtpyappframework-4.4.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dtpyappframework-4.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 34a2d590df2fe0750f601998a9df922b2537ff956de943fb57cbd56cd8a40951
MD5 91779f578e6f26299b5a419a6f517510
BLAKE2b-256 4fcf4c89c1952313221f0e6b663a97d8ab89ec6dcac50682848c8c2577202af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for dtpyappframework-4.4.1-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