{"id":16393583,"url":"https://github.com/tk42/sqlc-buf-pg-template","last_synced_at":"2026-05-07T14:32:52.890Z","repository":{"id":83491267,"uuid":"489143006","full_name":"tk42/sqlc-buf-pg-template","owner":"tk42","description":"SQL query driven backend template with sqlc, gRPC and postgres and also operated by grpcui, pgweb and grafana","archived":false,"fork":false,"pushed_at":"2022-10-18T07:43:29.000Z","size":615,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T04:13:42.314Z","etag":null,"topics":["grpc","postgresql","sql"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/tk42.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":"2022-05-05T22:27:05.000Z","updated_at":"2024-02-27T12:53:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"35c865d2-048a-4349-ac88-d90476d873c6","html_url":"https://github.com/tk42/sqlc-buf-pg-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk42%2Fsqlc-buf-pg-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk42%2Fsqlc-buf-pg-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk42%2Fsqlc-buf-pg-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tk42%2Fsqlc-buf-pg-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tk42","download_url":"https://codeload.github.com/tk42/sqlc-buf-pg-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240258771,"owners_count":19773055,"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":["grpc","postgresql","sql"],"created_at":"2024-10-11T04:53:41.341Z","updated_at":"2026-05-07T14:32:52.861Z","avatar_url":"https://github.com/tk42.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sqlc-buf-pg-template\nSQL query driven backend template with sqlc, gRPC and postgres and also visualized by pgweb and grafana.\n\n## HOW TO USE\n 1. Write proto files and edit buf yamls (`buf.work.yaml`, `buf.gen.yaml` and `buf.yaml`)\n 1. Write the configuration for sqlc in `sqlc.yaml`, SQL Table Schema in `schema.sql` and SQL query for the services in `query.sql`.\nSee [sqlcを使って簡単なウェブアプリケーションを作る](https://zenn.dev/nnabeyang/articles/697c6b65c1a7bd) [query annotations](https://docs.sqlc.dev/en/stable/reference/query-annotations.html).\n 1. Write proto files in `/petapis/pet/v1/pet.proto`.\n 1. To make a new migration file, run\n    ```bash\n    docker-compose -f docker-compose.dbmate_new.yml up\n    ```\n    Then you'll get the new migration file in `/petapis/migrations` directory.\n 1. Then write the migration code in the migration sql file.\n 1. To make a schema file, run\n    ```bash\n    docker-compose -f docker-compose.dbmate.yml up\n    ```\n    Then you'll get the new schema file `/petapis/schema/schema.sql`.\n 1. To generate pb files in `/gen`, write  and the autogenerated package to handle SQL, execute\n    ```bash\n    docker-compose -f docker-compose.autogen.yml\n    ```\n 1. Implement ```adaptor.go``` by the autogenerated codes in `/gen`.\n 1. To run the server, run\n    ```bash\n    docker-compose up\n    ```\n 1. You can access dashboards.\n    - To see the gRPC Web UI [http://localhost:8080/](http://localhost:8080/)\n    - To see the pgweb [http://localhost:8081/](http://localhost:8081/)\n    - To see the grafana [http://localhost:3000/](http://localhost:3000/)\n 1. Paste `/petapis/schema/schema.sql` to \"Query\" in pgweb and execute. Then the table schema will be created.\n 1. Post/Get/Delete Pet data by gRPC Web UI.\n   ![grpc_putpet](./assets/grpc_putpet.png)\n   ![grpc_rest](./assets/grpc_resp.png)\n 1. You can see the data in pgweb and in grafana also.\n   ![pgweb](./assets/pgweb.png)\n   ![grafana](./assets/grafana.png)\n\n\n## TODO\n - `buf lint`\n - `buf breaking`\ncf. https://zenn.dev/y16ra/articles/23e0cd68251554\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftk42%2Fsqlc-buf-pg-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftk42%2Fsqlc-buf-pg-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftk42%2Fsqlc-buf-pg-template/lists"}