{"id":22192558,"url":"https://github.com/3sidedcube/fw_service_readme_template","last_synced_at":"2025-10-12T23:30:21.198Z","repository":{"id":79436428,"uuid":"480848544","full_name":"3sidedcube/fw_service_readme_template","owner":"3sidedcube","description":"⚠️ This README will be used in a scaffolded repository created using: https://github.com/3sidedcube/fw_service_template","archived":true,"fork":false,"pushed_at":"2022-04-26T16:19:51.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T20:45:41.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/3sidedcube.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":"2022-04-12T14:36:18.000Z","updated_at":"2025-01-06T15:14:04.000Z","dependencies_parsed_at":"2023-03-12T08:11:25.037Z","dependency_job_id":null,"html_url":"https://github.com/3sidedcube/fw_service_readme_template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/3sidedcube/fw_service_readme_template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2Ffw_service_readme_template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2Ffw_service_readme_template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2Ffw_service_readme_template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2Ffw_service_readme_template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/3sidedcube","download_url":"https://codeload.github.com/3sidedcube/fw_service_readme_template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/3sidedcube%2Ffw_service_readme_template/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013446,"owners_count":26085274,"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","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"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":[],"created_at":"2024-12-02T12:26:03.255Z","updated_at":"2025-10-12T23:30:20.956Z","avatar_url":"https://github.com/3sidedcube.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forest Watcher Service \u003cNAME\u003e\n\nThis repository contains the code for the forest watcher microservices \u003cNAME\u003e.\nIt deploys a dockerized application on AWS fargate and expose endpoints under the public URL\n\n- fw-api.globalforestwatch.org\n- staging-fw-api.globalforestwatch.org\n- dev-fw-api.globalforestwatch.org\n\nfor production, staging and dev environments correspondingly.\n\n\u003e All items marked `// TODO` or `# TODO` should be amended to match the new project prior to pushing to a deployment branch (dev, staging, production).\n\nThe application itself is written in [Nodejs](https://nodejs.org/). Application code must be located in the `app/src` folder. The Dockerfile should always be place at the root of the repository.\n\nThe app is a [Koa v2](https://koajs.com/) application with TypeScript support. Which is structured like so:\n```markdown\n- app/src               # Source code for the service\n    - /models           # Database ORM/ODM models\n    - /routes           # Routers for the service\n    - /serializers      # Serialisers for response object\n    - /services         # Reusable services\n    - /validators       # Validators for request objects\n    app.ts              # Root for the app\n```\n\n## Local Development\n\n### Dependencies\n\nExecution using Docker requires:\n- [Docker](https://www.docker.com/)\n- [Docker Compose](https://docs.docker.com/compose/)\n\n### Using Docker\n\n1 - Execute the following command to run Docker:\n\n```shell\nmake up-and-build   # First time building Docker or you've made changes to the Dockerfile\nmake up             # When Docker has already been built and you're starting from where you left off\nmake logs           # To view the logs for the app\n```\n\nThe endpoints provided by this microservice should now be available:\n[localhost:xxxx](http://localhost:xxxx)\\\nOpenAPI docs will also be available at [localhost:xxxxx](http://localhost:xxxxx)\n\n2 - Run the following command to lint the project:\n\n```shell\nmake lint\n```\n\n3 - To close Docker:\n\n```shell\nmake down\n```\n\n### Testing\n\nFollow the instruction above for setting up the runtime environment for Docker execution, then run the following to view the test logs:\n```shell\nmake up\nmake tests\n```\n\n## Documentation\n\nThe endpoints are documented using the OpenAPI spec and saved under `./docs`.\\\nA visualisation of these docs will be available to view in a web browser\nwhen developing, please see above.\n\n## Terraform\n\nThe provided terraform template will\n- build a docker image based on the Dockerfile\n- upload the docker image to AWS ECR\n- create a new Fargate service in the Forest Watcher AWS ECS cluster using the docker image\n- create a new target group for the Fargate service and link it to the Forest Watcher Application Load balancer\n\nThe Fargate service will have access to\n- Document DB cluster\n- Redis Cluster\n- S3 Bucket\n\nRelevant endpoints and secrets to access those services are available as environment variables inside the container.\n\nThe Forest Watcher Application Load Balancer can be linked to multiple services.\nEach service must have a unique path pattern. Path patterns for a given service must be specified in the\nlb_listener_rule inputs inside the fargate_autoscaling in the terraform template.\nThe value of `health_check_path` must match a path_pattern.\n\nAn example for a path patterns is\n\n`path_pattern = [\"/v1/fw_forms/healthcheck\", \"/v1/forms*\", \"/v1/questionnaire*]`\n\nThis will route all requests which start with `/v1/forms` or `/v1/questionnaire` to the current service, as well as the specific path `/v1/fw_forms/healthcheck`.\nThe health_check_path specifies which route the load balancer will perform health checks on. This path must return a HTTP `200` or `202` status code to inform the load balancer the service is healthy. Any other code will be treat the service as unhealthy.\n- For the dev and staging environments, each application's routes will also need to be added to the API gateway to be successfully routed once deployed.\n\nThe Fargate service is currently configure to run with 0.25 cVPU and 512 MB of RAM. Autoscaling is enabled.\nTo change configurations, you can update default values for all environments in `/terraform/variables.tf`.\nTo change configurations for different environments separately, override default values in `/terraform/vars/terraform-{env}.tfvars`.\n\n## Databases\n\nThe services currently have access to a AWS DocumentDB cluster (MongoDB 3.6) and a AWS ElasticCache Cluster (Redis 6).\nBoth database clusters are managed via the GFW core infrastructure repository.\nFor the case that is become necessary to scale out one of the clusters, please contact the GFW engineering team.\n\nTo directly connect to the databases you can create a tunnel via a bastion host using SSH.\nYou will need to add your public SSH key to the bastion host and add your IP address to the security group to have access.\nPlease provide this information to the GFW engineering team for setup.\n\nExample:\n\n```bash\n# ADD keyfile to chain\nssh-add ~/.ssh/private_key.pem \u003e/dev/null 2\u003e\u00261\n\n# Create a tunnel to document DB\nssh -N -L 27017:\u003cdocumentdb cluster dns\u003e:27017 ec2-user@\u003cbastion host ip\u003e\n```\nYou will now be able to connect to the document db cluster via `localhost:27017`\n\n## Git branch naming convention and CI/CD\n\nThe branches\n\n- production\n- staging\n- dev\n\nRepresent infrastructure deployment in the according environment accounts on AWS.\nGithub actions workflows will apply infrastructure changes to these environments automatically,\nwhen ever a commit is pushed to one of the branches.\n\nPull requests against the branches will trigger a terraform plan action, and the planned infrastructure changes will be displayed first.\nIt is highly recommended to always work in a feature branch and to make a pull request again the `dev` branch first.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3sidedcube%2Ffw_service_readme_template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F3sidedcube%2Ffw_service_readme_template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F3sidedcube%2Ffw_service_readme_template/lists"}