{"id":15326751,"url":"https://github.com/ecshreve/backend-playground","last_synced_at":"2026-05-09T10:37:53.411Z","repository":{"id":229087886,"uuid":"775135852","full_name":"ecshreve/backend-playground","owner":"ecshreve","description":"A sandbox for exploring backend technologies, frameworks, and concepts.","archived":false,"fork":false,"pushed_at":"2024-03-26T00:11:42.000Z","size":953,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-01T18:44:02.255Z","etag":null,"topics":["devcontainer","docker","entgo","go","golang","postgresql"],"latest_commit_sha":null,"homepage":"https://github.com/ecshreve/backend-playground","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ecshreve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-20T20:32:36.000Z","updated_at":"2024-03-22T02:57:29.000Z","dependencies_parsed_at":"2024-06-20T21:47:55.004Z","dependency_job_id":"b5949531-1980-4655-8e88-52e6cac03a94","html_url":"https://github.com/ecshreve/backend-playground","commit_stats":null,"previous_names":["ecshreve/backend-playground"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecshreve%2Fbackend-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecshreve%2Fbackend-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecshreve%2Fbackend-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecshreve%2Fbackend-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecshreve","download_url":"https://codeload.github.com/ecshreve/backend-playground/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245864432,"owners_count":20685033,"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":["devcontainer","docker","entgo","go","golang","postgresql"],"created_at":"2024-10-01T09:36:49.662Z","updated_at":"2026-05-09T10:37:48.372Z","avatar_url":"https://github.com/ecshreve.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# backend-playground\n\nThis repo is a playground for backend development.\n\n## Summary\n\n- VSCode connected to remote host via SSH with the repository opened in a Docker container for development.\n- Alternate environment on Github Codespaces using the same devcontainer configuration.\n\t- Ubuntu 22.04 [devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) with Golang 1.22, Docker 24.0.9-1, Docker Compose 2.25.0-1\n\t- Based on the `base:ubuntu-22.04` devcontainer image: `mcr.microsoft.com/devcontainers/base:jammy`\n\t- Host docker socket accessible from the devcontainer via the docker-outside-of-docker feature.\n- Models defined in `ent/schema`, basic CRUD operations generated.\n- Database migrations via Ent [versioned migration](https://entgo.io/docs/versioned/intro#automatic-migration).\n- GraphQL API generated from the Ent schema using the [entgql](https://entgo.io/contrib/entgql) extension.\n- gRPC API generated from the Ent schema using the [entproto](https://entgo.io/contrib/entproto) extension.\n\n## Roadmap\n- [ ] Enable GraphQL mutations for User and Todo, write tests\n- [x] Add a ~~`ProfileImage`~~`AvatarImageUrl` field on the `User` model\n    - [ ] Spin up LocalStack S3 for image storage\n- [ ] Add Codespaces notes\n- [ ] Rework app configuration, move external configs to folder, and app config to a TOML or YAML file\n- [ ] Figure out a way to log / monitor the graphql requests better.\n- [ ] Add custom slog handler with formatting and colors, I have this somewhere just need to find it.\n- [ ] Maybe try an AI static site generator to spin up a quick UI\n- [ ] Generate a REST API with ent\n- [?] Deploy sandboxed gqlserver\n- [?] Dockerize everything\n- [?] Iterate on prebuilding the devcontainer image, what's the best way to do that\n---\n- [x] Audit tasks.toml, docker compose, and update the README\n- [x] Look at versioned migrations\n- [x] Move grpcserver back over to Postgres\n- [x] Audit `dev` run task and record demo\n- [x] Write logs to file and configure Loki for log viewing\n- [x] Add logging middleware to grpcserver\n- [x] Generate a gRPC service with ent\n- [x] Reimplement commit generator func into a standalone shell script\n\t- [x] Remove the script from .githooks, reset git config to default\n\t- ~~add configuration option or run task to show setting it as a hook.~~\n\t- [x] Reimplement the script in a standalone shell script, add scripts folder to PATH\n\t- ~~Add run task for the fancy gum output confirmation~~\n\t- ~~Add alias `gcg` to run the script wherever it ends up~~\n- [x] Audit tasks.toml and update the README\n- [x] Add an edge between User and Todo\n- [x] Populate the database with dummy seed data\n- [x] Generate a GraphQL API with ent\n\n## Development Commands\n\n- `./scripts/setup.sh` to install tools (TODO: move this into devcontainer setup)\n- `./scripts/gencom.sh` to generate a commit message based on the changes staged for commit\n- `run dockerdb` to start the database in a Docker container\n- `run dev` to start the dev server and watch for changes\n\n### `run`\n\nThis project uses `run` as a general task executor. Poke around the `tasks.toml` file and checkout\nthe [documentation](https://github.com/amonks/run) for more details. In my environment do\n`run dev` and leave it running in the background to handle regenerating code and restarting\nservices when needed.\n\nHere's a screenshot of the `run dev` output:\n\n\u003cimg src=\"assets/run.png\" width=\"600\" alt=\"run\"\u003e\n\n\n## Ent\n\nEnt is a Go ORM that generates database models and migrations from a schema. It is used to define the database schema and generate Go code for the models. Additional extensions are used in this project to generate a GraphQL API and gRPC service from the schema.\n\nIt's very easy to add a new model: `go run -mod=mod entgo.io/ent/cmd/ent new \u003cMODEL_NAME\u003e`\n\n### Database Schema and Migrations\n\nThe database schema is defined in the `ent/schema` directory. Ent uses the schema to generate Go code for the database models and create migrations.\n\nTo make a change to the database schema, take the following steps:\n\n1. Update the schema in `ent/schema`.\n2. `run db-migrate` to generate all code and create a new migration.\n3. `run db-apply` to lint and apply the migration.\n\n## GraphQL\n\nA GraphQL schema is generated from the ent schema. Then `go` code for a GraphQL server is generated.\n\n`ent/entc.go`\n- Uses the (entql)[https://pkg.go.dev/entgo.io/contrib/entgql] extension to generate a GraphQL schema and resolvers for the Ent models.\n\n`gqlserver/ent.graphql`\n- The generated GraphQL schema file for the Ent models.\n- The schema is defined using the GraphQL Schema Definition Language (SDL).\n\n`gqlserver/resolver.go`\n- The generated GraphQL base Resolver.\n\n`gqlserver/ent.resolvers.go`\n- The generated Ent resolvers that extend the base for the different Ent models.\n\n`gqlserver/gql-generated.go`\n- The generated GraphQL types and interfaces needed to implement the resolvers and server. \n\n\n## gRPC\n\n\u003c!-- TODO: add docs --\u003e\n\nProtobuf definitions are generated from the ent schema. Then `go` code for a gRPC server is generated.\n\n\n\n## Git Commit Message Script\n\nThis repository includes a script designed to enhance the commit process by automatically generating commit messages based on the changes staged for commit, with a focus on quality and conciseness. It uses `mods` to send the current `git diff` in addition to a custom prompt to the OpenAI API. Below are the details on how to set up and use the script. `mods-config.yml` is the config used in the script.\n\n### Setup\n\n- My set up is to add the `scripts/` directory to my PATH and set the OPENAI_API_KEY environment variable in this repo's .env file.\n- The script uses `mods` and `gum` CLI tools to interact with the OpenAI API and generate the commit message, they can be installed by running the setup script: `./scripts/setup.sh`.\n- See the config file `mods-config.yml` for all the LLM and prompt related settings.\n\n### Usage\n\nTo use the script, stage the changes you want to commit and run it: `./scripts/gencom.sh`. \n\n\u003cimg src=\"assets/demo.gif\" width=\"400\" alt=\"Demo GIF\"\u003e\n\n\n### Resources\n\n- [OpenAI API](https://beta.openai.com/docs/)\n- [Gum](https://github.com/charmbracelet/gum)\n- [Mods](https://github.com/charmbracelet/mods)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecshreve%2Fbackend-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecshreve%2Fbackend-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecshreve%2Fbackend-playground/lists"}