# googleapis/google-cloud-rust architecture

> Architecture diagram of the GitHub repository googleapis/google-cloud-rust, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googleapis/google-cloud-rust
- Repository: https://github.com/googleapis/google-cloud-rust

## Overview

##### Main Components

a. Code Generator Component:
- Subcomponents:
- Parser (handles OpenAPI and Protobuf inputs)
- Language Templates (Rust and Go)
- Code Generation Engine

b. Core SDK Components:
- Authentication (auth module)
- GAX (Google API Extensions)
- Base Utilities
- Well-Known Types (wkt)

c. Generated Client Libraries:
- Output section containing:
- Cloud Services Clients (SecretManager, IAM, etc.)
- Common Components
- Generated Models

d. Testing & Validation:
- Integration Tests
- Echo Server
- Validation Tools

##### Relationships and Data Flow

- API Specifications (Protobuf/OpenAPI) → Generator → Generated Clients
- Generated Clients → Core Libraries
- Integration Tests → Generated Clients

##### Important Elements to Highlight

- Code Generation Pipeline
- Authentication & Authorization
- Error Handling System
- Transport Layer
- Testing Infrastructure

**┌─────────────────────────────────────────┐**
- Input Specifications         │
- (Protobuf Definitions, OpenAPI Specs) │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Generator System              │
- ┌─────────┐  ┌────────┐  ┌─────────┐  │
- Parser  │→ │ Engine │→ │Templates│  │
- ┘  └────────┘  └─────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Core SDK Components           │
- ┌─────────┐  ┌────────┐  ┌─────────┐  │
- Auth   │  │  GAX   │  │  WKT    │  │
- ┘  └────────┘  └─────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────┐**
- Generated Client Libraries      │
- ┌─────────┐  ┌────────┐  ┌─────────┐  │
- Cloud   │  │  IAM   │  │ Other   │  │
- Services │  │        │  │Services │  │
- ┘  └────────┘  └─────────┘  │
- ┘

##### Additional Notes

- Version information for major components
- Configuration points (like .sidekick.toml locations)
- Extension points for new service additions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        API[API Specifications]:::input
    end

    subgraph Generator
        Parser["Parser"]:::generator
        Engine["Generator Engine"]:::generator
        Templates["Language Templates"]:::generator
        Parser --> Engine
        Engine --> Templates
    end

    subgraph CoreSDK
        Auth["Authentication"]:::core
        GAX["Google API Extensions (GAX)"]:::core
        WKT["Well-Known Types"]:::core
        BaseUtils["Base Utilities"]:::core
    end

    subgraph GeneratedClients
        CloudServices["Cloud Services"]:::generated
        IAMClient["IAM Client"]:::generated
        SecretManager["Secret Manager"]:::generated
        LocationServices["Location Services"]:::generated
    end

    subgraph Testing
        IntegrationTests["Integration Tests"]:::testing
        EchoServer["Echo Server"]:::testing
        TestData["Test Data"]:::testing
    end

    subgraph AuthComponents
        UserCred["User Credentials"]:::auth
        MDSCred["MDS Credentials"]:::auth
        TokenMgmt["Token Management"]:::auth
    end

    %% Main Flow
    API --> Parser
    Templates --> GeneratedClients
    
    %% Dependencies
    GeneratedClients --> CoreSDK
    IntegrationTests --> GeneratedClients
    Auth --> AuthComponents
    
    %% Component Mappings
    click Parser "https://github.com/googleapis/google-cloud-rust/tree/main/generator/internal/parser"
    click Engine "https://github.com/googleapis/google-cloud-rust/tree/main/generator/internal/sidekick"
    click Templates "https://github.com/googleapis/google-cloud-rust/tree/main/generator/internal/language/templates"
    click Auth "https://github.com/googleapis/google-cloud-rust/tree/main/src/auth"
    click GAX "https://github.com/googleapis/google-cloud-rust/tree/main/src/gax"
    click WKT "https://github.com/googleapis/google-cloud-rust/tree/main/src/wkt"
    click BaseUtils "https://github.com/googleapis/google-cloud-rust/tree/main/src/base"
    click CloudServices "https://github.com/googleapis/google-cloud-rust/tree/main/src/generated/cloud"
    click IAMClient "https://github.com/googleapis/google-cloud-rust/tree/main/src/generated/iam"
    click SecretManager "https://github.com/googleapis/google-cloud-rust/tree/main/src/generated/cloud/secretmanager"
    click LocationServices "https://github.com/googleapis/google-cloud-rust/tree/main/src/generated/cloud/location"
    click IntegrationTests "https://github.com/googleapis/google-cloud-rust/tree/main/src/integration-tests"
    click EchoServer "https://github.com/googleapis/google-cloud-rust/tree/main/src/gax/echo-server"
    click TestData "https://github.com/googleapis/google-cloud-rust/tree/main/generator/testdata"
    click UserCred "https://github.com/googleapis/google-cloud-rust/blob/main/src/auth/src/credentials/user_credential.rs"
    click MDSCred "https://github.com/googleapis/google-cloud-rust/blob/main/src/auth/src/credentials/mds_credential.rs"
    click TokenMgmt "https://github.com/googleapis/google-cloud-rust/blob/main/src/auth/src/token.rs"

    %% Styling
    classDef input fill:#f9f,stroke:#333
    classDef generator fill:#90EE90,stroke:#333
    classDef core fill:#87CEEB,stroke:#333
    classDef generated fill:#FFA500,stroke:#333
    classDef testing fill:#DDA0DD,stroke:#333
    classDef auth fill:#B8860B,stroke:#333
```
