Skip to main content

Dependency injection and layered architecture enforcement for Python projects

Project description

Frame 3(2)

archtool documentation

Преимущества

  • Dependency Injection - управление зависимостями между компонентами
  • Контроль слоёв - гарантия однонаправленных импортов
  • ISP Compliance - принудительное разделение интерфейсов
  • Мультиархитектура - поддержка Clean Architecture, ETL, микросервисов
  • Чёткое разделение между API эндпоинтами и бизнес-логикой
  • Автоматическая валидация зависимостей
  • Поддержка async/await
  • Интеграция с django и fast-api

Установка

pip install archtool

🌐 Framework Integration

Django Support

archtool помогает организовать Django-проекты в соответствии с Clean Architecture, упрощая:

  • Постепенный переход от монолитной структуры
  • Вынос бизнес-логики из views/forms
  • Интеграцию с современными решениями (FastAPI, AIOHTTP)

Пример структуры:

myproject/
├── archtool_bundle/            # django app, отвечающий за совместимость с archtool 
│   ├── interfaces.py
│   ├── controllers.py
│   ├── services.py
│   └── repos.py
├── app2/
│   ├── interfaces.py
│   ├── controllers.py
│   ├── services.py
│   └── repos.py
├── entrypoints/                  # точки входа в приложение
│   └── fastapi_app.py

Интеграция: документация в активной разработке

FastAPI Integration

Создавайте хорошо структурированные API с автоматическим DI: Документация в активной разработке


📚 Examples

Example Type Description
Django Migration examples/django_migration/
FastAPI Microservice examples/fastapi_service/



### Архитектурные слои
```python
# Clean Architecture (по Роберту Мартину)
class InfrastructureLayer(Layer):
    """Работа с БД, внешние API"""
    depends_on = None
    
    class Components:
        repos = ComponentPattern(
            module_name_regex="repos",
            superclass=ABCRepo
        )

class DomainLayer(Layer):
    """Ядро системы: модели и бизнес-логика"""
    depends_on = InfrastructureLayer
    
    class Components:
        services = ComponentPattern(
            module_name_regex="services",
            superclass=ABCService
        )

class ApplicationLayer(Layer):
    """Оркестрация workflow"""
    depends_on = DomainLayer
    
    class Components:
        controllers = ComponentPattern(
            module_name_regex="controllers",
            superclass=ABCController
        )

class PresentationLayer(Layer):
    """API и пользовательские интерфейсы"""
    depends_on = ApplicationLayer
    
    class Components:
        views = ComponentPattern(
            module_name_regex="views",
            superclass=ABCView
        )

Преимущества подхода

  1. Снижение связанности
    Изоляция слоёв через strict import rules (DIP)

  2. Тестируемость
    Легкое мокирование через DI-контейнер

  3. Гибкость архитектуры
    Кастомные слои для любых сценариев

  4. Валидация
    Автоматическая проверка правил импортов

  5. Документирование
    Явная структура проекта = живая документация

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

archtool-2.0.0.tar.gz (93.5 kB view details)

Uploaded Source

Built Distribution

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

archtool-2.0.0-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file archtool-2.0.0.tar.gz.

File metadata

  • Download URL: archtool-2.0.0.tar.gz
  • Upload date:
  • Size: 93.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for archtool-2.0.0.tar.gz
Algorithm Hash digest
SHA256 fc265fafdbeef185ce5af56f7099945e26702d5109bd3584f4e9b5390ae5ef45
MD5 a8c9e0f5422d321e340c14af983af1a6
BLAKE2b-256 10c5a86335dba2072eb2c2e4e95db71acad56ff7d6f908aee68d77d6a712e567

See more details on using hashes here.

File details

Details for the file archtool-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: archtool-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for archtool-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 747cfd230b0b6000729635f1b753d53c1f3d356dee9ad754c6adaa70e2a2cd7d
MD5 91044f676ae1aa48e89c393c0c1b7bb6
BLAKE2b-256 1e9da6f0cc792556a22378c6b1ccf9f4209e480d3a3da4d42d0fab1a6332cc99

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