---
# System prepended metadata

title: Game Business Unit

---

# Game Business Unit

## Code

* Project structure and Scaffolding using [`Phoenix`](https://phoenixframework.org/)
    * Use a domain driven approach ([contexts](https://hexdocs.pm/phoenix/contexts.html), [[example](https://hexdocs.pm/phoenix/Mix.Tasks.Phx.Gen.Context.html)])  instead of a layered approach (handlers/models)
        * Restrict communication to just between entities of the same level (IE in the same folder)
        * Cross Context use cases could probably go in the root domain file (inside lib)
        * When the domain entities are tightly related and share use cases they will probably share a context.
        * Context should not limit DB relations and being related through the DB doesn't mean both entities share a context.
        * When the use cases inside a Context are complex, define sub-context or split them when applicable
        * Separate the Wrappers/interfaces for external resources from the Domain (maybe directly in a lib subfolder or in a shared library)
        
* [`OpenApiSpex`](https://github.com/open-api-spex/open_api_spex) for Api documentation and schema specification
    * Normalised responses ("utility attributes for data")
* Automatic IO Test based on Open API
* If possible Mocks and Clients generated also based on Open API.
* Should Mocks, Clients and Schemas live in the same service repo and been added to the ones that depends on it.
* Reduce dependency between services (API Orchestration/Composition)

## Secrets management

* Careful with `fortex_nodule` and Google Secrets, we had and keep having build conflicts and a hard time with tests when integrating nodule. Would be best to avoid remote credentials, if possible.

## Tests

* [`Patch`](https://hexdocs.pm/patch/readme.html) for modules mocking
* (pending) Choose library for http: `MockMe` (can't run async tests), other?

## CI

* Can we port the following github workflows steps into Harness?
    * Formatter and credo check
    * Static code analysis with Dialyzer
    * Unit tests
    * Smoke tests
* Harness builds

## Dev experience (developer tools)

* Keep Makefile with dev tasks
    * code formatting
    * credo checks
    * static code check with dialyzer
    * tests
    * db setup/reset
    * deps setup/reset
* Run services with tilt for integration tests
    * This would be shared between teams assigned to different services in the GBU services "cluster".

## Observability

* Datadog
* Sentry
