{"id":37140645,"url":"https://github.com/perfectgentlemande/go-mongodb-crud-example","last_synced_at":"2026-01-14T16:29:06.835Z","repository":{"id":61969093,"uuid":"474499612","full_name":"perfectgentlemande/go-mongodb-crud-example","owner":"perfectgentlemande","description":"Example of REST API. Includes such things as MongoDB, Zap logger, chi router etc...","archived":false,"fork":false,"pushed_at":"2022-12-13T10:20:21.000Z","size":87,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-05T00:01:37.737Z","etag":null,"topics":["docker","docker-compose","go","golang","mongodb","oapi-codegen","openapi","rest-api"],"latest_commit_sha":null,"homepage":"","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/perfectgentlemande.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}},"created_at":"2022-03-27T00:36:29.000Z","updated_at":"2023-08-23T15:57:43.000Z","dependencies_parsed_at":"2023-01-28T11:01:09.795Z","dependency_job_id":null,"html_url":"https://github.com/perfectgentlemande/go-mongodb-crud-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/perfectgentlemande/go-mongodb-crud-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectgentlemande%2Fgo-mongodb-crud-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectgentlemande%2Fgo-mongodb-crud-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectgentlemande%2Fgo-mongodb-crud-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectgentlemande%2Fgo-mongodb-crud-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perfectgentlemande","download_url":"https://codeload.github.com/perfectgentlemande/go-mongodb-crud-example/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perfectgentlemande%2Fgo-mongodb-crud-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28425941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T15:24:48.085Z","status":"ssl_error","status_checked_at":"2026-01-14T15:23:41.940Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["docker","docker-compose","go","golang","mongodb","oapi-codegen","openapi","rest-api"],"created_at":"2026-01-14T16:29:05.996Z","updated_at":"2026-01-14T16:29:06.825Z","avatar_url":"https://github.com/perfectgentlemande.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-mongodb-crud-example\nExample of REST API.  \n\nIncludes:    \n- oapi-codegen;  \n- go-chi;  \n- Zap logger;  \n- MongoDB;  \n- Docker;\n- Docker Compose;\n- gomock.\n\n## Description\n\nSample project for educational purposes.  \nThere are 2 ideas:  \n- checking and glueing together technologies mentioned above;\n- sharing my own experience for the ones who want to glue the same technologies.\n\n## Package Diagram\n\n\u003cimg src=\"https://github.com/perfectgentlemande/go-mongodb-crud-example/blob/main/package-diagram.png?raw=true\"/\u003e\n\n## Generate\n\nAPI boilerplate code is generated using `oapi-codegen` tool from the `openapi.yaml` file.  \nIt's great tool that makes your actual API reflect the documentation.  \n\nGet it there:  \n`https://github.com/deepmap/oapi-codegen`  \n\nAnd make sure that your `GOPATH/bin` path presents in `PATH` variable.  \n\nUse this command to generate the `api.go` file:  \n- `oapi-codegen --package=api --generate=types,chi-server openapi/openapi.yaml \u003e internal/api/api.go`  \n\n## Running\n\n### Running\n\nUse `go run .` from the folder that contains `main.go`.\n\n### Running via Docker (no compose)\n\nGet the image here:  \n`https://hub.docker.com/_/mongo`  \n\nCreate network and volume:   \n- `docker network create db_network`  \n- `docker volume create mongo-vol`  \n- `docker volume create mongo-config-vol`  \n\nRun db container:\n- `docker run -it --rm -p 27017:27017 --name mongodb-0 --network db_network --mount source=mongo-vol,target=/data/db --mount source=mongo-config-vol,target=/data/configdb mongo:5.0.6`  \nAfter that you can run your using `go run` if you need.\n\nBuild the app image and run:  \n- `docker build -t go-mongodb-app:v0.1.0 .`  \n- `docker run -it -p 8080:80 --name go-mongodb-app-0 --network db_network go-mongodb-app:v0.1.0`  \n\n### Running via Docker Compose\n\nAs simple as:  \n- `docker-compose build`  \n- `docker-compose up`  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectgentlemande%2Fgo-mongodb-crud-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperfectgentlemande%2Fgo-mongodb-crud-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperfectgentlemande%2Fgo-mongodb-crud-example/lists"}