# 2096955/gcpdevgenius architecture

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

- Interactive diagram: https://gitdiagram.com/2096955/gcpdevgenius
- Repository: https://github.com/2096955/gcpdevgenius

## Overview

##### Project Type and Purpose
- This is a full-stack, AI-powered GCP solution architect tool.
- It provides an interactive Streamlit frontend for users to design GCP architectures via natural-language chat, and generates infrastructure-as-code (Terraform, CDK, Deployment Manager), cost estimates, and documentation.

##### File Structure Analysis
- Top-level directories and files:
- .cursor, .roo, .roomodes: internal rules/workflows for the AI agent.
- chatbot/: Python Streamlit app and modules (chat engine, A2A agents, code generators, utils, tests, styles).
- lib/: serverless functions (edge Lambda in JS, Python Lambdas for specific tasks) and a shared Python layer.
- scripts/: CLI utilities (GCP dependency checks, reports).
- cdk.json, tsconfig.json, package.json: Node/CDK configurations.
- requirements.txt & chatbot/requirements.txt: Python dependencies.
- Inside chatbot/:
- agent.py: Streamlit entrypoint.
- a2a/: Agent-to-agent framework (agents, client/server, base classes).
- gemini/: abstraction for Vertex AI.
- dynamodb.py, upload.py, utils.py: local JSON storage and utility functions.

##### Insights from README
- Frontend: Streamlit UI.
- AI integration: Vertex AI (via gemini/provider).
- Local JSON storage for chat logs and feedback.
- Infrastructure-as-Code outputs: Terraform, Deployment Manager, CDK.
- Cost estimation via GCP Pricing APIs.
- Optional A2A (Agent-to-Agent) orchestration.

a. Main Components
- Streamlit Frontend
- Chat Engine / Orchestrator (agent.py + layout/styles)
- A2A Framework & Agents (code conversion, data migration, host agent)
- AI Provider: Vertex AI
- IAC Generators: Terraform Generator, CDK Generator, Deployment Manager Generator
- Cost Estimator & Documentation Generator
- Storage: Local JSON files (and optional DynamoDB)
- GCP Integration Layer (REST/gRPC calls to Compute, IAM, Pricing APIs)
- Serverless Artifacts: Edge Lambda, Python Lambdas
- CLI Utilities (scripts/)
b. Relationships and Data Flows
- User → Streamlit UI → Chat Engine
- Chat Engine ↔ A2A Framework ↔ Specialized Agents
- Chat Engine → Vertex AI Provider → AI responses
- Chat Engine → IAC Generators → Template files
- Chat Engine → Cost Estimator → GCP Pricing API → Cost data
- Generators & Estimator → Storage (local JSON or DynamoDB)
- CLI scripts invoke underlying modules directly for reports or checks
- Lib Lambdas are packaged as deployable artifacts for edge or serverless deployment
c. Architectural Patterns
- MVC-style separation: Streamlit (View) / agent.py (Controller) / generate_*/utils (Model)
- Plugin-like modules for each IAC type
- Internal micro-workflow via Agent-to-Agent calls
- External abstraction layer for AI provider (gemini) and GCP APIs
d. Key Technologies
- Python 3.10+, Streamlit
- Vertex AI (via gemini/provider)
- Terraform, AWS-style CDK (Node.js 16+), Google Deployment Manager
- GCP REST APIs (Compute, IAM, Pricing)
- Node.js & TypeScript for CDK integration
- Local JSON storage, optional DynamoDB

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User"]:::external
    User -->|"interacts with"| UI

    %% Frontend Layer
    subgraph Frontend
        direction TB
        Agent["agent.py"]:::frontend
        Layout["layout.py"]:::frontend
        Styles["styles.py"]:::frontend
        RunStreamlit["run_streamlit.sh"]:::frontend
        RunA2A["run_streamlit_with_a2a.sh"]:::frontend
    end
    UI["Streamlit UI"]:::frontend
    UI --> Agent
    click Agent "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/agent.py"
    click Layout "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/layout.py"
    click Styles "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/styles.py"
    click RunStreamlit "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/run_streamlit.sh"
    click RunA2A "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/run_streamlit_with_a2a.sh"

    %% Backend Services
    subgraph "Backend Services"
        direction TB
        ChatEngine["Chat Engine / Orchestrator"]:::service
        A2A["A2A Framework & Agents"]:::service
        AIProvider["Vertex AI Provider"]:::external
        TFGen["Terraform Generator"]:::service
        CDKGen["CDK Generator"]:::service
        DMGen["Deployment Manager Generator"]:::service
        CFNGen["CloudFormation Generator"]:::service
        ArchGen["Architecture Diagram Generator"]:::service
        DocGen["Documentation Generator"]:::service
        CostEst["Cost Estimator"]:::service
        Placeholder["Placeholder Image Generator"]:::service
        Storage["Local JSON Storage / DynamoDB"]:::storage
        GCPInt["GCP API Integration"]:::external
    end

    %% Backend interconnections
    Agent --> ChatEngine
    ChatEngine --> A2A
    ChatEngine --> AIProvider
    ChatEngine --> TFGen
    ChatEngine --> CDKGen
    ChatEngine --> DMGen
    ChatEngine --> CFNGen
    ChatEngine --> ArchGen
    ChatEngine --> DocGen
    ChatEngine --> CostEst
    ChatEngine --> Placeholder
    TFGen --> Storage
    CDKGen --> Storage
    DMGen --> Storage
    CFNGen --> Storage
    ArchGen --> Storage
    DocGen --> Storage
    CostEst --> GCPInt
    CostEst --> Storage

    %% Click events for backend components
    click ChatEngine "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/utils.py"
    click ChatEngine "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/upload.py"
    click ChatEngine "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/dynamodb.py"
    click A2A "https://github.com/2096955/gcpdevgenius/tree/main/chatbot/a2a/"
    click AIProvider "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/gemini/provider.py"
    click TFGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_terraform_widget.py"
    click CDKGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_cdk_widget.py"
    click DMGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_dm_widget.py"
    click CFNGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_cfn_widget.py"
    click ArchGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_arch_widget.py"
    click DocGen "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_doc_widget.py"
    click CostEst "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/cost_estimate_widget.py"
    click Placeholder "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/generate_placeholder_image.py"
    click Storage "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/dynamodb.py"
    click Storage "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/upload.py"
    click GCPInt "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/test_gcp_auth.py"
    click GCPInt "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/test_gcp_clients.py"

    %% Deployable Artifacts
    subgraph "Deployable Artifacts"
        direction TB
        EdgeLambda["Edge Lambda (JS)"]:::service
        PyLambdas["Python Lambdas"]:::service
        SharedLayer["Shared Python Layer"]:::storage
    end
    EdgeLambda --> SharedLayer
    PyLambdas --> SharedLayer

    click EdgeLambda "https://github.com/2096955/gcpdevgenius/blob/main/lib/edge-lambda/index.js"
    click EdgeLambda "https://github.com/2096955/gcpdevgenius/blob/main/lib/edge-lambda/secretsManager.js"
    click EdgeLambda "https://github.com/2096955/gcpdevgenius/blob/main/lib/edge-lambda/package.json"
    click PyLambdas "https://github.com/2096955/gcpdevgenius/blob/main/lib/lambda/kb_ds.py"
    click PyLambdas "https://github.com/2096955/gcpdevgenius/blob/main/lib/lambda/oss_index.py"
    click PyLambdas "https://github.com/2096955/gcpdevgenius/blob/main/lib/lambda/prefix_list.py"
    click SharedLayer "https://github.com/2096955/gcpdevgenius/blob/main/lib/layer/requirements.txt"

    %% CLI Utilities
    subgraph "CLI Utilities"
        direction TB
        CLI1["gcp_dependency_check.py"]:::service
        CLI2["example_prd.txt"]:::service
        CLI3["prd.txt"]:::service
    end
    CLI1 -->|"uses modules"| ChatEngine
    CLI2 --> ChatEngine
    CLI3 --> ChatEngine

    click CLI1 "https://github.com/2096955/gcpdevgenius/blob/main/scripts/gcp_dependency_check.py"
    click CLI2 "https://github.com/2096955/gcpdevgenius/blob/main/scripts/example_prd.txt"
    click CLI3 "https://github.com/2096955/gcpdevgenius/blob/main/scripts/prd.txt"

    %% Configuration Files
    Configs["CDK & Node Configs"]:::service
    Deps["Python Dependencies"]:::service
    Configs --> CDKGen
    Deps --> Agent

    click Configs "https://github.com/2096955/gcpdevgenius/blob/main/cdk.json"
    click Configs "https://github.com/2096955/gcpdevgenius/blob/main/tsconfig.json"
    click Configs "https://github.com/2096955/gcpdevgenius/blob/main/package.json"
    click Configs "https://github.com/2096955/gcpdevgenius/blob/main/package-lock.json"
    click Deps "https://github.com/2096955/gcpdevgenius/blob/main/requirements.txt"
    click Deps "https://github.com/2096955/gcpdevgenius/blob/main/chatbot/requirements.txt"

    %% External Services
    subgraph External
        direction TB
        VertexAI["Vertex AI"]:::external
        GCPAPIs["GCP Compute/IAM/Pricing APIs"]:::external
    end
    AIProvider --> VertexAI
    GCPInt --> GCPAPIs

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366d6,color:#0366d6;
    classDef service fill:#DFFFE0,stroke:#228C22,color:#228C22;
    classDef external fill:#FFE0B2,stroke:#FF8C00,color:#FF8C00;
    classDef storage fill:#E0E0E0,stroke:#696969,color:#333333;
```
