# googlecloudplatform/genai-for-marketing architecture

> Architecture diagram of the GitHub repository googlecloudplatform/genai-for-marketing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/genai-for-marketing
- Repository: https://github.com/googlecloudplatform/genai-for-marketing

## Overview

##### Project type and purpose
- This is a full-stack, cloud-native marketing solution that uses Google Cloud’s Generative AI services.
- The Angular-based frontend drives various marketing use cases (insights, content generation, trendspotting, search).
- The Python backend (in backend_apis/) exposes REST endpoints, orchestrates calls to BigQuery, Vertex AI (text+vision models), Firebase, GCS, Workspace APIs and Looker.
- Terraform (infra/) codifies all cloud resources.

##### File structure
- Top-level directories:
- backend_apis/ – Python app that wraps AI, database and external service calls
- frontend/ – Angular application (components, services, routing)
- infra/ – Terraform modules, BigQuery schemas, IAM, deployment scripts
- notebooks/ – Jupyter demos illustrating the AI workflows
- templates/ – slide/doc templates for Workspace integration
- Key config files:
- app.yaml – App Engine config for frontend (or gRPC proxy)
- backend_apis/Dockerfile & requirements.txt – containerizing the Python APIs
- infra/*.tf – Terraform resources: Cloud Run/App Engine, BigQuery, IAM, GCS buckets, Vertex AI endpoints
- infra/templates/config.toml.tftpl → config.toml for AI prompts/models

##### README for additional insights
- Frontend UI
- Backend APIs
- BigQuery
- Vertex AI (Search + Generative Models)
- Google Workspace and Looker
- It calls out:
- Marketing Insights (Looker dashboards)
- Audience Q&A (natural language→SQL)
- Trendspotting (Vertex+BigQuery+news summarization)
- Content Search (Vertex AI Search)
- Content Generation (Vertex Text & Vision models)
- Workspace integration (Docs, Slides, Sheets)

##### Essential architectural elements – don’t miss
- Stateless containerized API calling multiple AI endpoints
- Angular routing to various “demos” (trendspotting, copy generation)
- BigQuery as the analytics store feeding dashboards and Q&A
- Vertex AI Search layer in front of content index
- Google Workspace integration for automated asset delivery
- Terraform provisioning, sample tfvars by vertical

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FUI["Angular SPA"]:::frontend
        MI["Marketing Insights Component"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        API["Python API (Cloud Run/App Engine)"]:::api
        MAIN["main.py"]:::api
        DOCKER["Dockerfile"]:::api
        REQ["requirements.txt"]:::api
        BODY["body_schema.py"]:::api
        U_GCS["utils_gcs.py"]:::api
        U_FIRE["utils_firebase.py"]:::api
        U_PROMPT["utils_prompt.py"]:::api
        U_SEARCH["utils_search.py"]:::api
        U_WS["utils_workspace.py"]:::api
    end

    %% Google Cloud AI & Data
    subgraph "Google Cloud AI & Data"
        direction TB
        BQ["BigQuery"]:::data
        GCS["Cloud Storage (GCS)"]:::data
        FIRESTORE["Firebase Auth/Firestore"]:::data
        subgraph "Vertex AI" 
            direction TB
            VA_TEXT["PaLM Text Models"]:::ai
            VA_VISION["Vision/Image Models"]:::ai
            VA_SEARCH["Vertex AI Search"]:::ai
        end
    end

    %% Integrations
    subgraph "External Integrations"
        direction TB
        LOOKER["Looker Dashboards"]:::integration
        WS["Google Workspace APIs"]:::integration
    end

    %% Infra & Dev Tools
    subgraph "Infrastructure & Dev Tools"
        direction TB
        TF["Terraform"]:::infra
        SCRIPTS["CI/CD Scripts"]:::infra
    end

    %% Demo Artifacts
    subgraph "Demo & Templates"
        direction TB
        NB["Jupyter Notebooks"]:::demo
        TMPL["Slide/Doc Templates"]:::demo
    end

    %% Connections
    FUI -->|"HTTP/REST"| API
    MI -->|"iframe embed"| LOOKER
    API -->|"SQL"| BQ
    API -->|"HTTP"| GCS
    API -->|"Auth"| FIRESTORE
    API -->|"Text Gen"| VA_TEXT
    API -->|"Image Gen"| VA_VISION
    API -->|"Search"| VA_SEARCH
    API -->|"HTTP"| WS
    TF -->|"provisions"| API
    TF -->|"provisions"| BQ
    TF -->|"provisions"| GCS
    TF -->|"provisions"| VA_TEXT
    TF -->|"provisions"| VA_VISION
    TF -->|"provisions"| VA_SEARCH
    TF -->|"provisions"| FIRESTORE
    TF -->|"provisions"| LOOKER
    SCRIPTS -->|"deploy"| API
    SCRIPTS -->|"deploy"| FUI
    NB -->|"demo workflows"| API
    TMPL -->|"used by"| WS

    %% Click Events
    click FUI "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/frontend/"
    click MI "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/frontend/src/app/marketing-insights/marketing-insights.component.ts"
    click API "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/backend_apis/"
    click MAIN "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/main.py"
    click DOCKER "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/backend_apis/Dockerfile"
    click REQ "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/requirements.txt"
    click BODY "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/body_schema.py"
    click U_GCS "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/utils_gcs.py"
    click U_FIRE "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/utils_firebase.py"
    click U_PROMPT "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/utils_prompt.py"
    click U_SEARCH "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/utils_search.py"
    click U_WS "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/backend_apis/app/utils_workspace.py"
    click BQ "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/infra/bq-schemas/"
    click TF "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/infra/"
    click SCRIPTS "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/infra/scripts/"
    click NB "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/notebooks/"
    click TMPL "https://github.com/googlecloudplatform/genai-for-marketing/tree/main/templates/"
    click config "https://github.com/googlecloudplatform/genai-for-marketing/blob/main/infra/templates/config.toml.tftpl"

    %% Styles
    classDef frontend fill:#e0f3ff,stroke:#005b96,color:#005b96;
    classDef api fill:#d0e8ff,stroke:#1a73e8,color:#1a73e8;
    classDef data fill:#e8f5e9,stroke:#2e7d32,color:#2e7d32;
    classDef ai fill:#fff3e0,stroke:#f57c00,color:#f57c00;
    classDef integration fill:#f3e5f5,stroke:#6a1b9a,color:#6a1b9a;
    classDef infra fill:#eeeeee,stroke:#757575,color:#424242;
    classDef demo fill:#e1f5fe,stroke:#0277bd,color:#0277bd;
```
