{"id":42148588,"url":"https://github.com/xt765/mermaid-trace","last_synced_at":"2026-01-29T21:00:41.247Z","repository":{"id":334526274,"uuid":"1141108603","full_name":"xt765/mermaid-trace","owner":"xt765","description":"Stop reading logs. Start watching them.  MermaidTrace is a specialized logging tool that automatically generates Mermaid JS sequence diagrams from your code execution. It's perfect for visualizing complex business logic, microservice interactions, or asynchronous flows.","archived":false,"fork":false,"pushed_at":"2026-01-28T06:33:48.000Z","size":443,"stargazers_count":19,"open_issues_count":0,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-29T09:24:34.487Z","etag":null,"topics":["fastapi","graph","graphics","graphs","langchain","layered-architecture","log","logger","logging","mermaid","mvc","mvc-architecture","pipy-package","python","python-script","python3","src","visual","visualization"],"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/xt765.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-24T09:04:59.000Z","updated_at":"2026-01-29T09:15:46.000Z","dependencies_parsed_at":"2026-01-29T21:00:35.526Z","dependency_job_id":null,"html_url":"https://github.com/xt765/mermaid-trace","commit_stats":null,"previous_names":["xt765/logcapy"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/xt765/mermaid-trace","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xt765%2Fmermaid-trace","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xt765%2Fmermaid-trace/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xt765%2Fmermaid-trace/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xt765%2Fmermaid-trace/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xt765","download_url":"https://codeload.github.com/xt765/mermaid-trace/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xt765%2Fmermaid-trace/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28884676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-29T19:55:09.949Z","status":"ssl_error","status_checked_at":"2026-01-29T19:55:08.490Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["fastapi","graph","graphics","graphs","langchain","layered-architecture","log","logger","logging","mermaid","mvc","mvc-architecture","pipy-package","python","python-script","python3","src","visual","visualization"],"created_at":"2026-01-26T18:06:18.410Z","updated_at":"2026-01-29T21:00:41.199Z","avatar_url":"https://github.com/xt765.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MermaidTrace: The Python Logger That Draws Diagrams\n\n🌐 **Language**: [English](README.md) | [中文](README_CN.md)\n\n[![PyPI version](https://img.shields.io/pypi/v/mermaid-trace.svg?style=flat-square\u0026color=blue)](https://pypi.org/project/mermaid-trace/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/mermaid-trace.svg?style=flat-square\u0026color=blue)](https://pypi.org/project/mermaid-trace/)\n[![License](https://img.shields.io/github/license/xt765/mermaid-trace?style=flat-square)](LICENSE)\n[![CI Status](https://img.shields.io/github/actions/workflow/status/xt765/mermaid-trace/ci.yml?style=flat-square\u0026label=CI)](https://github.com/xt765/mermaid-trace/actions/workflows/ci.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/xt765/mermaid-trace?style=flat-square\u0026logo=codecov)](https://codecov.io/gh/xt765/mermaid-trace)\n\n---\n\n## 📋 Overview\n\n**Stop reading logs. Start watching them.**\n\nMermaidTrace is a specialized logging tool that automatically generates [Mermaid JS](https://mermaid.js.org/) sequence diagrams from your code execution. It's perfect for visualizing complex business logic, microservice interactions, or asynchronous flows.\n\n---\n\n## 📚 Documentation\n\n[User Guide](docs/en/USER_GUIDE.md) · [API Reference](docs/en/API.md) · [Contributing Guidelines](docs/en/CONTRIBUTING.md) · [Changelog](docs/en/CHANGELOG.md) · [License](docs/en/LICENSE)\n\n---\n\n## ✨ Key Features\n\n- **Decorator-Driven**: Just add `@trace` or `@trace_interaction` to your functions.\n- **Auto-Diagramming**: Generates `.mmd` files that can be viewed in VS Code, GitHub, or Mermaid Live Editor.\n- **Async Support**: Works seamlessly with `asyncio` coroutines.\n- **Context Inference**: Automatically tracks nested calls and infers `source` participants using `contextvars`.\n- **FastAPI Integration**: Includes middleware for zero-config HTTP request tracing.\n- **CLI Tool**: Built-in viewer to preview diagrams in your browser.\n\n---\n\n## 🚀 Quick Start\n\n### Installation\n\n```bash\npip install mermaid-trace\n```\n\n### Basic Usage\n\n```python\nfrom mermaid_trace import trace, configure_flow\nimport time\n\n# 1. Configure output\nconfigure_flow(\"my_flow.mmd\")\n\n# 2. Add decorators\n@trace(source=\"Client\", target=\"PaymentService\", action=\"Process Payment\")\ndef process_payment(amount):\n    if check_balance(amount):\n        return \"Success\"\n    return \"Failed\"\n\n@trace(source=\"PaymentService\", target=\"Database\", action=\"Check Balance\")\ndef check_balance(amount):\n    return True\n\n# 3. Run your code\nprocess_payment(100)\n```\n\n### Nested Calls (Context Inference)\n\nYou don't need to specify `source` every time. MermaidTrace infers it from the current context.\n\n```python\n@trace(source=\"Client\", target=\"API\")\ndef main():\n    # Inside here, current participant is \"API\"\n    service_call()\n\n@trace(target=\"Service\") # source inferred as \"API\"\ndef service_call():\n    pass\n```\n\n### FastAPI Integration\n\n```python\nfrom fastapi import FastAPI\nfrom mermaid_trace.integrations.fastapi import MermaidTraceMiddleware\n\napp = FastAPI()\napp.add_middleware(MermaidTraceMiddleware, app_name=\"MyAPI\")\n\n@app.get(\"/\")\nasync def root():\n    return {\"message\": \"Hello World\"}\n```\n\n### CLI Viewer\n\nVisualize your generated `.mmd` files instantly:\n\n```bash\nmermaid-trace serve my_flow.mmd\n```\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions! Please see [CONTRIBUTING.md](docs/en/CONTRIBUTING.md) for details.\n\n---\n\n## 📄 License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxt765%2Fmermaid-trace","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxt765%2Fmermaid-trace","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxt765%2Fmermaid-trace/lists"}