{"id":26493970,"url":"https://github.com/dwarvesf/fortress-api","last_synced_at":"2025-03-20T09:58:27.850Z","repository":{"id":62826020,"uuid":"559837345","full_name":"dwarvesf/fortress-api","owner":"dwarvesf","description":"api for fortress, an internal system to do a lot of things @ dwarvesf","archived":false,"fork":false,"pushed_at":"2025-03-10T10:04:50.000Z","size":7361,"stargazers_count":10,"open_issues_count":3,"forks_count":5,"subscribers_count":5,"default_branch":"develop","last_synced_at":"2025-03-10T10:37:49.752Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":false,"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/dwarvesf.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":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-31T07:44:34.000Z","updated_at":"2025-01-23T08:00:11.000Z","dependencies_parsed_at":"2024-06-19T19:39:07.572Z","dependency_job_id":"5656aa78-27fe-4204-a6f2-90c1ca700c65","html_url":"https://github.com/dwarvesf/fortress-api","commit_stats":null,"previous_names":[],"tags_count":280,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Ffortress-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Ffortress-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Ffortress-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwarvesf%2Ffortress-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwarvesf","download_url":"https://codeload.github.com/dwarvesf/fortress-api/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244591450,"owners_count":20477709,"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-03-20T09:58:27.386Z","updated_at":"2025-03-20T09:58:27.843Z","avatar_url":"https://github.com/dwarvesf.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fortress API\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/golang-1.18-blue\" /\u003e\n  \u003cimg src=\"https://img.shields.io/badge/strategy-gitflow-%23561D25\" /\u003e\n  \u003ca href=\"https://github.com/consolelabs/mochi-api/blob/main/LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-GNU-blue\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis repository is the official BE service for Fortress\n\n## How to contribute\n\n### Setup local development environment (pick one of following ways)\n\n#### Using DEVBOX\n\n1. Create isolated shell using devbox\n\n```\nmake shell\n```\n\n2. Start Colima as container runtime \n\n```\nmake colima-start\n```\n\nRelated issue when initiating development environment first time using colima\n- [docker-credential-desktop not installed or not available in PATH](https://stackoverflow.com/questions/67642620/docker-credential-desktop-not-installed-or-not-available-in-path/72888813#72888813)\n  - tltr: Cheating by removing `credsStore` in the `~/.docker/config.json`. Or installing `osxkeychain`\n\n####  Using your machine environment\n\n1. Install Golang\n\n2. Install Docker\n\n### How to run source code locally\n\n1. Set up source\n\nSet up infras, install dependencies, etc.\n\n```\nmake init\n```\n\n2. Set up env\n\nCreate a file `.env` with these values:\n\n```\nDB_HOST=\"127.0.0.1\"\nDB_PORT=\"25432\"\nDB_USER=\"postgres\"\nDB_PASS=\"postgres\"\nDB_NAME=\"fortress_local\"\nDB_SSL_MODE=\"disable\"\nALLOWED_ORIGINS=\"*\"\nENV=dev\nDEBUG=true\nJWT_SECRET_KEY=JWTSecretKey\n```\n\n3. Run source\n\n```\nmake dev\n```\n\nThe service starts with port 8080 as the default\n\n### How to work on a TODO\n\n1. Feel free to pick any TODO for you from [Board View](https://www.notion.so/dwarves/4d756d46e90240918cd2505f962cacd1?v=d65335d1772f4532ab1bc274a1ae8c76)\n2. **Assign** that item to your account\n3. Remember to update item’s **status** based on your working progress\n   - `Not Started`: not started yet\n   - `Planned`: working on this sprint\n   - `In Progress`: still working on\n   - `In Review`: Task done = PR has been merged to `develop` branch at least\n   - `Complete`: Confirmation from the team that the TODO is finished\n\n### PR template\n\n```markdown\n#### What's this PR do?\n\n- [x] Add new routes for user\n- [x] Add instruction for using docker-compose\n\n#### What are the relevant Git tickets?\n\n// Put in link to Git Issue\n\n#### Screenshots (if appropriate)\n\n// Use [Licecap](http://www.cockos.com/licecap/) to share a screencast gif.\n\n#### Any background context you want to provide? (if appropriate)\n\n- Is there a blog post?\n- Does the knowledge base need an update?\n- Does this add new dependencies which need to be added to?\n```\n\n## Technical Document\n\n### Project structure\n\n- `cmd/` this folder contains the main application entry point files for the project\n- `docs/`: contains Swagger documentation files generated by [swaggo](https://github.com/swaggo/swag)\n- `migrations/`: contains seeds and SQL migration files\n  - `schemas/`: contains DB schema migration files\n  - `seed/`: contains seed files which will initialize DB with sets of dummy data\n  - `test-seed/`: also seed files but for test DB\n- `pkg/`: contains core source code of service\n  - `config/`: contains configs for application\n  - `handler/`: handling API requests\n  - `logger/`: logging initial and functional methods\n  - `model/`: DB model structs\n  - `mw/`: middleware\n  - `request/`: API request models\n  - `routes/`: API routing (see [gin](https://github.com/gin-gonic/gin))\n  - `service/`: contains interaction with external services (google API, etc.)\n  - `store/`: data access layers, contains DB CRUD operations (see [gorm](https://gorm.io/))\n  - `utils/`: utility methods\n  - `view/`: API view models\n\n### Sample usecases\n\n1. Create new API\n\n- Check out file `/pkg/routes/v1.go` and explore the code flow to see how to create and handle an API\n- Remember to annotate handler functions with [swaggo](https://github.com/swaggo/swag). Then run `make gen-swagger` to generate Swagger documentations\n\n2. New DB migration\n\nCheck out `.sql` files under `/migrations` to write a valid schema migration / seed file\n\n- To apply new migration files, run `make migrate-up`\n- To apply seed files, run `make seed-db`\n- To apply new migration files for test DB, run `make migrate-test`\n\n**Note:** remember to run these 2 every time you pulling new code\n\n```shell\nmake migrate-up\nmake migrate-test\n```\n\n3. DB repositories\n\nCheck out dirs under `/pkg/store`\n\n4. New API Implementation Steps\n\n- Add the new route to `/pkg/routes/v1.go`\n  - Check if the new route is in a new group or an existing one\n    - Implement `interface IHandler` in `pkg/handler/[name]/interface.go`\n    - Implement handling functions that takes a `*gin.Context` in `pkg/handler/[name]/[name].go`\n    - Add Swagger doc to handler\n    - Add the sub handler to the main handler in `pkg/handler/handler.go`\n  - Check if the new route needs authentication\n  - Check if the new route needs authorization (permission)\n    - If a new permission is needed then define it in `pkg/model/permissions.go`\n- Add the new table\n  - Create new migration by `make migrate-new`\n  - Add seed file to `migrations/seed`\n  - Include the new seed file in `migrations/seed/seed.sql`\n  - Check if existing seed data needs modification (`roles.sql`, `permisions.sql`, etc.)\n  - Implement the model in `pkg/model`\n  - After the model is defined, implement the CRUD functions in `pkg/store`\n    - Implement `interface IStore` in `pkg/store/[name]/interface.go`\n    - Implement the details in `pkg/store/[name]/[name].go`\n    - Add the sub store to the main store in `pkg/store/store.go`\n- Glue the implemented handler and the implemented store\n\n## :pray: Credits\n\nA big thanks to all who contributed to this project!\n\nIf you'd like to contribute, please contact us.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Ffortress-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwarvesf%2Ffortress-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwarvesf%2Ffortress-api/lists"}