base on A Python tool to visualize + enforce dependencies, using modular architecture 🌎 Open source 🐍 Installable via pip πŸ”§ Able to be adopted incrementally - ⚑ Implemented with no runtime impact ♾️ Interoperable with your existing systems πŸ¦€ Written in rust # Tach [![downloads](https://static.pepy.tech/badge/tach/month)](https://pepy.tech/project/tach) [![version](https://img.shields.io/pypi/v/tach.svg)](https://pypi.Python.org/pypi/tach) [![license](https://img.shields.io/pypi/l/tach.svg)](https://pypi.Python.org/pypi/tach) [![python](https://img.shields.io/pypi/pyversions/tach.svg)](https://pypi.Python.org/pypi/tach) [![ci](https://github.com/gauge-sh/tach/actions/workflows/ci.yml/badge.svg)](https://github.com/gauge-sh/tach/actions/workflows/ci.yml) [![basedpyright - checked](https://img.shields.io/badge/basedpyright-checked-ffc000)](https://docs.basedpyright.com) [![ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) Tach is a Python tool to enforce dependencies and interfaces, written in Rust. Tach is inspired by the [modular monolith](https://www.milanjovanovic.tech/blog/what-is-a-modular-monolith) architecture. [Docs](https://docs.gauge.sh) <div align="center"> <img src="docs/assets/light_logo.png" alt="gauge-logo" width="30%" style="border-radius: 50%; padding-bottom: 20px"/> </div> https://github.com/user-attachments/assets/11eec4a1-f80a-4f13-9ff3-91a9760133b6 Tach can enforce: - πŸ“‹ Imports only come from [declared dependencies](https://docs.gauge.sh/usage/configuration#modules) - 🀝 Cross-module calls use the [public interface](https://docs.gauge.sh/usage/configuration#interfaces) - ⛓️‍πŸ’₯ [No cycles](https://docs.gauge.sh/usage/configuration) in the dependency graph Tach is: - 🌎 Open source - 🐍 Installable via pip - πŸ”§ Able to be adopted incrementally - ⚑ Implemented with no runtime impact - ♾️ Interoperable with your existing systems ## Getting Started ### Installation ```bash pip install tach ``` ### Setup Tach will guide you through initial project setup. Run: ```bash tach init ``` After an introductory message, you will see a file tree interface allowing you to interactively configure your project. Use the arrow keys to navigate, and mark each module boundary with 'Enter'. You can mark all of your top-level Python packages, or just a few that you want to track. FAQ: [What is a module?](https://docs.gauge.sh/usage/faq#what-is-a-module%3F) If your Python code lives below your project root, or if you are working in a monorepo with multiple Python packages, mark your Python [source roots](https://docs.gauge.sh/usage/configuration#source-roots) using the 's' key. ### Enforcement Tach comes with a cli command to enforce the boundaries that you just set up! From the root of your Python project, run: ```bash tach check ``` You will see: ```bash βœ… All modules validated! ``` You can validate that Tach is working by: 1. Removing an item from the `depends_on` key in `tach.toml`, or marking it as [deprecated](https://docs.gauge.sh/usage/deprecate) 2. By adding an import between modules that didn't previously import from each other. Give both a try and run `tach check` again. This will generate an error: ```bash ❌ tach/check.py[L8]: Cannot use 'tach.filesystem'. Module 'tach' cannot depend on 'tach.filesystem'. ``` Each error indicates an import which violates your dependencies. If your terminal supports hyperlinks, click on the file path to go directly to the error. When an error is detected, `tach check` will exit with a non-zero code. It can be easily integrated with CI/CD, [Pre-commit hooks](https://docs.gauge.sh/usage/commands#tach-install), and [VS Code](https://marketplace.visualstudio.com/items?itemName=detachhead.dtach), and more! ### Extras Visualize your dependency graph. ```bash tach show [--web] ``` Tach will generate a graph of your dependencies. Here's what this looks like for Tach: ![tach show](docs/assets/tach_show.png) Note that this graph is generated remotely with the contents of your `tach.toml` when running `tach show --web`. If you would like to use the [GraphViz DOT format](https://graphviz.org/about/) locally, simply running `tach show` will generate `tach_module_graph.dot` in your working directory. You can view the dependencies and usages for a given path: ```bash tach report my_package/ # OR tach report my_module.py ``` e.g.: ```bash > tach report python/tach/filesystem [Dependencies of 'python/tach/filesystem'] python/tach/filesystem/install.py[L6]: Import 'tach.hooks.build_pre_commit_hook_content' python/tach/filesystem/project.py[L5]: Import 'tach.constants.CONFIG_FILE_NAME' ... ------------------------------- [Usages of 'python/tach/filesystem'] python/tach/cache/access.py[L8]: Import 'tach.filesystem.find_project_config_root' python/tach/cache/setup.py[L7]: Import 'tach.filesystem.find_project_config_root' ... ``` Tach also supports: - [Public interfaces for modules](https://docs.gauge.sh/usage/interfaces/) - [Deprecating individual dependencies](https://docs.gauge.sh/usage/deprecate) - [Layered architecture](https://docs.gauge.sh/usage/layers) - [Incremental adoption](https://docs.gauge.sh/usage/unchecked-modules) - [Generating JSON dependency maps](https://docs.gauge.sh/usage/commands#tach-map) - [Monorepos and namespace packages](https://docs.gauge.sh/usage/configuration#source-roots) - [Domain ownership](https://docs.gauge.sh/usage/configuration#tach-domain-toml) - [Inline 'ignore' comments](https://docs.gauge.sh/usage/tach-ignore) - [Pre-commit hooks](https://docs.gauge.sh/usage/commands#tach-install) More info in the [docs](https://docs.gauge.sh/). If you have any feedback, we'd love to talk! If you have any questions or run into any issues, let us know by submitting a [Github Issue](https://github.com/gauge-sh/tach/issues)! --- ### Contributors <a href="https://github.com/gauge-sh/tach/graphs/contributors"> <img src="https://contrib.rocks/image?repo=gauge-sh/tach" /> </a> ", Assign "at most 3 tags" to the expected json: {"id":"13040","tags":[]} "only from the tags list I provide: [{"id":39,"name":"3d-generation","display_name":"3D generation","slug":"3d-generation"},{"id":3,"name":"ai-agent","display_name":"AI agent","slug":"ai-agent"},{"id":8,"name":"ai-coding","display_name":"AI coding assistant","slug":"ai-coding"},{"id":5,"name":"ai-image","display_name":"AI image generation","slug":"ai-image"},{"id":9,"name":"ai-infrastructure","display_name":"AI infrastructure","slug":"ai-infrastructure"},{"id":10,"name":"ai-memory","display_name":"AI memory","slug":"ai-memory"},{"id":11,"name":"ai-skills","display_name":"AI skills","slug":"ai-skills"},{"id":12,"name":"ai-translation","display_name":"AI translation","slug":"ai-translation"},{"id":6,"name":"ai-video","display_name":"AI video generation","slug":"ai-video"},{"id":4,"name":"ai-voice","display_name":"AI voice","slug":"ai-voice"},{"id":7,"name":"ai-workflow","display_name":"AI workflow","slug":"ai-workflow"},{"id":22,"name":"audio-processing","display_name":"Audio processing","slug":"audio-processing"},{"id":29,"name":"authentication","display_name":"Authentication","slug":"authentication"},{"id":51,"name":"bundler","display_name":"Bundler","slug":"bundler"},{"id":41,"name":"chatbot","display_name":"Chatbot","slug":"chatbot"},{"id":27,"name":"cloud-native","display_name":"Cloud native","slug":"cloud-native"},{"id":1,"name":"computer-vision","display_name":"Computer vision","slug":"computer-vision"},{"id":37,"name":"crypto-trading","display_name":"Crypto trading","slug":"crypto-trading"},{"id":57,"name":"curated-list","display_name":"Curated list","slug":"curated-list"},{"id":54,"name":"data-streaming","display_name":"Data streaming","slug":"data-streaming"},{"id":35,"name":"data-visualization","display_name":"Data visualization","slug":"data-visualization"},{"id":16,"name":"database-backup","display_name":"Database backup","slug":"database-backup"},{"id":49,"name":"design-system","display_name":"Design system","slug":"design-system"},{"id":38,"name":"digital-human","display_name":"Digital human","slug":"digital-human"},{"id":34,"name":"document-processing","display_name":"Document processing","slug":"document-processing"},{"id":44,"name":"ecommerce","display_name":"E-commerce","slug":"ecommerce"},{"id":45,"name":"emulator","display_name":"Emulator","slug":"emulator"},{"id":46,"name":"file-management","display_name":"File management","slug":"file-management"},{"id":32,"name":"fintech","display_name":"Fintech","slug":"fintech"},{"id":31,"name":"game-development","display_name":"Game development","slug":"game-development"},{"id":24,"name":"headless-browser","display_name":"Headless browser","slug":"headless-browser"},{"id":52,"name":"headless-cms","display_name":"Headless CMS","slug":"headless-cms"},{"id":36,"name":"home-automation","display_name":"Home automation","slug":"home-automation"},{"id":20,"name":"image-editing","display_name":"Image editing","slug":"image-editing"},{"id":28,"name":"iot","display_name":"IoT","slug":"iot"},{"id":13,"name":"local-llm","display_name":"Local LLM","slug":"local-llm"},{"id":17,"name":"mcp","display_name":"MCP","slug":"mcp"},{"id":47,"name":"monitoring","display_name":"Monitoring","slug":"monitoring"},{"id":2,"name":"nlp","display_name":"NLP","slug":"nlp"},{"id":26,"name":"observability","display_name":"Observability","slug":"observability"},{"id":40,"name":"pentesting","display_name":"Pentesting","slug":"pentesting"},{"id":48,"name":"programming-examples","display_name":"Programming examples","slug":"programming-examples"},{"id":42,"name":"proxy","display_name":"Proxy","slug":"proxy"},{"id":14,"name":"rag","display_name":"RAG","slug":"rag"},{"id":56,"name":"resume-building","display_name":"Resume building","slug":"resume-building"},{"id":33,"name":"robotics","display_name":"Robotics","slug":"robotics"},{"id":30,"name":"search","display_name":"Search","slug":"search"},{"id":43,"name":"self-hosted","display_name":"Self-hosted","slug":"self-hosted"},{"id":50,"name":"static-analysis","display_name":"Static analysis","slug":"static-analysis"},{"id":18,"name":"synthetic-data","display_name":"Synthetic data","slug":"synthetic-data"},{"id":19,"name":"text-to-speech","display_name":"Text to speech","slug":"text-to-speech"},{"id":53,"name":"ui-components","display_name":"UI components","slug":"ui-components"},{"id":15,"name":"vector-database","display_name":"Vector database","slug":"vector-database"},{"id":21,"name":"video-editing","display_name":"Video editing","slug":"video-editing"},{"id":25,"name":"web-scraping","display_name":"Web scraping","slug":"web-scraping"},{"id":55,"name":"webassembly","display_name":"WebAssembly","slug":"webassembly"},{"id":23,"name":"workflow-automation","display_name":"Workflow automation","slug":"workflow-automation"}]" returns me the "expected json"