{"id":21862733,"url":"https://github.com/betofigueiredo/diff_tracer","last_synced_at":"2026-02-24T04:04:12.516Z","repository":{"id":262353553,"uuid":"886955642","full_name":"betofigueiredo/diff_tracer","owner":"betofigueiredo","description":"A FastAPI utility designed to compare two API responses, making it easier to validate behavior and ensure accuracy during refactoring.","archived":false,"fork":false,"pushed_at":"2024-12-14T17:16:47.000Z","size":249,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T10:11:45.841Z","etag":null,"topics":["fastapi","python","refactoring"],"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/betofigueiredo.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}},"created_at":"2024-11-11T23:06:46.000Z","updated_at":"2024-12-14T17:16:51.000Z","dependencies_parsed_at":"2024-11-12T01:26:43.921Z","dependency_job_id":"207aa173-e655-468e-b487-d85f97ef87f6","html_url":"https://github.com/betofigueiredo/diff_tracer","commit_stats":null,"previous_names":["betofigueiredo/diff-tracer","betofigueiredo/diff_tracer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betofigueiredo%2Fdiff_tracer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betofigueiredo%2Fdiff_tracer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betofigueiredo%2Fdiff_tracer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/betofigueiredo%2Fdiff_tracer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/betofigueiredo","download_url":"https://codeload.github.com/betofigueiredo/diff_tracer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235718843,"owners_count":19034669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","python","refactoring"],"created_at":"2024-11-28T03:17:04.247Z","updated_at":"2025-10-08T14:30:34.834Z","avatar_url":"https://github.com/betofigueiredo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eDIFF TRACER\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  A FastAPI utility designed to compare two API responses, making it easier to validate behavior and ensure accuracy during refactoring.\n  \u003cbr/\u003e\u003cbr/\u003e\n  \u003cimg src=\"https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2Fbetofigueiredo%2Fdiff_tracer%2Fmain%2Fpyproject.toml\u0026query=%24.tool.poetry.version\u0026style=for-the-badge\u0026label=Version\u0026labelColor=363a4f\u0026color=c9a7c2\"\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/betofigueiredo/diff_tracer/.github%2Fworkflows%2Fci.yaml?style=for-the-badge\u0026label=CI\u0026labelColor=363a4f\"\u003e\n  \u003ca href=\"https://github.com/betofigueiredo/diff_tracer/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-green?style=for-the-badge\u0026labelColor=363a4f\u0026color=a6da95\"\u003e\u003c/a\u003e\n  \u003cbr/\u003e\n  \u003ca href=\"https://www.python.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Made%20with-Python-blue?style=for-the-badge\u0026labelColor=363a4f\u0026color=346FA0\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://fastapi.tiangolo.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Made%20with-FastAPI-blue?style=for-the-badge\u0026labelColor=363a4f\u0026color=009485\"\u003e\u003c/a\u003e\n  \u003cbr/\u003e\u003cbr/\u003e\n  \u003cimg src=\"https://github.com/user-attachments/assets/53b3f1cd-f5a8-43de-9b9d-3a3dfbad064c\" alt=\"Preview\" width=\"100%\"/\u003e\n\u003c/p\u003e\n\n\u003e [!WARNING]\n\u003e Please keep in mind that Diff Tracer is still under active development\n\n\u003cbr /\u003e\n\n## Installation\n\n```zsh\n❯ pip install diff_tracer\n```\n\n\u003cbr /\u003e\n\n## Basic Usage\n\nTo compare two results:\n\n```python\nfrom diff_tracer import compare_async\n\n@app.get(\"/\")\nasync def get_data():\n    return await compare_async(\n        current_fn=lambda: currentUseCase(), # current function in production\n        new_fn=lambda: newUseCase(), # new refactored function\n        percentage=80, # percentage of requests to compare, good to control expensive endpoints\n    )\n```\n\nActive the dashboard endpoint in your main file:\n\n```python\nfrom fastapi import FastAPI\nfrom diff_tracer import init_web_view\n\n\napp = FastAPI()\n\n\ninit_web_view(app=app, security_token=\"362a9b3f302542deb3184671bbc3e7da\")\n```\n\nAccess http://localhost:{PORT}/diff-tracer-view/362a9b3f302542deb3184671bbc3e7da to view the dashboard.\n\nCheck a full working example on `./diff_tracer/fastapi_example.py`\n\u003cbr /\u003e\u003cbr /\u003e\n\n## Why\n\nI used this aproach while working on a major endpoint refactor at my current company. The endpoint was critical but lacked comprehensive tests, making it challenging to ensure the refactored function behaved identically to the original. While I wrote some tests, I wanted an extra layer of confidence before deploying to production.\n\u003cbr /\u003e\u003cbr /\u003e\n\n## Known issues\n\n- The dashboard endpoint is not secure. You can set a token to make it harder to access, but it's still not secure.\n- The files are saved local on your API, so everytime you make a new deploy they will be erased.\n  \u003cbr /\u003e\u003cbr /\u003e\n\n## Contributing\n\nFor local development just install the libraries and start the FastAPI example file:\n\n```zsh\n❯ poetry install\n❯ poetry run task start_api\n```\n\nAccess http://localhost:8000/users to simulate requests.\n\nAccess http://localhost:8000/diff-tracer-view/1234 to view de dashboard. 1234 is the default token.\n\nTo run the tests:\n\n```zsh\n❯ poetry run task test\n```\n\n\u003cbr /\u003e\n\n## Thanks to\n\nThe code that makes the comparison is from Google Diff, Match and Patch Library written by Neil Fraser Copyright (c) 2006 Google Inc. http://code.google.com/p/google-diff-match-patch/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetofigueiredo%2Fdiff_tracer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetofigueiredo%2Fdiff_tracer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetofigueiredo%2Fdiff_tracer/lists"}