{"id":28483916,"url":"https://github.com/walkccc/greenlight","last_synced_at":"2025-10-24T01:50:15.155Z","repository":{"id":211484733,"uuid":"729222000","full_name":"walkccc/greenlight","owner":"walkccc","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-22T13:57:40.000Z","size":358,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-07T22:05:56.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"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/walkccc.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":"2023-12-08T16:57:04.000Z","updated_at":"2024-03-04T07:26:43.000Z","dependencies_parsed_at":"2023-12-10T23:21:32.428Z","dependency_job_id":"42720309-409a-49e3-b9a1-e3d31b9ec641","html_url":"https://github.com/walkccc/greenlight","commit_stats":null,"previous_names":["walkccc/greenlight"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/walkccc/greenlight","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkccc%2Fgreenlight","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkccc%2Fgreenlight/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkccc%2Fgreenlight/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkccc%2Fgreenlight/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkccc","download_url":"https://codeload.github.com/walkccc/greenlight/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkccc%2Fgreenlight/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262585907,"owners_count":23332743,"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":[],"created_at":"2025-06-07T22:05:57.821Z","updated_at":"2025-10-24T01:50:10.097Z","avatar_url":"https://github.com/walkccc.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Greenlight\n\n\u003ca href=\"https://golang.org/doc/go1.21\"\u003e\u003cimg alt=\"Go 1.21\" src=\"https://img.shields.io/badge/Go-1.21-blue?logo=go\u0026color=5EC9E3\"\u003e\u003c/a\u003e\n\n\u003e This repository is based on\n\u003e [\"Let's Go Further\" by Alex Edwards](https://lets-go-further.alexedwards.net).\n\u003e The **Go**al is to provide a well-structured way to start a Go-backed backend\n\u003e infrastructure.\n\n## Prerequesites\n\n### Install Docker and PostgreSQL image\n\n```bash\n# Install Docker.\nbrew install docker\n\n# Run Docker app so that we can access the `docker` command.\n\n# Pull the PostgresSQL image.\ndocker pull postgres:15.5-alpine\n\n# Check the downloaded image.\ndocker images\n```\n\n### Install `migrate`\n\n```bash\n# Install `migrate` command.\nbrew install golang-migrate\n\n# Check the installed `migrate` command.\nmigrate --version\n```\n\n### Take a look at [`Makefile`](./Makefile) and [`bootstrap.sh`](./bootstrap.sh)\n\n```bash\n# See all the available commands.\nmake help\n```\n\n## Get Started\n\n### Run a Docker container using the official PostgreSQL image\n\nCreates and runs a Docker container with the name `postgres`, using the official\n`postgres:15.5-alpine` Docker image. The container is started as a background\nprocess (`-d` flag) and is mapped to port `5432` of the host machine\n(`-p 127.0.0.1:5432:5432/tcp` flag), which is the default port for PostgreSQL.\n\nThe container is also configured with the environment variables `POSTGRES_USER`\nand `POSTGRES_PASSWORD`, which set the default username and password for the\nPostgreSQL database. In this case, the username is set to `root` and the\npassword is set to `password`.\n\n```bash\ndocker run --name postgres \\\n  -p 127.0.0.1:5432:5432/tcp \\\n  -e POSTGRES_USER=root \\\n  -e POSTGRES_PASSWORD=password \\\n  -d postgres:15.5-alpine\n```\n\n```bash\n# Interact with a PostgreSQL database running inside a Docker container named\n# 'postgres'. Open an interactive terminal (`psql`) as the 'root' user for\n# executing SQL commands.\ndocker exec -it postgres psql -U root\n\n# Try the following query in the shell.\nSELECT NOW();\n```\n\n### Create `.envrc`\n\n```bash\ntouch .envrc\necho \"export GREENLIGHT_DB_DSN=postgres://pengyuc:password@localhost:5432/greenlight?sslmode=disable\" \u003e\u003e .envrc\n```\n\n### Run `bootstrap.sh` to create db, role, extension and migrate the db\n\n```bash\nbash bootstrap.sh\n```\n\n## Style Guide\n\nWhile cases and spaces don't make a difference in the SQL engine, except for the\nsize of the raw file, I aim to stay consistent and enhance readability whenever\npossible, just as in my other projects.\n\n- Use `UpperCase` for table names, which might be slightly different from what's\n  in the book.\n- Use `lower_snake_case` for column names.\n- Capitalize the keywords in Postgres.\n\n## Visual Studio Code extensions\n\n```bash\ncode --install-extension esbenp.prettier-vscode\ncode --install-extension foxundermoon.shell-format\ncode --install-extension golang.go\n```\n\n## Appendix\n\n### Add new migration scripts\n\n```bash\nmigrate create -ext sql -dir migrations -seq \u003cnew_script_file_name\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkccc%2Fgreenlight","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkccc%2Fgreenlight","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkccc%2Fgreenlight/lists"}