# durraniu/storytimegcp architecture

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

- Interactive diagram: https://gitdiagram.com/durraniu/storytimegcp
- Repository: https://github.com/durraniu/storytimegcp

## Overview

##### Main Components

a) Client Layer:
- Shiny UI (represented in app_ui.R)
- Web Browser Interface
- Static Assets (inst/app/www/)

b) Application Layer:
- Shiny Server (app_server.R)
- Core Application Logic (R/ directory)
- Configuration Management (app_config.R, golem-config.yml)

c) External Services:
- Cloudflare Workers AI
- Google Cloud Run (deployment platform)
- Shiny Apps.io (alternative deployment platform)

##### Component Relationships

- User interactions → Shiny UI → Shiny Server
- Shiny Server → Cloudflare Workers AI (for story generation)
- Configuration → Application (show environment variables flow)
- Deployment Platforms (show both options)

##### Specific Implementation Details

Key modules:
- Story Generation (get_story.R)
- Image Processing (req_single_image.R)
- Content Filtering (test_profanity.R)
- URL Management (base_url.R)

##### Architectural Patterns to Highlight

- Golem Framework Structure (indicated by the project structure)
- Model-View-Controller pattern (inherent in Shiny apps)
- Configuration Management (separate config files)

##### Technical Stack Indicators

Technologies:
- R/Shiny as the main framework
- Golem for project structure
- Cloudflare Workers AI integration
- Cloud deployment options

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI["Shiny UI"]:::client
        Browser["Web Browser"]:::client
        Assets["Static Assets"]:::client
    end

    subgraph Application
        Server["Shiny Server"]:::server
        AppLogic["Core Application Logic"]:::server
        Config["Configuration Management"]:::config
        
        subgraph Modules
            Story["Story Generation"]:::module
            Image["Image Processing"]:::module
            Filter["Content Filtering"]:::module
            URL["URL Management"]:::module
        end
        
        subgraph Configuration
            EnvVars["Environment Variables"]:::config
            ConfigFiles["Config Files"]:::config
        end
    end

    subgraph "External Services"
        CloudflareAI["Cloudflare Workers AI"]:::external
        GCloudRun["Google Cloud Run"]:::external
        ShinyApps["Shiny Apps.io"]:::external
    end

    subgraph Development
        DevTools["Development Tools"]:::dev
        Deploy["Deployment Config"]:::dev
    end

    Browser --> UI
    UI --> Server
    Server --> AppLogic
    AppLogic --> Story
    AppLogic --> Image
    AppLogic --> Filter
    AppLogic --> URL
    
    Story --> CloudflareAI
    Image --> CloudflareAI
    
    Config --> EnvVars
    Config --> ConfigFiles
    
    EnvVars --> AppLogic
    ConfigFiles --> AppLogic
    
    Assets --> UI
    
    AppLogic --> GCloudRun
    AppLogic --> ShinyApps
    
    DevTools --> Deploy
    Deploy --> GCloudRun
    Deploy --> ShinyApps

    %% Click Events
    click UI "https://github.com/durraniu/stoRytimegcp/blob/main/R/app_ui.R"
    click Server "https://github.com/durraniu/stoRytimegcp/blob/main/R/app_server.R"
    click Assets "https://github.com/durraniu/stoRytimegcp/tree/main/inst/app/www/"
    click Config "https://github.com/durraniu/stoRytimegcp/blob/main/R/app_config.R"
    click ConfigFiles "https://github.com/durraniu/stoRytimegcp/blob/main/inst/golem-config.yml"
    click Story "https://github.com/durraniu/stoRytimegcp/blob/main/R/get_story.R"
    click Image "https://github.com/durraniu/stoRytimegcp/blob/main/R/req_single_image.R"
    click Filter "https://github.com/durraniu/stoRytimegcp/blob/main/R/test_profanity.R"
    click URL "https://github.com/durraniu/stoRytimegcp/blob/main/R/base_url.R"
    click DevTools "https://github.com/durraniu/stoRytimegcp/tree/main/dev/"
    click Deploy "https://github.com/durraniu/stoRytimegcp/tree/main/rsconnect/shinyapps.io/"
    click AppLogic "https://github.com/durraniu/stoRytimegcp/blob/main/R/app_global.R"

    %% Styling
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef config fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef module fill:#9b59b6,stroke:#8e44ad,color:white
    classDef dev fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Client Components"]:::client
        L2["Server Components"]:::server
        L3["Configuration"]:::config
        L4["External Services"]:::external
        L5["Application Modules"]:::module
        L6["Development Tools"]:::dev
    end
```
