# philschmid/gemini-samples architecture

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

- Interactive diagram: https://gitdiagram.com/philschmid/gemini-samples
- Repository: https://github.com/philschmid/gemini-samples

## Overview

##### Main Components
- External Service – Google DeepMind Gemini Models (and Gemma 3 27B for some experiments). Represent this as an external API/service node.
- Client and Experiment Interfaces – This repository’s examples (the Jupyter notebooks in the “examples” folder, guides in the “guides” folder, JavaScript examples, and the Python script in “scripts”) act as experimental clients or integration samples that invoke the Gemini (or Gemma) models via configured APIs.
- Assets & Supporting Files – The “assets” directory (for media like porsche.mp3) is a minor component used for experiments (e.g., audio transcription).
- Environment & Configuration – Although not physically a directory, the README instructs users to create a .env file (for the GEMINI_API_KEY) which configures access to external APIs.
- Documentation & Guides – The “README.md” and “guides” folder provide instructions on setup and usage, which is essential for understanding interactions between components.

##### Relationships and Interactions
- Directional flows from the experimental modules (various notebooks, scripts, JavaScript examples) toward the external Gemini/Gemma API. Each experiment’s purpose can be annotated (for instance, “Gemini with OpenAI SDK” or “Gemini Transcription with Timestamps”).
- That the experiments handle tasks such as integrating with Google Search, generating structured JSON outputs (by means of libraries like Pydantic), handling audio transcription, or generating native images.
- That the guides support these experiments by explaining how to implement techniques like function calling.

##### Architectural Patterns & Design Principles
- Separation of Concerns – Different folders clearly separate sample experiments, guides, and language-specific examples.
- Modularity – Each example or guide acts as a standalone use case for a particular experiment (a “plug-and-play” design showcasing extensibility).

##### Technologies, Frameworks, & Libraries
- For Python, Jupyter Notebooks (ipynb files) demonstrating integration logic.
- JavaScript examples that show how to interact with the Gemini models.
- Possibly backend libraries for processing (like Pydantic for JSON schema validations in structured output examples).
- API key management via environment configuration (the suggested .env file).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External API
    EAPI["Google DeepMind Gemini API"]:::external

    %% Python Experiments Subgraph
    subgraph "Python Experiments"
        PN1["gemini-with-openai-sdk.ipynb"]:::python
        PS1["gemini-browser-use.py"]:::python
    end

    %% JavaScript Experiments Subgraph
    subgraph "JavaScript Experiments"
        JS1["gemini-native-image-out.js"]:::js
    end

    %% Documentation & Guides Subgraph
    subgraph "Documentation & Guides"
        DOC1["README.md"]:::doc
        DOC2["function-calling.ipynb"]:::doc
    end

    %% Supporting Assets & Configuration Subgraph
    subgraph "Supporting"
        ASSET["porsche.mp3"]:::asset
        CONFIG[".env Configuration"]:::config
    end

    %% Connections from Experiments to External API
    PN1 -->|"calls"| EAPI
    PS1 -->|"calls"| EAPI
    JS1 -->|"calls"| EAPI

    %% Documentation supports Experiments
    DOC1 -->|"guides"| PN1
    DOC1 -->|"guides"| PS1
    DOC1 -->|"guides"| JS1
    DOC2 -->|"guides"| PN1
    DOC2 -->|"guides"| PS1
    DOC2 -->|"guides"| JS1

    %% Supporting resources used by Experiments
    ASSET -->|"used_by"| PN1
    ASSET -->|"used_by"| JS1
    CONFIG -->|"configures"| PN1
    CONFIG -->|"configures"| PS1
    CONFIG -->|"configures"| JS1

    %% Click Events
    click PN1 "https://github.com/philschmid/gemini-samples/blob/main/examples/gemini-with-openai-sdk.ipynb"
    click PS1 "https://github.com/philschmid/gemini-samples/blob/main/scripts/gemini-browser-use.py"
    click JS1 "https://github.com/philschmid/gemini-samples/blob/main/javascript-examples/gemini-native-image-out.js"
    click DOC1 "https://github.com/philschmid/gemini-samples/blob/main/README.md"
    click DOC2 "https://github.com/philschmid/gemini-samples/blob/main/guides/function-calling.ipynb"
    click ASSET "https://github.com/philschmid/gemini-samples/blob/main/assets/porsche.mp3"

    %% Styles
    classDef external fill:#B3E5FC,stroke:#039BE5,stroke-width:2px;
    classDef python fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef js fill:#FFE0B2,stroke:#F57C00,stroke-width:2px;
    classDef doc fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
    classDef asset fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef config fill:#CFD8DC,stroke:#607D8B,stroke-width:2px;
```
