{"id":32558820,"url":"https://github.com/boonious/suzy","last_synced_at":"2025-10-28T23:59:34.304Z","repository":{"id":199719549,"uuid":"703578508","full_name":"boonious/suzy","owner":"boonious","description":"Displaying, decorating, streaming billions of numbers. ","archived":false,"fork":false,"pushed_at":"2023-10-18T10:09:41.000Z","size":329,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-10-19T03:26:50.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/boonious.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}},"created_at":"2023-10-11T13:59:59.000Z","updated_at":"2023-10-20T13:00:36.330Z","dependencies_parsed_at":"2023-10-11T23:32:12.814Z","dependency_job_id":"dc8cad84-5061-428a-aef1-52cb27a09c4f","html_url":"https://github.com/boonious/suzy","commit_stats":null,"previous_names":["boonious/suzy"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/boonious/suzy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boonious%2Fsuzy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boonious%2Fsuzy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boonious%2Fsuzy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boonious%2Fsuzy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boonious","download_url":"https://codeload.github.com/boonious/suzy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boonious%2Fsuzy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281533432,"owners_count":26517827,"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-10-28T02:00:06.022Z","response_time":60,"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":[],"created_at":"2025-10-28T23:58:40.451Z","updated_at":"2025-10-28T23:59:34.298Z","avatar_url":"https://github.com/boonious.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Suzy\n\nNumber streams (\"数溪 - ShùXī\" in Chinese): experimenting with Elixir / Phoenix\nstacks for displaying, decorating, streaming billions of numbers via both JSON API and UI.\n\nCurrent feature: modulo-N deduction on number streams with basic caching.\n\n## Usage\nTo start your Phoenix server:\n\n  * Run `mix setup` to install and setup dependencies\n  * Start Phoenix endpoint with `mix phx.server` or inside IEx with `iex -S mix phx.server`\n\nThen visit the following from your browser:\n- [`localhost:4000/numbers`](http://localhost:4000/numbers)\n- [`localhost:4000/api/numbers`](http://localhost:4000/api/numbers)\n\n### Querying\nBoth the UI and API uses the following `GET` query params:\n- `page`, default `1`\n- `page_size`, default `100`\n- `attrs[]` multiple of `mod_n` and `cache_get`, e.g.  `?attrs[]=cache_get\u0026attrs[]=mod_3\u0026attrs[]=mod_5`\n\n### Caching\nTo cache a number in the app in-memory cache (basic GenServer):\n-  `POST` to [`localhost:4000/api/numbers/:number`](http://localhost:4000/numbers/:number) where `:number` is the number, using `attrs[]` params described above:\n  - `localhost:4000/api/numbers/3?attrs[]=mod_3` \n  - `localhost:4000/api/numbers/2?attrs[]=mod_3` \u003c- error, as caching is only for valid mod-n numbers\n- UI: select `cache` checkbox and click on the star icon of a number\n\n## Design\nThe app is mainly underpinned by the [Phoenix Framework](https://www.phoenixframework.org)\nand uses [Phoenix components](https://hexdocs.pm/phoenix/components.html#function-components) for \na basic UX.\n\nThe `Decorator` design pattern is used in the backend design to perform various modulo-n number \ndeductions which are runtime / dynamically composable as demonstrated in the API/UI, via the `attrs[]`\nparams described above. For example, the following performs `mod_3`, `mod_4`, `mod_5` deduction:\n\n- `localhost:4000/api/numbers?attrs[]=mod_3\u0026attrs[]=mod_4\u0026attrs[]=mod_5`\n\nThe deduction logic all implements a common/base number behaviour (the `Number.deduce/1` callback). \nThe logic is executed from a composable runtime pipeline or stack. The same\nmechanism is also used for number caching and fetching numbers from cache as well:\n\n```ex\n# composable stack performing modulo-n deduction\n[Numbers.Mod3, Numbers.Mod5]\n\n# post-deduction caching\n[Numbers.Mod3, Numbers.Mod5, Numbers.CachePut]\n\n# fetch from cache first, a hit will bypass the subsequent deductions\n[Numbers.CacheGet, Numbers.Mod3, Numbers.Mod5]\n```\n\nFurther details:\n- https://github.com/boonious/suzy/pull/1\n- https://github.com/boonious/suzy/pull/2\n- https://github.com/boonious/suzy/pull/3\n\n### Example Rust client for the API\n\n```rust\ncd rust_client\n\n// Lists modulo-n numbers \ncargo run GET  \"http://localhost:4000/api/numbers?attrs[]=cache_get\u0026attrs[]=mod_3\u0026attrs[]=mod_5\"\n\n// Cache a modulo-n number\ncargo run POST  \"http://localhost:4000/api/numbers/3?\u0026attrs[]=mod_3\"\n```\n\nGET Response:\n\n```\nsuzy_client % cargo run \"get\" \"http://localhost:4000/api/numbers?attrs[]=cache_get\u0026attrs[]=mod_3\u0026attrs[]=mod_5\"\n    Finished dev [unoptimized + debuginfo] target(s) in 0.11s\n    Running `target/debug/suzy_client get 'http://localhost:4000/api/numbers?attrs[]=cache_get\u0026attrs[]=mod_3\u0026attrs[]=mod_5'`\n1\n2\n3 Fizz cached\n4\n5 Buzz\n6 Fizz\n7\n8\n9 Fizz\n10 Buzz\n11\n12 Fizz\n13\n14\n15 FizzBuzz\n16\n17\n18 Fizz\n...\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboonious%2Fsuzy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboonious%2Fsuzy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboonious%2Fsuzy/lists"}