This repo is a playground for backend development.
- VSCode connected to remote host via SSH with the repository opened in a Docker container for development.
- Alternate environment on Github Codespaces using the same devcontainer configuration.
- Ubuntu 22.04 devcontainer with Golang 1.22, Docker 24.0.9-1, Docker Compose 2.25.0-1
- Based on the
base:ubuntu-22.04
devcontainer image:mcr.microsoft.com/devcontainers/base:jammy
- Host docker socket accessible from the devcontainer via the docker-outside-of-docker feature.
- Models defined in
ent/schema
, basic CRUD operations generated. - Database migrations via Ent versioned migration.
- GraphQL API generated from the Ent schema using the entgql extension.
- gRPC API generated from the Ent schema using the entproto extension.
- Enable GraphQL mutations for User and Todo, write tests
- Add a
ProfileImage
AvatarImageUrl
field on theUser
model- Spin up LocalStack S3 for image storage
- Add Codespaces notes
- Rework app configuration, move external configs to folder, and app config to a TOML or YAML file
- Figure out a way to log / monitor the graphql requests better.
- Add custom slog handler with formatting and colors, I have this somewhere just need to find it.
- Maybe try an AI static site generator to spin up a quick UI
- Generate a REST API with ent
- [?] Deploy sandboxed gqlserver
- [?] Dockerize everything
- [?] Iterate on prebuilding the devcontainer image, what's the best way to do that
- Audit tasks.toml, docker compose, and update the README
- Look at versioned migrations
- Move grpcserver back over to Postgres
- Audit
dev
run task and record demo - Write logs to file and configure Loki for log viewing
- Add logging middleware to grpcserver
- Generate a gRPC service with ent
- Reimplement commit generator func into a standalone shell script
- Remove the script from .githooks, reset git config to default
add configuration option or run task to show setting it as a hook.- Reimplement the script in a standalone shell script, add scripts folder to PATH
Add run task for the fancy gum output confirmationAdd aliasgcg
to run the script wherever it ends up
- Audit tasks.toml and update the README
- Add an edge between User and Todo
- Populate the database with dummy seed data
- Generate a GraphQL API with ent
./scripts/setup.sh
to install tools (TODO: move this into devcontainer setup)./scripts/gencom.sh
to generate a commit message based on the changes staged for commitrun dockerdb
to start the database in a Docker containerrun dev
to start the dev server and watch for changes
This project uses run
as a general task executor. Poke around the tasks.toml
file and checkout
the documentation for more details. In my environment do
run dev
and leave it running in the background to handle regenerating code and restarting
services when needed.
Here's a screenshot of the run dev
output:
Ent 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.
It's very easy to add a new model: go run -mod=mod entgo.io/ent/cmd/ent new <MODEL_NAME>
The database schema is defined in the ent/schema
directory. Ent uses the schema to generate Go code for the database models and create migrations.
To make a change to the database schema, take the following steps:
- Update the schema in
ent/schema
. run db-migrate
to generate all code and create a new migration.run db-apply
to lint and apply the migration.
A GraphQL schema is generated from the ent schema. Then go
code for a GraphQL server is generated.
ent/entc.go
- Uses the (entql)[https://pkg.go.dev/entgo.io/contrib/entgql] extension to generate a GraphQL schema and resolvers for the Ent models.
gqlserver/ent.graphql
- The generated GraphQL schema file for the Ent models.
- The schema is defined using the GraphQL Schema Definition Language (SDL).
gqlserver/resolver.go
- The generated GraphQL base Resolver.
gqlserver/ent.resolvers.go
- The generated Ent resolvers that extend the base for the different Ent models.
gqlserver/gql-generated.go
- The generated GraphQL types and interfaces needed to implement the resolvers and server.
Protobuf definitions are generated from the ent schema. Then go
code for a gRPC server is generated.
This 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.
- 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. - The script uses
mods
andgum
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
. - See the config file
mods-config.yml
for all the LLM and prompt related settings.
To use the script, stage the changes you want to commit and run it: ./scripts/gencom.sh
.