Skip to main content

A Domain-Driven Design (DDD) programming package for Python, similar to zope.interface

Project description

FivcGlue

A Domain-Driven Design (DDD) programming package for Python, similar to zope.interface.

๐ŸŽฏ Overview

FivcGlue provides a clean and intuitive way to implement Domain-Driven Design patterns in Python applications. It offers interfaces and implementations for common DDD building blocks, helping you structure your code following DDD principles.

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.10 or higher
  • UV package manager (recommended) or pip

Installation

With UV (recommended):

# Install with development dependencies
make install

# Or minimal installation
make install-min

# With YAML support
uv sync --extra yaml

With pip:

# Basic installation
pip install -e .

# With YAML support
pip install -e ".[yaml]"

# With development dependencies
pip install -e ".[dev,yaml]"

๐Ÿ“ฆ Features

FivcGlue provides core DDD building blocks:

  • Interfaces: Define contracts for your domain components
  • Configurations: Flexible configuration management (JSON, YAML)
  • Caching: In-memory and Redis-based caching implementations
  • Logging: Built-in logging utilities
  • Mutexes: Distributed locking with Redis support

๐Ÿ’ป Usage

Basic Example

from fivcglue.interfaces import IConfig
from fivcglue.implements import YAMLFileConfig

# Load configuration from YAML file
config = YAMLFileConfig("config.yml")
value = config.get("key", default="default_value")

Configuration Management

from fivcglue.implements import JSONFileConfig, YAMLFileConfig

# JSON configuration
json_config = JSONFileConfig("settings.json")

# YAML configuration (requires PyYAML)
yaml_config = YAMLFileConfig("settings.yml")

Caching

from datetime import timedelta
from fivcglue.implements.caches_mem import CacheImpl as MemoryCacheImpl
from fivcglue.implements.caches_redis import CacheImpl as RedisCacheImpl

# In-memory cache
cache = MemoryCacheImpl(_component_site=None, max_size=10000)
cache.set_value("key", b"value", expire=timedelta(hours=1))
value = cache.get_value("key")

# Redis cache (requires redis package)
redis_cache = RedisCacheImpl(_component_site=None, host="localhost", port=6379)
redis_cache.set_value("key", b"value", expire=timedelta(hours=1))

๐Ÿ“ Project Structure

src/fivcglue/
โ”œโ”€โ”€ interfaces/      # Interface definitions
โ”‚   โ”œโ”€โ”€ configs.py   # Configuration interfaces
โ”‚   โ”œโ”€โ”€ caches.py    # Cache interfaces
โ”‚   โ”œโ”€โ”€ loggers.py   # Logger interfaces
โ”‚   โ””โ”€โ”€ mutexes.py   # Mutex interfaces
โ”œโ”€โ”€ implements/      # Concrete implementations
โ”‚   โ”œโ”€โ”€ configs_jsonfile.py
โ”‚   โ”œโ”€โ”€ configs_yamlfile.py
โ”‚   โ”œโ”€โ”€ caches_mem.py
โ”‚   โ”œโ”€โ”€ caches_redis.py
โ”‚   โ”œโ”€โ”€ loggers_builtin.py
โ”‚   โ””โ”€โ”€ mutexes_redis.py
โ””โ”€โ”€ fixtures/        # Test fixtures

๐Ÿ› ๏ธ Development

Available Make Commands

make help        # Show all available commands
make install     # Install with dev dependencies
make install-min # Install minimal dependencies
make dev         # Install development dependencies
make lint        # Run code linting
make format      # Format code
make test        # Run tests
make test-cov    # Run tests with coverage
make clean       # Clean temporary files
make build       # Build distribution packages

Running Tests

# Run all tests
make test

# Run with coverage
make test-cov

# Run specific test file
uv run pytest tests/test_configs.py -v

Code Quality

# Lint code
make lint

# Format code
make format

๐Ÿ“š Documentation

For more detailed documentation, see the docs/ directory:

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Development Setup

  1. Clone the repository
  2. Install dependencies: make install
  3. Run tests: make test
  4. Format code: make format
  5. Run linting: make lint

๐Ÿ“„ License

MIT License - see LICENSE file for details

๐Ÿ”— Links

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

fivcglue-0.1.5.tar.gz (38.4 kB view details)

Uploaded Source

Built Distribution

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

fivcglue-0.1.5-py3-none-any.whl (34.3 kB view details)

Uploaded Python 3

File details

Details for the file fivcglue-0.1.5.tar.gz.

File metadata

  • Download URL: fivcglue-0.1.5.tar.gz
  • Upload date:
  • Size: 38.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.10

File hashes

Hashes for fivcglue-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b5f5fec853f0ef98ee637a13059e8425f4d0aa03ced497b6e5808e691a27ea18
MD5 55671e2553dc002e3b1c3c581d080e23
BLAKE2b-256 c65893b1c42f3c6827cc6cff27c81ed28453cd2e084209938b9be174f8a0cb6b

See more details on using hashes here.

File details

Details for the file fivcglue-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: fivcglue-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 34.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.10

File hashes

Hashes for fivcglue-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 66b72c5955bd6a8676f2cb6b2c2540ed4bc7b4ebae0a464b045b5753bd02471b
MD5 92d82b44c6126f49267aad145efe707b
BLAKE2b-256 68dbcdf624bdb44c20f5c354e55fb9f72f79a9160fc7f7480317113395c0b3cf

See more details on using hashes here.

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