{"id":15789732,"url":"https://github.com/ytake/protoactor-go-cqrs-example","last_synced_at":"2025-09-07T21:34:45.814Z","repository":{"id":224564905,"uuid":"763599249","full_name":"ytake/protoactor-go-cqrs-example","owner":"ytake","description":"no tactical DDD pattern, implemented CQRS pattern using actor model(golang)","archived":false,"fork":false,"pushed_at":"2024-07-21T08:39:53.000Z","size":42,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-05T22:03:04.264Z","etag":null,"topics":["actor-model","cqrs-es","example-code","protoactor-go"],"latest_commit_sha":null,"homepage":"","language":"Go","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/ytake.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},"funding":{"github":"ytake","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2024-02-26T15:40:52.000Z","updated_at":"2024-07-21T08:39:56.000Z","dependencies_parsed_at":"2024-02-26T16:59:53.675Z","dependency_job_id":"1c863494-30d3-42f7-955a-eca22e9af2fc","html_url":"https://github.com/ytake/protoactor-go-cqrs-example","commit_stats":null,"previous_names":["ytake/protoactor-go-cqrs-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ytake/protoactor-go-cqrs-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-cqrs-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-cqrs-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-cqrs-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-cqrs-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ytake","download_url":"https://codeload.github.com/ytake/protoactor-go-cqrs-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2Fprotoactor-go-cqrs-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274100822,"owners_count":25222444,"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-09-07T02:00:09.463Z","response_time":67,"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":["actor-model","cqrs-es","example-code","protoactor-go"],"created_at":"2024-10-04T22:03:10.798Z","updated_at":"2025-09-07T21:34:45.790Z","avatar_url":"https://github.com/ytake.png","language":"Go","funding_links":["https://github.com/sponsors/ytake"],"categories":[],"sub_categories":[],"readme":"# protoactor-go-cqrs-example\n\nThis repository is a sample implementation of the CQRS pattern using protoactor-go(Actor Model).  \nimplementing simple user registration and user list retrieval.  \nTactical DDD layers are not implemented.\n\n- use actor model to easily implement ES+CQRS(protoactor-go)\n- use [sqlc](https://github.com/sqlc-dev/sqlc) to generate code from sql.\n\nこのリポジトリは、protoactor-goを使ってCQRSパターンを実装したサンプルです(アクターモデル)。  \n簡単なユーザー登録とユーザー一覧取得を実装しています。  \n戦術的DDDのパターンでは実装していません。\n\n - actorモデルを使って簡単なES+CQRSを実装します(protoactor-go)  \n - [sqlc](https://github.com/sqlc-dev/sqlc)を使ってsqlからコードを生成してあります。  \n\n## Architecture\n\nthis sample uses MySQL for persistence,  \nbut uses different tables for Command / Query.  \nRead Model updates are processed by the Read Model Update Actor using Event Sourcing replay etc.\n\nCommandとQueryの2つのパターンで実装しています。  \nMySQLを使って永続化していますが、  \nCommand / Queryで異なるテーブルを利用しています。  \nRead Modelの更新は、Event Sourcingのリプレイなどを使って、Read Model更新アクターが処理しています。  \n\n### Command \n\n```mermaid\ngraph TD;\n    EchoFramework(Echo Framework) -.- ProtoActor(Proto Actor);\n    ProtoActor --\u003e |Spawn| RestAPIActor(RestAPI Actor);\n    RestAPIActor(RestAPI Actor) --\u003e |Spawn| UserRegistrationActor(User Registration Actor);\n    RestAPIActor(RestAPI Actor)  -.- StreamActor(Stream Actor)\n    UserRegistrationActor --\u003e |Write| StreamActor(Stream Actor);\n    UserRegistrationActor --\u003e |Spawn| ReadModelUpdateActor(Read Model Update Actor);\n    UserRegistrationActor \u003c--\u003e |Event Sourcing/Replay| Persistence(Persistence);\n    Persistence \u003c--\u003e MySQL(MySQL);\n```\n\n### Query\n\n```mermaid\ngraph TD;\n    EchoFramework(Echo Framework) \u003c--\u003e |DTO|MySQL(MySQL);\n    EchoFramework(Echo Framework) --\u003e |HTTP Response|Response(Hal+JSON);\n```\n\n## How to run\n\n```bash\n$ docker-compose up -d\n$ go run cmd/main.go\n```\n\n## Post a command / create user\n\nIn this sample, an actor is generated and persisted for each email address.  \nThe same actor cannot be generated, so you cannot register with the same email address.\n\nこのサンプルではメールアドレスごとにアクターが生成、永続化されます。  \n同じアクターは生成できない仕組みにしているため、同じメールアドレスで登録することはできないようになっています。  \n\n```bash\n$ curl --request POST \\\n  --url http://127.0.0.1:1323/user/registration \\\n  --header 'Content-Type: application/json' \\\n  --data '{\n\t\"username\": \"test\",\n\t\"email\": \"test@example.com\"\n}'\n```\n\n## Get a query\n\n```bash\n$ curl --request GET \\\n  --url http://127.0.0.1:1323/users \n```\n\nthis sample returns hal+json,  \nbut you can implement it with GraphQL or gRPC etc.  \nThere are no restrictions on the response format.\n\nこのサンプルではhal+jsonを返していますが、  \nGraphQLやgRPCなどでも実装可能です。  \nレスポンスフォーマットには特に制限はありません。\n\n```json\n{\n  \"_embedded\": {\n    \"users\": {\n      \"_links\": {\n        \"self\": {\n          \"href\": \"/users/1\"\n        }\n      },\n      \"created_at\": \"2024-02-26T23:44:07+09:00\",\n      \"email\": \"test@example.com\",\n      \"id\": \"01HQJXYYX2BQEYCWTX34P9Z7DE\",\n      \"name\": \"test\"\n    }\n  },\n  \"_links\": {\n    \"self\": {\n      \"href\": \"/users\"\n    }\n  },\n  \"count\": 1,\n  \"total\": 1\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fprotoactor-go-cqrs-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fytake%2Fprotoactor-go-cqrs-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Fprotoactor-go-cqrs-example/lists"}