{"id":19438407,"url":"https://github.com/altynboy/go-echo-boilerplate","last_synced_at":"2026-05-10T23:58:06.928Z","repository":{"id":241272204,"uuid":"804318251","full_name":"Altynboy/go-echo-boilerplate","owner":"Altynboy","description":"A production-ready Go Echo boilerplate for quick web app development. Includes CRUD operations, JWT authentication, and user roles.","archived":false,"fork":false,"pushed_at":"2024-12-08T19:23:14.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-25T07:16:52.521Z","etag":null,"topics":["boilerplate","crud","echo","echo-jwt","golang","gorm","jwt-authentication","postgresql"],"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/Altynboy.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-05-22T11:21:20.000Z","updated_at":"2024-12-08T19:23:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f54edcb-bacc-4229-884f-4d23b7e7ba56","html_url":"https://github.com/Altynboy/go-echo-boilerplate","commit_stats":null,"previous_names":["altynboy/go-echo-boilerplate"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Altynboy/go-echo-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altynboy%2Fgo-echo-boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altynboy%2Fgo-echo-boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altynboy%2Fgo-echo-boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altynboy%2Fgo-echo-boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Altynboy","download_url":"https://codeload.github.com/Altynboy/go-echo-boilerplate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Altynboy%2Fgo-echo-boilerplate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32876029,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-10T13:40:02.631Z","status":"ssl_error","status_checked_at":"2026-05-10T13:40:02.145Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["boilerplate","crud","echo","echo-jwt","golang","gorm","jwt-authentication","postgresql"],"created_at":"2024-11-10T15:18:13.543Z","updated_at":"2026-05-10T23:58:06.923Z","avatar_url":"https://github.com/Altynboy.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go Echo Boilerplate\n\nThis boilerplate is designed to provide a quick start for production ready web application development using the Echo framework in Go. It includes implementations for CRUD operations, JWT authentication, user roles, and more.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/golang-v1.24-lightblue\" height=\"25\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/echo-v4.13-blue\" height=\"25\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/gorm-v1.25-green\" height=\"25\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/echo--jwt-v1.25-blue\" height=\"25\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/conf-viper-%66bc67\" height=\"25\"/\u003e\n    \u003cimg src=\"https://img.shields.io/badge/db-postgres-%23336791\" height=\"25\"/\u003e\n\u003c/p\u003e\n\n## Table of Contents\n\n- [Features](#features)\n  - [CRUD Operations](#crud-operations)\n  - [Router-Controller-Model Structure](#router-controller-model-structure)\n  - [Authorization using Login Password](#authorization-using-login-password)\n  - [JWT Authentication using Middleware](#jwt-authentication-using-middleware)\n  - [Roles for Users](#roles-for-users)\n  - [JSON Response Wrapper](#json-response-wrapper)\n  - [Environment Variables](#environment-variables)\n  - [Postman Collection with Environment Setup](#postman-collection-with-environment-setup)\n- [Getting Started](#getting-started)\n  - [Prerequisites](#prerequisites)\n  - [Installation](#installation)\n\n## Features\n\n### CRUD Operations\n\nThis boilerplate supports Create, Read, Update, and Delete operations for various models. The CRUD functionality is implemented using a clean architecture approach with separate layers for routing, controllers, and models.\n\n### Router-Controller-Model Structure\n\n- **Router**: Defines all the application routes and middleware.\n- **Controller**: Handles the business logic and communicates between the router and models.\n- **Model**: Represents the data structure and provides functions to interact with the database.\n\n### Authorization using Login Password\n\nUsers can authenticate themselves using a login endpoint that requires a username and password. Passwords are securely hashed using bcrypt before being stored in the database.\n\n### JWT Authentication using Middleware\n\nJWT (JSON Web Token) is used to authenticate API requests. Middleware is employed to protect routes and ensure that only authenticated users can access certain endpoints.\n\n```json\n{\n  \"name\": \"test\",\n  \"id\": 2,\n  \"role\": \"USER\",\n  \"exp\": 1716461438\n}\n```\n\n### Roles for Users\n\nUser roles (e.g., Admin, User) are implemented to manage permissions and access control within the application. Middleware checks user roles to authorize access to specific routes.\n\n```golang\nconst (\n\tAdmin     \tUserRole = \"ADMIN\"\n\tModerator \tUserRole = \"MODERATOR\"\n\tUser \t\tUserRole = \"USER\"\n)\n```\n\n### JSON Response Wrapper\n\nAll API responses are wrapped in a standard JSON format, including status codes, messages, and data payloads, ensuring consistency and ease of use for frontend applications.\n\n```json\n{\n  \"Success\": true,\n  \"Message\": \"Success\",\n  \"Data\": [\n    {\n      \"blogs\": [\n        {\n          \"ID\": 1,\n          \"CreatedAt\": \"2024-05-22T22:41:11.616688Z\",\n          \"UpdatedAt\": \"2024-05-22T22:41:11.616688Z\",\n          \"DeletedAt\": null,\n          \"UserId\": 2,\n          \"Title\": \"test1\",\n          \"Content\": \"content1\"\n        },\n        {\n          \"ID\": 2,\n          \"CreatedAt\": \"2024-05-23T12:50:46.833646Z\",\n          \"UpdatedAt\": \"2024-05-23T12:50:46.833646Z\",\n          \"DeletedAt\": null,\n          \"UserId\": 2,\n          \"Title\": \"test2\",\n          \"Content\": \"content2\"\n        }\n      ]\n    }\n  ]\n}\n```\n\n### Environment Variables\n\nEnvironment variables are used to configure the application, such as database connection strings, JWT secret keys, and other settings. The `config.json` file is utilized to manage these variables.\n\nEnvironment variables\n\n```json\n{\n  \"Db\": {\n    \"Host\": \"localhost\",\n    \"Port\": \"5432\",\n    \"Name\": \"test\",\n    \"User\": \"postgres\",\n    \"Password\": \"123\",\n    \"SslMode\": \"disable\"\n  },\n  \"Jwt\": {\n    \"SecretKey\": \"secret_key\",\n    \"ExpTime\": 3\n  }\n}\n```\n\nimplement like this using `viper` in `main.go`\n\n```golang\nfunc initConfig() error {\n\tviper.AddConfigPath(\"config\")\n\tviper.SetConfigName(\"config\")\n\treturn viper.ReadInConfig()\n}\n\n//... somewherre in your code\n// example loading database config envs\ndb, err := gorm.Open(postgres.New(postgres.Config{\n  DSN: fmt.Sprintf(\"host=%s port=%s dbname=%s user=%s password=%s sslmode=%s\",\n    viper.GetString(\"Db.Host\"),\n    viper.GetString(\"Db.Port\"),\n    viper.GetString(\"Db.Name\"),\n    viper.GetString(\"Db.User\"),\n    viper.GetString(\"Db.Password\"),\n    viper.GetString(\"Db.SslMode\"),\n  )}), \u0026gorm.Config{})\n```\n\n### Postman Collection with Environment Setup\n\nA Postman collection (`_postman` folder) is provided to facilitate testing of the API endpoints. It includes pre-configured requests for all routes and an environment setup to manage variables like base URL and authentication tokens.\n\n## Getting Started\n\n### Prerequisites\n\n- Go (version 1.23+)\n- Postman (optional, for testing API endpoints)\n\n### Installation\n\n1. **Clone the repository**:\n   ```bash\n   git clone https://github.com/altynboy/go-echo-boilerplate.git\n   cd go-echo-boilerplate\n   ```\n2. **Install dependecies**\n   ```bash\n   go mod tidy\n   ```\n3. **Setup env variables** in `config.json`\n   ```json\n   {\n     \"Db\": {\n       \"Host\": \"localhost\",\n       \"Port\": \"5432\",\n       \"Name\": \"test\",\n       \"User\": \"postgres\",\n       \"Password\": \"123\",\n       \"SslMode\": \"disable\"\n     },\n     \"Jwt\": {\n       \"SecretKey\": \"secret_key\",\n       \"ExpTime\": 3\n     }\n   }\n   ```\n4. **Run the application**\n   ```bash\n   go run main.go\n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltynboy%2Fgo-echo-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltynboy%2Fgo-echo-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltynboy%2Fgo-echo-boilerplate/lists"}