# google-gemini/angular-rock-paper-scissors-sample architecture

> Architecture diagram of the GitHub repository google-gemini/angular-rock-paper-scissors-sample, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google-gemini/angular-rock-paper-scissors-sample
- Repository: https://github.com/google-gemini/angular-rock-paper-scissors-sample

## Overview

##### Main System Components

a) Client-Side (Angular Application):
- Core Game Components (game.component)
- UI Components (about, footer, loading)
- Hand Recognition System
- Audio System
- Theme Manager

b) External Services Layer:
- TensorFlow.js Integration
- Gemini API (via Firebase Functions)
- Webcam Interface

##### Component Relationships and Data Flow

- User Interface → Webcam Feed
- Webcam Feed → TensorFlow.js Hand Detection
- Hand Detection → Fingerpose Classifier
- Game Logic → Firebase Functions → Gemini API
- Game State → Audio System
- Game State → UI Updates

##### Specific Implementation Details

Specialized components:
a) AI Strategy System:
- Random Strategy
- Anticipate Strategy
- Conditional Strategy
- Markov Strategy

b) Hand Recognition Pipeline:
- Flow:
- Video Input
- TensorFlow.js Processing
- Landmark Detection (21 points)
- Gesture Classification

##### Technical Stack Indicators

- Angular 17
- TensorFlow.js
- Firebase
- Gemini API
- WebRTC (for webcam)

##### Key Architectural Patterns

Patterns:
- Component-based architecture (Angular)
- Strategy Pattern (AI strategies)
- Service-based communication
- Event-driven interactions

##### Important Notes

Callouts for:
- API key handling through Firebase Functions
- Real-time hand gesture processing
- State management flow
- Audio feedback system

##### Infrastructure Layer

Remember to:
- Keep components aligned with the actual file structure
- Clear boundaries between client and server components
- Security boundaries around API key handling
- Version numbers for major dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph UI["User Interface Layer"]
        direction TB
        GC["Game Component"]:::component
        AB["About Component"]:::component
        FT["Footer Component"]:::component
        LD["Loading Component"]:::component
        TM["Theme Manager"]:::service
    end

    subgraph AL["Application Logic Layer"]
        direction TB
        GH["Game Handler"]:::service
        GS["Global Score"]:::service
        AH["Audio Handler"]:::service
        AS["Audio Service"]:::service
    end

    subgraph HR["Hand Recognition Layer"]
        direction TB
        HM["Handpose Manager"]:::service
        FH["Fingerpose Handler"]:::service
        HR["Hand Renderer"]:::service
        WC["Webcam Interface"]
        TF["TensorFlow.js"]
    end

    subgraph AI["AI Strategy Layer"]
        direction TB
        BS["Base Strategy"]:::service
        RS["Random Strategy"]:::service
        ANS["Anticipate Strategy"]:::service
        CS["Conditional Strategy"]:::service
        MS["Markov Strategy"]:::service
    end

    subgraph EX["External Services Layer"]
        direction TB
        GEM["Gemini API"]
        FF["Firebase Functions"]
    end

    %% Relationships
    GC --> GH
    GC --> HM
    GC --> AH
    HM --> FH
    HM --> HR
    HM --> WC
    WC --> TF
    GH --> AI
    GH --> FF
    FF --> GEM
    GH --> AS
    GH --> GS

    %% Click Events
    click GC "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/game.component.ts"
    click AB "https://github.com/google-gemini/angular-rock-paper-scissors-sample/tree/main/src/app/components/about"
    click FT "https://github.com/google-gemini/angular-rock-paper-scissors-sample/tree/main/src/app/components/footer"
    click LD "https://github.com/google-gemini/angular-rock-paper-scissors-sample/tree/main/src/app/components/loading"
    click TM "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/services/theme-manager.service.ts"
    click GH "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/game-handler.service.ts"
    click GS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/global-score.service.ts"
    click AH "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/audio-handler.service.ts"
    click AS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/audio.service.spec.ts"
    click HM "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/handpose-manager.service.ts"
    click FH "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/helpers/fingerpose-handler.ts"
    click HR "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/helpers/hand-renderer.ts"
    click BS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/ai-strategies/ai-strategy-base.ts"
    click RS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/ai-strategies/random-strategy.service.ts"
    click ANS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/ai-strategies/anticipate-strategy.service.ts"
    click CS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/ai-strategies/conditional-strategy.service.ts"
    click MS "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/src/app/pages/game/services/ai-strategies/markov-strategy.service.ts"
    click FF "https://github.com/google-gemini/angular-rock-paper-scissors-sample/blob/main/functions/src/index.ts"

    %% Styles
    classDef component fill:#2196F3,stroke:#1565C0,color:white
    classDef service fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black

    %% Legend
    subgraph Legend
        C1["Component"]:::component
        S1["Service"]:::service
        E1["External"]:::external
    end
```
