{"id":15978150,"url":"https://github.com/bemihq/bemi-mikro-orm","last_synced_at":"2026-02-28T17:03:58.271Z","repository":{"id":257588409,"uuid":"857033565","full_name":"BemiHQ/bemi-mikro-orm","owner":"BemiHQ","description":"Automatic data change tracking for MikroORM","archived":false,"fork":false,"pushed_at":"2024-09-20T15:42:48.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-15T16:06:44.138Z","etag":null,"topics":["audit-log","audit-trail","data-versioning","mikro-orm","postgresql"],"latest_commit_sha":null,"homepage":"https://bemi.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BemiHQ.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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-09-13T17:07:13.000Z","updated_at":"2025-07-03T11:37:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"0eb9649c-e6a1-40d3-bcc8-80fd0e669870","html_url":"https://github.com/BemiHQ/bemi-mikro-orm","commit_stats":{"total_commits":4,"total_committers":1,"mean_commits":4.0,"dds":0.0,"last_synced_commit":"2e713c14e63f07bf2d911c9b28900417b0a69720"},"previous_names":["bemihq/bemi-mikro-orm"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/BemiHQ/bemi-mikro-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BemiHQ%2Fbemi-mikro-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BemiHQ%2Fbemi-mikro-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BemiHQ%2Fbemi-mikro-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BemiHQ%2Fbemi-mikro-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BemiHQ","download_url":"https://codeload.github.com/BemiHQ/bemi-mikro-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BemiHQ%2Fbemi-mikro-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272936320,"owners_count":25018160,"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","status":"online","status_checked_at":"2025-08-31T02:00:09.071Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["audit-log","audit-trail","data-versioning","mikro-orm","postgresql"],"created_at":"2024-10-07T23:06:10.583Z","updated_at":"2026-02-28T17:03:58.225Z","avatar_url":"https://github.com/BemiHQ.png","language":"TypeScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://bemi.io\"\u003e\n    \u003cimg width=\"1201\" alt=\"bemi-banner\" src=\"https://docs.bemi.io/img/bemi-banner.png\"\u003e\n  \u003c/a\u003e\n\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://bemi.io\"\u003eWebsite\u003c/a\u003e\n    ·\n    \u003ca href=\"https://docs.bemi.io\"\u003eDocs\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/BemiHQ/bemi-mikro-orm-example\"\u003eExample\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/BemiHQ/bemi-mikro-orm/issues/new\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/BemiHQ/bemi-mikro-orm/issues/new\"\u003eRequest Feature\u003c/a\u003e\n    ·\n    \u003ca href=\"https://discord.gg/mXeZ6w2tGf\"\u003eDiscord\u003c/a\u003e\n    ·\n    \u003ca href=\"https://x.com/BemiHQ\"\u003eX\u003c/a\u003e\n    ·\n    \u003ca href=\"https://www.linkedin.com/company/bemihq/about\"\u003eLinkedIn\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n# Bemi MikroORM\n\n[Bemi](https://bemi.io) plugs into [MikroORM](https://github.com/mikro-orm/mikro-orm) and your existing PostgreSQL database to track data changes automatically. It unlocks robust context-aware audit trails and time travel querying inside your application.\n\nDesigned with simplicity and non-invasiveness in mind, Bemi doesn't require any alterations to your existing database structure. It operates in the background, empowering you with data change tracking features.\n\nThis library is an optional MikroORM integration, enabling you to pass application-specific context when performing database changes. This can include context such as the 'where' (API endpoint, worker, etc.), 'who' (user, cron job, etc.), and 'how' behind a change, thereby enriching the information captured by Bemi.\n\n## Contents\n\n- [Highlights](#highlights)\n- [Use cases](#use-cases)\n- [Quickstart](#quickstart)\n- [Architecture overview](#architecture-overview)\n- [License](#license)\n\n## Highlights\n\n- Automatic and secure database change tracking with application-specific context in a structured form\n- 100% reliability in capturing data changes, even if executed through direct SQL outside the application\n- High performance without affecting code runtime execution and database workload\n- Easy-to-use without changing table structures and rewriting the code\n- Time travel querying and ability to easily group and filter changes\n- Scalability with an automatically provisioned cloud infrastructure\n- Full ownership of your data\n\nSee [an example repo](https://github.com/BemiHQ/bemi-mikro-orm-example) for MikroORM that automatically tracks all changes.\n\n## Use cases\n\nThere's a wide range of use cases that Bemi is built for! The tech was initially built as a compliance engineering system for fintech that supported $15B worth of assets under management, but has since been extracted into a general-purpose utility. Some use cases include:\n\n- **Audit Trails:** Use logs for compliance purposes or surface them to customer support and external customers.\n- **Change Reversion:** Revert changes made by a user or rollback all data changes within an API request.\n- **Time Travel:** Retrieve historical data without implementing event sourcing.\n- **Troubleshooting:** Identify the root cause of application issues.\n- **Distributed Tracing:** Track changes across distributed systems.\n- **Testing:** Rollback or roll-forward to different application test states.\n- **Analyzing Trends:** Gain insights into historical trends and changes for informed decision-making.\n\n## Quickstart\n\nInstall the NPM package\n\n```sh\nnpm install @bemi-db/mikro-orm\n```\n\nAdd an [Express](https://expressjs.com/) middleware to pass application context with automatically tracked database changes\n\n```ts\nimport { setContext } from \"@bemi-db/mikro-orm\";\nimport express, { Request } from \"express\";\n\nconst app = express();\n\napp.use(\n  // Customizable context\n  setContext((req: Request) =\u003e ({\n    userId: req.user?.id,\n    endpoint: req.url,\n    params: req.body,\n  }))\n);\n```\n\nMake database changes and make sure they're all stored in a table called `changes` in the destination DB\n\n```\npsql -h [HOSTNAME] -U [USERNAME] -d [DATABASE] -c 'SELECT \"primary_key\", \"table\", \"operation\", \"before\", \"after\", \"context\", \"committed_at\" FROM changes;'\n\n primary_key | table | operation |                       before                      |                       after                        |                                context                                                      |      committed_at\n-------------+-------+-----------+---------------------------------------------------+----------------------------------------------------+---------------------------------------------------------------------------------------------+------------------------\n 26          | todo  | CREATE    | {}                                                | {\"id\": 26, \"task\": \"Sleep\", \"isCompleted\": false}  | {\"userId\": 187234, \"endpoint\": \"/todo\", \"params\": {\"task\": \"Sleep\", \"isCompleted\": false}}  | 2023-12-11 17:09:09+00\n 27          | todo  | CREATE    | {}                                                | {\"id\": 27, \"task\": \"Eat\", \"isCompleted\": false}    | {\"userId\": 187234, \"endpoint\": \"/todo\", \"params\": {\"task\": \"Eat\", \"isCompleted\": false}}    | 2023-12-11 17:09:11+00\n 28          | todo  | CREATE    | {}                                                | {\"id\": 28, \"task\": \"Repeat\", \"isCompleted\": false} | {\"userId\": 187234, \"endpoint\": \"/todo\", \"params\": {\"task\": \"Repeat\", \"isCompleted\": false}} | 2023-12-11 17:09:13+00\n 26          | todo  | UPDATE    | {\"id\": 26, \"task\": \"Sleep\", \"isCompleted\": false} | {\"id\": 26, \"task\": \"Sleep\", \"isCompleted\": true}   | {\"userId\": 187234, \"endpoint\": \"/todo/complete\", \"params\": {\"id\": 26}}                      | 2023-12-11 17:09:15+00\n 27          | todo  | DELETE    | {\"id\": 27, \"task\": \"Eat\", \"isCompleted\": false}   | {}                                                 | {\"userId\": 187234, \"endpoint\": \"/todo/27\", \"params\": {\"id\": 27}}                            | 2023-12-11 17:09:18+00\n```\n\nCheck out our [MikroORM docs](https://docs.bemi.io/orms/mikro-orm) for more details.\n\n## Architecture overview\n\nBemi is designed to be lightweight and secure. It takes a practical approach to achieving the benefits of [event sourcing](https://blog.bemi.io/rethinking-event-sourcing/) without requiring rearchitecting existing code, switching to highly specialized databases, or using unnecessary git-like abstractions on top of databases. We want your system to work the way it already does with your existing database to allow keeping things as simple as possible.\n\nBemi plugs into both the database and application levels, ensuring 100% reliability and a comprehensive understanding of every change.\n\nOn the database level, Bemi securely connects to PostgreSQL's [Write-Ahead Log](https://www.postgresql.org/docs/current/wal-intro.html)'s and implements [Change Data Capture](https://blog.bemi.io/cdc/). This allows tracking even the changes that get triggered via direct SQL.\n\nOn the application level, this package automatically passes application context to the replication logs to enhance the low-level database changes. For example, information about a user who made a change, an API endpoint where the change was triggered, a worker name that automatically triggered database changes, etc.\n\nBemi workers then stitch the low-level data with the application context and store this information in a structured easily queryable format, as depicted below:\n\n![bemi-architechture](https://docs.bemi.io/img/architecture.png)\n\nThe cloud solution includes worker ingesters, queues for fault tolerance, and a serverless PostgreSQL. If you are interested in running a self-hosted version yourself, see our [self-hosting docs](https://docs.bemi.io/self-hosting).\n\n## License\n\nDistributed under the terms of the [LGPL-3.0 License](LICENSE).\nIf you need to modify and distribute the code, please release it to contribute back to the open-source community.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemihq%2Fbemi-mikro-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbemihq%2Fbemi-mikro-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbemihq%2Fbemi-mikro-orm/lists"}