# bhanu1776/gcp-media-viewer architecture

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

- Interactive diagram: https://gitdiagram.com/bhanu1776/gcp-media-viewer
- Repository: https://github.com/bhanu1776/gcp-media-viewer

## Overview

a. User Interface (UI) Layer:
- Next.js App Shell: Encompassing components such as layout.tsx and globals.css, which set the global styling and layout for pages.
- Application Pages: Represented by page.tsx in the src/app directory.
- UI Components Library: All components under src/components/ui (button, card, dialog, form, input, label, sheet, switch) that build out the reusable UI elements.
- Feature-Specific UI Components: These include media-viewer.tsx, settings-modal.tsx, url-input.tsx, theme-provider.tsx, and theme-toggle.tsx.
b. Application Logic & State Management:
- Business logic and utility functions located in src/lib (e.g., store.ts for state management and utils.ts for helper functions).
c. Configuration and Styles:
- Tailwind CSS configuration (tailwind.config.ts, postcss.config.mjs) for styling.
- Prettier, ESLint, and Husky pre-commit hooks to maintain code quality.
- Next.js specific configuration (next.config.ts) for application behavior.
d. External Services:
- Google Cloud Storage: Represent the external GCP storage service that is integrated by constructing the full URL from user input to fetch and display media.
- Browser Storage: Indicate local storage usage or state management for settings persistence (eg., Base URL configuration).

##### Architectural Patterns and Design Principles
- Use of client‐side state management (via a store in src/lib/store.ts) to maintain settings like theme and base URL data.
- The file structure suggests a clear organization based around Next.js’s app directory, which aligns with modern React/Next.js practices.
- Responsive design aspect by showing that the “UI Layer” is built with Tailwind CSS, ensuring that components are styled for different platforms (desktop, mobile).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User Node
    User("User"):::user

    %% User Interface Layer Subgraph
    subgraph "User Interface Layer"
        NextShell("Next.js App Shell"):::ui
        AppPages("Application Pages"):::ui
        ReusableUI("Reusable UI Components Library"):::ui
        subgraph "Feature-Specific UI Components"
            MediaViewer("Media Viewer Component"):::ui
            SettingsModal("Settings Modal"):::ui
            URLInput("URL Input Component"):::ui
            ThemeProvider("Theme Provider"):::ui
            ThemeToggle("Theme Toggle"):::ui
        end
    end

    %% Application Logic & State Management Subgraph
    subgraph "Application Logic & State Management"
        StateMgmt("State Management & Utilities"):::state
    end

    %% Configuration and Styling Subgraph
    subgraph "Configuration and Styling"
        Config("Configuration & Styling"):::config
    end

    %% External Services Subgraph
    subgraph "External Services"
        GCP("GCP Storage"):::external
        BrowserStorage("Browser Storage"):::external
    end

    %% Relationships
    User -->|"input"| URLInput
    User -->|"open"| SettingsModal
    SettingsModal <-->|"sync"| StateMgmt
    URLInput -->|"processUrl"| MediaViewer
    MediaViewer -->|"fetchMedia"| GCP
    StateMgmt <-->|"persist"| BrowserStorage
    ThemeProvider -->|"applyTheme"| NextShell
    ThemeToggle -->|"toggle"| NextShell
    NextShell -->|"renders"| AppPages
    AppPages -->|"uses"| ReusableUI
    Config -->|"configures"| NextShell

    %% Click Events for Component Mapping
    click NextShell "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/app/layout.tsx"
    click NextShell "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/app/globals.css"
    click AppPages "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/app/page.tsx"
    click ReusableUI "https://github.com/bhanu1776/gcp-media-viewer/tree/main/src/components/ui"
    click MediaViewer "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/components/media-viewer.tsx"
    click SettingsModal "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/components/settings-modal.tsx"
    click URLInput "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/components/url-input.tsx"
    click ThemeProvider "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/components/theme-provider.tsx"
    click ThemeToggle "https://github.com/bhanu1776/gcp-media-viewer/blob/main/src/components/theme-toggle.tsx"
    click StateMgmt "https://github.com/bhanu1776/gcp-media-viewer/tree/main/src/lib"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/next.config.ts"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/tailwind.config.ts"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/postcss.config.mjs"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/.eslintrc.json"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/.prettierrc"
    click Config "https://github.com/bhanu1776/gcp-media-viewer/blob/main/.husky"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef state fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef config fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef user fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
