# kenrota/gcp-labs architecture

> Architecture diagram of the GitHub repository kenrota/gcp-labs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kenrota/gcp-labs
- Repository: https://github.com/kenrota/gcp-labs

## Overview

##### Overall Project Breakdown
- Having a section (or annotation) that emphasizes the use of Terraform as the underlying mechanism for infrastructure provisioning across these labs.

##### Main Components
a. App Engine:
- App Engine / IAP: Represent the secure App Engine application (“appengine/iap/app/main.py”) and configuration files.
- App Engine / Static Website: Include the static website configuration and assets (appengine/static-website/).
b. Cloud Functions:
- Basic functions (with sub-components for HTTP and Pub/Sub triggers under functions/basic).
- Fan-out examples (both autoscale and direct) which highlight different event handling patterns.
- Additional examples (such as the ones under functions/hono and functions/logging) to illustrate language differences (Python, JavaScript) and logging.
c. Pub/Sub:
- Pub/Sub components like the dead-letter handling lab and the pull-messages lab – denote how messages are published and then consumed.
d. DNS:
- DNS lab’s main module and its supporting source code, indicating how domain and network infrastructure might be managed via Terraform.
e. Runservices & SQL:
- For runservices (load-balancing integration) and SQL labs, emphasize how they show integrations with other parts of the system, like using a SQL instance for connection demos.
f. VM-based Labs:
- The VM section includes examples for container-optimized systems (cos-bigtable-emulator, cos-elasticsearch, cos-function, cos) showing labs that run on virtual machines or containers with Docker and Python apps.

##### Relationships and Interactions
- For the App Engine and VM sections, if applicable, show network boundaries (e.g., external access vs. internal service endpoints).

##### Architectural Patterns and Design Principles
- Microservices-style separation where independent folders each represent loosely coupled services or labs.
- Infrastructure as Code (Terraform) pattern, where each lab’s resources are deployed and managed consistently.
- Design patterns such as fan-out messaging (both direct and autoscaled) used in the Cloud Functions examples.
- If applicable, indicate the incorporation of best practices like secure access (IAP for App Engine), serverless architectures (Cloud Functions), and event-driven systems (Pub/Sub).

##### Final Recommendation
- Drill down by showing individual labs within those groups where relevant (e.g., under Cloud Functions, show separate nodes for “basic HTTP trigger”, “basic Pub/Sub trigger”, “fan-out autoscale”, “fan-out direct”, etc.).
- Use clear, legible labels, consistent iconography, and an organized layout so that another engineer can quickly grasp the purpose of each lab and how they relate in a common GCP architecture experiments theme.

## Diagram (Mermaid)

```mermaid
flowchart TD
    TF("Terraform (IaC)"):::terraform

    subgraph "App Engine Labs"
        A_IAP["App Engine - IAP"]:::appengine
        A_Static["App Engine - Static Website"]:::appengine
    end

    subgraph "Cloud Functions Labs"
        CF_HTTP["Cloud Functions - Basic HTTP Trigger"]:::cloudfunctions
        CF_PubSub["Cloud Functions - Basic Pub/Sub Trigger"]:::cloudfunctions
        CF_FanOut_A["Cloud Functions - Fan-out Autoscale"]:::cloudfunctions
        CF_FanOut_D["Cloud Functions - Fan-out Direct"]:::cloudfunctions
        CF_Hono["Cloud Functions - Hono Example"]:::cloudfunctions
        CF_Logging["Cloud Functions - Logging Example"]:::cloudfunctions
    end

    subgraph "Pub/Sub Labs"
        PS_Dead["Pub/Sub - Dead Letter"]:::pubsub
        PS_Pull["Pub/Sub - Pull Messages"]:::pubsub
    end

    subgraph "DNS Lab"
        DNS["DNS Lab"]:::dns
    end

    subgraph "Runservices & SQL Labs"
        RS_LB["Runservices - Load Balancer Integration"]:::run
        SQL["SQL Lab"]:::sql
    end

    subgraph "Storage Labs"
        Storage["Storage - Static Website Hosting"]:::storage
    end

    subgraph "VM Labs"
        VM_Bigtable["VM Lab - Bigtable Emulator"]:::vm
        VM_Elastic["VM Lab - Elasticsearch"]:::vm
        VM_CF["VM Lab - Containerized Function"]:::vm
        VM_General["VM Lab - General COS Demo"]:::vm
    end

    %% Terraform provisioning arrows (dotted)
    TF -.-> A_IAP
    TF -.-> A_Static
    TF -.-> CF_HTTP
    TF -.-> CF_PubSub
    TF -.-> CF_FanOut_A
    TF -.-> CF_FanOut_D
    TF -.-> CF_Hono
    TF -.-> CF_Logging
    TF -.-> PS_Dead
    TF -.-> PS_Pull
    TF -.-> DNS
    TF -.-> RS_LB
    TF -.-> SQL
    TF -.-> Storage
    TF -.-> VM_Bigtable
    TF -.-> VM_Elastic
    TF -.-> VM_CF
    TF -.-> VM_General

    %% Interactions between labs
    CF_HTTP -->|"sends_trigger"| PS_Pull
    CF_PubSub -->|"triggers"| PS_Dead
    CF_FanOut_A -->|"fan-out"| CF_FanOut_D
    RS_LB -->|"integration"| SQL

    %% Click Events
    click A_IAP "https://github.com/kenrota/gcp-labs/blob/main/appengine/iap/app/main.py"
    click A_IAP "https://github.com/kenrota/gcp-labs/blob/main/appengine/iap/main.tf"
    click A_Static "https://github.com/kenrota/gcp-labs/tree/main/appengine/static-website/"
    click CF_HTTP "https://github.com/kenrota/gcp-labs/tree/main/functions/basic/http-trigger/"
    click CF_PubSub "https://github.com/kenrota/gcp-labs/tree/main/functions/basic/pubsub-trigger/"
    click CF_FanOut_A "https://github.com/kenrota/gcp-labs/tree/main/functions/fan-out-autoscale/"
    click CF_FanOut_D "https://github.com/kenrota/gcp-labs/tree/main/functions/fan-out-direct/"
    click CF_Hono "https://github.com/kenrota/gcp-labs/tree/main/functions/hono/"
    click CF_Logging "https://github.com/kenrota/gcp-labs/tree/main/functions/logging/"
    click PS_Dead "https://github.com/kenrota/gcp-labs/tree/main/pubsub/dead-letter/"
    click PS_Pull "https://github.com/kenrota/gcp-labs/tree/main/pubsub/pull-messages/"
    click DNS "https://github.com/kenrota/gcp-labs/tree/main/dns/"
    click RS_LB "https://github.com/kenrota/gcp-labs/tree/main/runservices/lb-integration/"
    click SQL "https://github.com/kenrota/gcp-labs/tree/main/sql/"
    click Storage "https://github.com/kenrota/gcp-labs/tree/main/storage/static-website/"
    click VM_Bigtable "https://github.com/kenrota/gcp-labs/tree/main/vm/cos-bigtable-emulator/"
    click VM_Elastic "https://github.com/kenrota/gcp-labs/tree/main/vm/cos-elasticsearch/"
    click VM_CF "https://github.com/kenrota/gcp-labs/tree/main/vm/cos-function/"
    click VM_General "https://github.com/kenrota/gcp-labs/tree/main/vm/cos/"

    %% Styles
    classDef appengine fill:#AEDFF7,stroke:#333,stroke-width:2px;
    classDef cloudfunctions fill:#C7F9CC,stroke:#333,stroke-width:2px;
    classDef pubsub fill:#F8D49D,stroke:#333,stroke-width:2px;
    classDef dns fill:#F9C274,stroke:#333,stroke-width:2px;
    classDef run fill:#A3E4D7,stroke:#333,stroke-width:2px;
    classDef sql fill:#FDE2E4,stroke:#333,stroke-width:2px;
    classDef storage fill:#FFD0B3,stroke:#333,stroke-width:2px;
    classDef vm fill:#E2C2F0,stroke:#333,stroke-width:2px;
    classDef terraform fill:#E0E0E0,stroke:#333,stroke-width:2px;
```
