{"id":21879131,"url":"https://github.com/miguelteixeiraa/crinkle","last_synced_at":"2026-03-07T10:31:43.681Z","repository":{"id":211502795,"uuid":"727022366","full_name":"miguelteixeiraa/crinkle","owner":"miguelteixeiraa","description":"Crinkle is a framework for organizing the execution of complex processing flows by implementing the “Chain of Responsability” pattern in Python","archived":false,"fork":false,"pushed_at":"2024-03-11T22:13:10.000Z","size":108,"stargazers_count":11,"open_issues_count":3,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-07T05:13:57.595Z","etag":null,"topics":["apache-commons","async","asyncio","chain-of-responsibility-pattern","framework","function-composition","opinionated","pydantic","python","python-types","python3","simple","type-safe","typehints","types"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/miguelteixeiraa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-12-04T02:41:59.000Z","updated_at":"2024-12-30T22:28:49.000Z","dependencies_parsed_at":"2025-04-15T03:07:12.824Z","dependency_job_id":"6d4844c8-4c4e-4370-9f4a-35539448cc0d","html_url":"https://github.com/miguelteixeiraa/crinkle","commit_stats":null,"previous_names":["miguelteixeiraa/crinkle"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/miguelteixeiraa/crinkle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelteixeiraa%2Fcrinkle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelteixeiraa%2Fcrinkle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelteixeiraa%2Fcrinkle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelteixeiraa%2Fcrinkle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/miguelteixeiraa","download_url":"https://codeload.github.com/miguelteixeiraa/crinkle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/miguelteixeiraa%2Fcrinkle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30212048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-commons","async","asyncio","chain-of-responsibility-pattern","framework","function-composition","opinionated","pydantic","python","python-types","python3","simple","type-safe","typehints","types"],"created_at":"2024-11-28T08:15:21.526Z","updated_at":"2026-03-07T10:31:43.648Z","avatar_url":"https://github.com/miguelteixeiraa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"./assets/crinkle.png\" alt=\"Crinkle Icon\" width=70\u003e\n\u003ch3 align=\"center\"\u003eCrinkle\u003c/h3\u003e\n\u003cp align=\"center\"\u003e\u003cstrong\u003eCrinkle\u003c/strong\u003e is a framework for organizing the execution of complex processing flows by implementing the “Chain of Responsability” pattern (🔋included).\u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://securityscorecards.dev/viewer/?uri=github.com/miguelteixeiraa/crinkle\"\u003e\n    \u003cimg src=\"https://api.securityscorecards.dev/projects/github.com/miguelteixeiraa/crinkle/badge\" alt=\"OpenSSF Scorecard\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"./assets/coverage.svg\" alt=\"Coverage\"\u003e\n  \u003cimg src=\"https://github.com/miguelteixeiraa/crinkle/actions/workflows/lint-and-format.yaml/badge.svg\" alt=\"Lint and Format\"\u003e\n  \u003cimg src=\"https://github.com/miguelteixeiraa/crinkle/actions/workflows/tests.yaml/badge.svg\" alt=\"Tests\"\u003e\n\u003c/p\u003e\n\n**Merchan**:\n\n- **Minimalist**: Translate complex computational requirements into simple, yet elegant. _and less_ code.\n- **Grow large**: Grow large while keep everything maintainable and fast\n- **Empower testability**: Make things more testable by breaking large processes into small, specialized pieces with composition.\n- **Opinionated Yet Intuitive**: Quickly understand and work with.\n\n---\n\n\u003e 💡 Inspired by [Apache Commons Chain](https://www.baeldung.com/apache-commons-chain)\n\n## Requirements\n\nA recent and currently supported version of [Python](https://www.python.org/downloads/\").\n\n## Installation\n\n```console\n$ pip install crinkle\n```\n\n## Example\n\nFor an introduction to the Chain of Responsability Pattern and its use cases, see\n[Chain of Responsibility by Refactoring Guru](https://refactoring.guru/design-patterns/chain-of-responsibility)\n\n```Python hl_lines=\"18  21  23-27\"\nfrom pydantic import BaseModel\nfrom typing import Dict, List\nfrom crinkle import Context, Flow\n\n\nclass Order(BaseModel):\n    loyalty: bool  # just to simplify the example\n    items: List\n    discounts: List\n\n\ncontext = Context[Order, Dict](\n    initial_state=Order(),\n    additional_data={},  # Optional\n)\n\nflow = Flow(name='Promotions/Discounts Flow')\n\n\n@flow.processor(name='Discounts pre-conditions Processor')\ndef discounts_pre_conditions_processor(context: Context[Order, Dict]) -\u003e bool:\n    if context.state.loyalty:\n        return False  # Go to next processor\n\n    return True  # Stop flow without going to next processors\n\n\n@flow.processor(name='Manufacturer Coupons Processor')\ndef manufacturer_coupons_processor(context: Context[Order, Dict]) -\u003e bool:\n    # do stuff with context\n    return False  # Go to next processor\n\n\n# Async is also supported\n@flow.processor(name='Buy one get one Processor')\nasync def bogo_processor(context: Context[Order, Dict]) -\u003e bool:\n    # do stuff with context\n    return False  # This is the last processor, so end of flow\n\n\n# Just like Apache Commons Chain, the Flow will be forced to terminate\n# if a processor returns True (this would mean processing is complete).\n\nflow.execute(context)\n\n# **context.state** has the state of the Order after all processing\n```\n\n### Using Object Oriented Programming (OOP)\n\nCrinkle has flavors for all tastes! OOP is also supported, see example:\n\n```Python hl_lines=\"15-18\"\nfrom typing import Dict, List\nfrom crinkle import ProcessorBase, ProcessorBaseAsync, Flow, Context\n\n\nclass Order(BaseModel):\n    loyalty: bool  # just to simplify the example\n    items: List\n    discounts: List\n\n\ncontext = Context[Order, Dict](\n    initial_state=Order(),\n    additional_data={},  # Optional\n)\n\n\nclass DiscountsPreConditionsProcessor(ProcessorBase):\n    def __init__(self, name: str):\n        self.name = name\n\n    def process(self, context: Context[Order, Dict]) -\u003e bool:\n        # Go to next processor\n        if context.state.loyalty:\n            return False\n\n        return True  # Stop flow without going to next processors\n\n\nclass ManufacturerCouponsProcessor(ProcessorBase):\n    def __init__(self, name: str):\n        self.name = name\n\n    def process(self, context: Context[Order, Dict]) -\u003e bool:\n        # do stuff with context\n        return False  # Go to next processor\n\n\nclass BOGOProcessor(ProcessorBaseAsync):\n    def __init__(self, name: str):\n        self.name = name\n\n    # Async is also supported\n    async def process(self, context: Context[Order, Dict]) -\u003e bool:\n        # do stuff with context\n        return False  # This is the last processor, so end of flow\n\n\nflow = Flow(\n    flow_name='Promotions/Discounts Flow',\n    processors=[\n        DiscountsPreConditionsProcessor(name='...'),\n        ManufacturerCouponsProcessor(name='...'),\n        BOGOProcessor(name='...'),\n    ],\n)\n# OR\nflow.add_processor(DiscountsPreConditionsProcessor(name='...'))\nflow.add_processor(ManufacturerCouponsProcessor(name='...'))\nflow.add_processor(BOGOProcessor(name='...'))\n\n\n# Just like Apache Commons Chain, the Flow will be forced to terminate\n# if a processor returns True (this would mean processing is complete).\n\nflow.execute(context)\n\n# **context.state** has the state of the Order after all processing\n\n```\n\n## License\n\nThis project is licensed under the terms of the [MIT license](https://github.com/miguelteixeiraa/crinkle/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelteixeiraa%2Fcrinkle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiguelteixeiraa%2Fcrinkle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiguelteixeiraa%2Fcrinkle/lists"}