{"id":38598797,"url":"https://github.com/fraktalio/fmodel-rust-postgres","last_synced_at":"2026-01-17T08:31:39.760Z","repository":{"id":246427918,"uuid":"820049676","full_name":"fraktalio/fmodel-rust-postgres","owner":"fraktalio","description":"Run your domain models as Postgres extensions","archived":false,"fork":false,"pushed_at":"2025-08-21T15:03:43.000Z","size":255,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T17:25:11.044Z","etag":null,"topics":["database","domain-modeling","event-sourcing","extension","fmodel","postgresql","rust-lang"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fraktalio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-06-25T17:39:27.000Z","updated_at":"2025-08-21T14:54:52.000Z","dependencies_parsed_at":"2024-06-27T23:21:47.876Z","dependency_job_id":"b1e0bed6-3a3b-453d-8d93-199ed79ef45e","html_url":"https://github.com/fraktalio/fmodel-rust-postgres","commit_stats":null,"previous_names":["fraktalio/fmodel-rust-postgres"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/fraktalio/fmodel-rust-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraktalio%2Ffmodel-rust-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraktalio%2Ffmodel-rust-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraktalio%2Ffmodel-rust-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraktalio%2Ffmodel-rust-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fraktalio","download_url":"https://codeload.github.com/fraktalio/fmodel-rust-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fraktalio%2Ffmodel-rust-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28504364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T06:57:29.758Z","status":"ssl_error","status_checked_at":"2026-01-17T06:56:03.931Z","response_time":85,"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":["database","domain-modeling","event-sourcing","extension","fmodel","postgresql","rust-lang"],"created_at":"2026-01-17T08:31:39.657Z","updated_at":"2026-01-17T08:31:39.747Z","avatar_url":"https://github.com/fraktalio.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `fmodel-rust-postgres`\n\nEffortlessly transform your domain models into powerful PostgreSQL extensions using our GitHub repository template.\nWith pre-implemented infrastructure and application layers in the `framework` module, you can focus entirely on your core domain logic while running your models directly within your PostgreSQL database for seamless integration and enhanced performance.\n\nThe template includes a demo domain model of a `restaurant/order management system`, showcasing practical implementation and providing a solid foundation for your own projects.\n\n![event model](restaurant-model.jpg)\n\n\u003eActually, the domain model is copied from the traditional application [fmodel-rust-demo](https://github.com/fraktalio/fmodel-rust-demo), demonstrating how to run your unique and single domain model directly within your PostgreSQL database/`as extension`; or connect the application to the database/`traditionally`.\n\n## Event Sourcing\n\nWith event sourcing, we delve deeper by capturing every decision or alteration as an event.\nEach new transfer or modification to the state is meticulously documented, providing a comprehensive audit trail\nof all activities.\nThis affords you a 100% accurate historical record of your domain, enabling you to effortlessly traverse back\nin time and review the state at any given moment.\n\n**History is always on!**\n\n## Technology\nThis project is using:\n\n- [`rust` programming language](https://www.rust-lang.org/) to build a high-performance, reliable, and efficient system.\n- [`f{model}` rust library](https://github.com/fraktalio/fmodel-rust) to implement tactical Domain-Driven Design patterns, optimised for Event Sourcing.\n- [pgrx](https://github.com/pgcentralfoundation/pgrx) to simplify the creation of custom Postgres extensions and bring `logic` closer to your data(base).\n\n## f{model}\n\n[`f{model}`](https://github.com/fraktalio/fmodel-rust/blob/main/README.md) library provides just enough tactical Domain-Driven Design patterns, optimised for Event Sourcing and CQRS.\n\n- algebraic data types form the structure of our data (commands, state, and events).\n- functions/lambda offers the algebra of manipulating the data in a compositional manner, effectively modeling the behavior.\n\n- This leads to modularity in design and a clear separation of the data’s structure and functions/behaviour of the data/entity.\n\n`f{model}` library offers generic and abstract components to specialize in for your specific case/expected behavior.\n\n[Read more](https://github.com/fraktalio/fmodel-rust/blob/main/README.md)\n\n\n\n## Requirements\n- [Rust](https://www.rust-lang.org/tools/install)\n- [PGRX subcommand](https://github.com/pgcentralfoundation/pgrx?tab=readme-ov-file#getting-started): `cargo install --locked cargo-pgrx`\n- Then you can run `cargo pgrx upgrade` in your extension's crate to update its dependencies.\n- (Mac os) `brew install git icu4c pkg-config`\n- (Mac os) `export PKG_CONFIG_PATH=/opt/homebrew/opt/icu4c/lib/pkgconfig`\n- Run `cargo pgrx init` once, to properly configure the pgrx development environment. It downloads the latest releases of supported Postgres versions, configures them for debugging, compiles them with assertions, and installs them to `\"${PGRX_HOME}\"`. These include all contrib extensions and tools included with Postgres. Other cargo pgrx commands such as `run` and `test` will manage and use these installations on your behalf.\n\n\u003e No manual Postgres database installation is required.\n\n## Test it\nRun tests:\n\n```shell\ncargo pgrx test\n```\n\n## Run it\nCompile/install extension to a pgrx-managed Postgres instance and start psql console:\n```shell\ncargo pgrx run\n```\n\nNow, you can run the following SQL commands in the psql console:\n\n1. Load the extension:\n```sql\ncreate extension fmodel_rust_postgres;\n```\n\n2. Send commands to the system:\n\n\u003e Observe how the Commands are formatted in JSON format.\n\nCreate a restaurant:\n```sql\nselect handle('{\"type\": \"CreateRestaurant\",\"identifier\": \"e48d4d9e-403e-453f-b1ba-328e0ce23737\", \"name\": \"Joe\", \"menu\": {\"menu_id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\", \"items\": [{\"id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\",\"name\": \"supa\",\"price\": 10},{\"id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\",\"name\": \"sarma\",\"price\": 20 }],\"cuisine\": \"Vietnamese\"}}'::Command);\n```\n\nPlace an order at the restaurant:\n```sql\nselect handle('{\"type\": \"PlaceOrder\",\"identifier\": \"e48d4d9e-403e-453f-b1ba-328e0ce23737\", \"order_identifier\": \"afd909c6-f8f3-49b2-af7f-833e933cbab4\", \"line_items\": [{\"id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\",\"quantity\": 1, \"menu_item_id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\", \"name\": \"supa\", \"price\": 10},{\"id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\", \"quantity\": 1, \"menu_item_id\": \"02f09a3f-1624-3b1d-8409-44eff7708210\",\"name\": \"sarma\",\"price\": 20 }]}'::Command);\n```\n\n\nConfused? Run `cargo pgrx help`\n\n## The structure of the project\n\nThe project is structured as follows:\n- [lib.rs](src/lib.rs) file contains the entry point of the package/crate.\n- `framework` module contains the generalized and parametrized implementation of infrastructure and application layers.\n- `domain` module contains the domain model. It is the core and pure domain logic of the application!!!\n- `application` module contains the application layer. It is the orchestration of the domain model and the infrastructure layer (empty, as it is implemented in the `framework` module).\n- `infrastructure` module contains the infrastructure layer / fetching and storing data (empty, as it is implemented in the `framework` module).\n\nThe framework module offers a generic implementation of the infrastructure and application layers, which can be reused across multiple domain models.\nYour focus should be on the `domain` module, where you can implement your unique domain model. We have provided a demo domain model of a `restaurant/order management system` to get you started.\n\n## Check the tests\nThe project contains a set of tests that demonstrate how to use the domain model and the framework.\nYou can find them in the root: [lib.rs](src/lib.rs).\n\nYou will find a command handler function only, which can handle all the commands of the system! Simple!\n\n## References and further reading\n- [pgrx](https://github.com/pgcentralfoundation/pgrx)\n- [fmodel-rust](https://github.com/fraktalio/fmodel-rust)\n\n---\nCreated with :heart: by [Fraktalio](https://fraktalio.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraktalio%2Ffmodel-rust-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffraktalio%2Ffmodel-rust-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffraktalio%2Ffmodel-rust-postgres/lists"}