{"id":34156926,"url":"https://github.com/okira-e/go-as-your-backend","last_synced_at":"2026-03-11T02:02:56.101Z","repository":{"id":266227341,"uuid":"886372493","full_name":"okira-e/go-as-your-backend","owner":"okira-e","description":"Starter template for using Go as a REST service.","archived":false,"fork":false,"pushed_at":"2026-01-16T17:08:38.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-17T05:11:31.695Z","etag":null,"topics":["backend-template","fiber","go-starter","golang","rest-api","starter-kit","starter-template","template"],"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/okira-e.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-11-10T20:32:24.000Z","updated_at":"2026-01-16T17:08:41.000Z","dependencies_parsed_at":"2024-12-03T08:34:43.446Z","dependency_job_id":null,"html_url":"https://github.com/okira-e/go-as-your-backend","commit_stats":null,"previous_names":["okira-e/go-as-your-backend"],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/okira-e/go-as-your-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okira-e%2Fgo-as-your-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okira-e%2Fgo-as-your-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okira-e%2Fgo-as-your-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okira-e%2Fgo-as-your-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okira-e","download_url":"https://codeload.github.com/okira-e/go-as-your-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okira-e%2Fgo-as-your-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30367800,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["backend-template","fiber","go-starter","golang","rest-api","starter-kit","starter-template","template"],"created_at":"2025-12-15T07:36:37.813Z","updated_at":"2026-03-11T02:02:56.082Z","avatar_url":"https://github.com/okira-e.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go As Your Backend\n\nA starter template for building REST APIs in Go. Uses [Fiber](https://docs.gofiber.io/), [GORM](https://gorm.io/), and [Atlas](https://atlasgo.io/) for migrations, with a sensible project structure and built-in JWT authentication.\n\n\u003e **Note:** This template is extracted from a production backend, not designed as a comprehensive framework. The patterns here reflect real-world needs rather than theoretical completeness—which is exactly what makes it practical.\n\n## Why?\n\nBecause Go is awesome, simple, reliable, and will serve more requests per dollar than most other languages.\n\n## What does the template offer?\n\n- JWT authentication with access/refresh token flow\n- Database migrations with Atlas\n- Generic repository pattern with dynamic filtering\n- Role-based access control middleware\n- Structured logging\n- Project structure for scalable web applications\n\n## Project Structure\n\n```\napp/\n  logging/       # Logging utilities\n  models/        # Database models and DTOs\n  modules/       # Feature modules (users, posts, roles)\n    users/       # Auth, handlers, service, repository\n    posts/       # Example CRUD module\n    roles/       # Role management\n  spec/          # Generic repository interface and filters\n  utils/         # Helper functions\n```\n\n## Dependencies\n\n- [Fiber](https://gofiber.io/) - Fast HTTP framework built on Fasthttp\n- [GORM](https://gorm.io/) - ORM for Go\n- [Atlas](https://atlasgo.io/) - Database schema management and migrations\n- [golang-jwt](https://github.com/golang-jwt/jwt) - JWT implementation\n\n## Getting Started\n\n1. Clone this repository\n2. Copy `env-example` to `.env` and configure your database credentials\n3. Generate the first migration:\n```bash\nmake new-migration name=init\n```\n4. Run migrations:\n```bash\nmake apply-migration\n```\n5. Start the server:\n```bash\nmake build \u0026\u0026 ./bin/go-as-your-backend\n```\n\n## Environment Variables\n\nSee `env-example` for all required variables:\n\n## API Endpoints\n\nSee `REQUESTS.md` for detailed endpoint documentation with curl examples.\n\n### Auth\n\n- `POST /api/v1/users/register` - Register new user\n- `POST /api/v1/users/login` - Login\n- `POST /api/v1/users/refresh` - Refresh access token\n- `POST /api/v1/users/logout` - Logout\n- `GET /api/v1/users/me` - Get current user\n\n### Posts\n\n- `GET /api/v1/posts` - List posts\n- `GET /api/v1/posts/published` - List published posts\n- `GET /api/v1/posts/count` - Get posts count\n- `POST /api/v1/posts` - Create post (requires auth)\n\n## Example Request\n\n```bash\ncurl --get --data-urlencode 'filter={\"where\":{\"and\":[{\"column\":\"published\",\"operator\":\"=\",\"value\":true}]}}' http://localhost:3232/api/v1/posts\n```\n\n## Example Response\n\n```json\n{\n    \"success\": true,\n    \"status\": 200,\n    \"message\": \"\",\n    \"data\": [\n        {\n            \"id\": \"019a8318-66eb-7824-89c6-c9bde9ea9cbe\",\n            \"title\": \"My First Post\",\n            \"content\": \"This is the content of my first post.\",\n            \"published\": true,\n            \"user_id\": \"019a529c-c734-7796-ba61-81fe04e75647\",\n            \"created_at\": \"2025-11-15T17:12:16.633114Z\",\n            \"updated_at\": null\n        }\n    ]\n}\n```\n\n## Dynamic Query Filtering\n\nThe template includes a filter system for building dynamic queries from API parameters.\n\n### Filter Syntax\n\n```json\n{\n    \"select\": [\"id\", \"title\", \"published\"],\n    \"where\": {\n        \"and\": [{ \"column\": \"published\", \"operator\": \"=\", \"value\": true }],\n        \"or\": [{ \"column\": \"title\", \"operator\": \"LIKE\", \"value\": \"%hello%\" }]\n    },\n    \"order_by\": [{ \"column\": \"created_at\", \"direction\": \"DESC\" }]\n}\n```\n\n### Supported Operators\n\n`=`, `\u003e`, `\u003c`, `\u003e=`, `\u003c=`, `LIKE`, `IN`, `IS NULL`\n\n### Examples\n\nFilter published posts:\n\n```\n/posts?filter={\"where\":{\"and\":[{\"column\":\"published\",\"operator\":\"=\",\"value\":true}]}}\n```\n\nWith ordering:\n\n```\n/posts?filter={\"where\":{\"and\":[{\"column\":\"published\",\"operator\":\"=\",\"value\":true}]},\"order_by\":[{\"column\":\"created_at\",\"direction\":\"DESC\"}]}\n```\n\nWith pagination:\n\n```\n/posts?limit=10\u0026offset=0\n```\n\n## Testing with Veriflow\n\nThis template includes a [Veriflow](https://github.com/okira-e/veriflow) configuration for API flow testing. Veriflow is a CLI tool for testing REST API flows with support for chained requests, assertions, and variable exports.\n\n### Running Tests\n\n```bash\nveriflow run\n```\n\n### Test Configuration\n\nSee `veriflow.json` for the test flows:\n\n- **auth** - Registration and login flow\n- **posts** - CRUD operations for posts\n- **filters** - Filter query parameter tests\n- **validation** - Input validation tests\n\nExample flow:\n\n```json\n{\n    \"name\": \"auth\",\n    \"steps\": [\n        {\n            \"name\": \"register\",\n            \"request\": {\n                \"method\": \"POST\",\n                \"path\": \"/users/register\",\n                \"json\": {\n                    \"email\": \"john.doe-{{RUN_ID}}@example.com\",\n                    \"first_name\": \"John\",\n                    \"last_name\": \"Doe\",\n                    \"password\": \"$Password2025\",\n                    \"phone\": \"+1234567890\"\n                }\n            },\n            \"assert\": {\n                \"status\": 201\n            }\n        }\n    ]\n}\n```\n\n## Contributing\n\nFeel free to suggest improvements and open a PR.\n\n## License\n\nThis project is licensed under the Unlicense - see the [UNLICENSE](UNLICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokira-e%2Fgo-as-your-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokira-e%2Fgo-as-your-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokira-e%2Fgo-as-your-backend/lists"}