cloud-adapters — Architecture
The @mnemose/cloud-adapters package defines typed port interfaces for all cloud provider operations and provides the GCP v1 implementation. No service imports the GCP SDK directly — all cloud calls go through these adapters.
Design
Mnemose uses the Ports and Adapters (Hexagonal Architecture) pattern for cloud operations:
- Ports — TypeScript interfaces in
src/ports/describing what the platform needs from a cloud provider (IAM, resource management, storage, KMS, etc.) - Adapters — Implementations in
src/gcp/that satisfy those ports using the Google Cloud Node.js SDK
This separation means:
- The domain and command handlers are cloud-agnostic — they depend only on port interfaces
- A new cloud provider (AWS, Azure) can be added by implementing the ports without touching command handlers
- Unit tests mock the ports; no real cloud credentials needed
Port Interfaces
| Port | Description |
|---|---|
IamPort | Role binding management, IAM policy get/set |
ResourcePort | Compute, storage, network resource inventory and provisioning |
StoragePort | Object storage read/write/sign operations |
KmsPort | Key management (create, rotate, destroy key versions) |
MonitoringPort | Metrics query and alert policy management |
SecurityPort | Security findings read and mute operations |
GCP Implementation
src/gcp/ contains the GCP v1 adapters using @google-cloud/iam, @google-cloud/compute, @google-cloud/storage, @google-cloud/kms, and @google-cloud/monitoring.
The createGcpPlatform(config) factory wires all adapters into a single CloudPlatform object that is injected into the gateway Context per request.
Local Dev
resolveLocalInfraConfig() reads MNEMOSE_INFRA_CONFIG (a JSON blob written by the bootstrap script) to configure the adapters for the local emulator stack.