# devrajdc/dc-code-screenshot architecture

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

- Interactive diagram: https://gitdiagram.com/devrajdc/dc-code-screenshot
- Repository: https://github.com/devrajdc/dc-code-screenshot

## Overview

##### Main components
- App Entry Point: Start with the main mounting point (src/main.jsx) that renders the <App /> component (src/App.jsx).
- UI Layout & Components: Break down the visual components into two major groups:
- Code Display and Editor: Components like CodeEditor.jsx under src/components, which integrate “react-simple-code-editor” and “highlight.js”.
- Control Panel Components: All controls are under src/components/controls (e.g., DarkModeSwitch.jsx, FontSelect.jsx, ExportOptions.jsx, etc.) and UI components under src/components/ui (button, card, dropdown, etc.).
- State Management: The state is managed (likely using Zustand, as mentioned in the README) in files such as src/store.js and possibly integrated with components via the React context.
- Utility and Options: Helper logic found in src/lib/utils.js and configuration logic under src/options.js.
- Styling/Configuration: Tools like Tailwind CSS (tailwind.config.js, postcss.config.js), Vite (vite.config.js), and other build configuration files define how the project is built and styled.
- Static Resources: index.html and public directory signify static assets that support the front-end deployment.

##### Relationships and Interactions
- The entry point (main.jsx) initializes the whole React application by rendering App.jsx.
- Inside App.jsx, the layout is divided between the code display area (with CodeEditor.jsx) and the control panel for customizing theme, font, language, padding, etc.
- The control components communicate changes to the global state managed by Zustand (store.js). The state changes affect both the visual styling (via Tailwind CSS classes) and the preview output.
- The integration of external libraries is clear: "react-simple-code-editor" for the editor UI, "highlight.js" for syntax highlighting, "html-to-image" for export functionalities, and additional libraries for toast notifications and hotkeys.
- User actions in the control panel (clicks, key presses) trigger state updates via store.js, which in turn update the code snippet display that can then be exported.

##### Architectural Patterns & Design Principles
- Separation of Concerns: There’s a clear distinction between UI controls (potentially “dumb” or presentational components) and the state management layer (via Zustand). Similarly, styling is isolated to Tailwind CSS classes.
- Extensibility: The modular structure of having a separate folder for controls and UI indicates that new functionalities or themes can be added without major refactoring.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Layer
    subgraph "Entry Layer"
        entryIndex("index.html"):::static
        main("main.jsx"):::entry
    end

    %% App Layer
    subgraph "App Layer"
        app("App.jsx"):::app
    end

    %% UI Layer
    subgraph "UI Layer"
        codeEditor("CodeEditor.jsx"):::editor
        subgraph "Control Panel Components"
            darkMode("DarkModeSwitch.jsx"):::control
            exportOptions("ExportOptions.jsx"):::control
            fontSelect("FontSelect.jsx"):::control
            fontSize("FontSizeInput.jsx"):::control
            languageSelect("LanguageSelect.jsx"):::control
            padding("PaddingSlider.jsx"):::control
            themeSelect("ThemeSelect.jsx"):::control
        end
        uiElements("UI Elements"):::ui
    end

    %% State and Utility
    subgraph "State & Utility"
        store("store.js"):::state
        utils("utils.js"):::util
        options("options.js"):::util
    end

    %% Configurations
    subgraph "Configurations"
        tailwind("tailwind.config.js"):::config
        postcss("postcss.config.js"):::config
        vite("vite.config.js"):::config
    end

    %% Static Assets
    subgraph "Static Assets"
        public("public/"):::static
    end

    %% External Libraries
    subgraph "External Libraries"
        react("React"):::external
        simpleEditor("react-simple-code-editor"):::external
        highlight("highlight.js"):::external
        htmlToImage("html-to-image"):::external
        hotToast("react-hot-toast"):::external
        zustand("Zustand"):::external
    end

    %% Connections
    entryIndex --> main
    main --> app
    app --> codeEditor
    app --> darkMode
    app --> exportOptions
    app --> fontSelect
    app --> fontSize
    app --> languageSelect
    app --> padding
    app --> themeSelect
    app --> uiElements

    darkMode --> store
    exportOptions --> store
    fontSelect --> store
    fontSize --> store
    languageSelect --> store
    padding --> store
    themeSelect --> store
    codeEditor --> store

    codeEditor -- "Uses"--> simpleEditor
    codeEditor -- "Uses"--> highlight

    exportOptions -- "ExportsTo"--> htmlToImage

    app -- "StateManagedBy"--> store
    store -- "Utilizes"--> zustand
    uiElements -- "StyledUsing"--> tailwind
    app -- "BuiltWith"--> react

    utils --- store
    options --- store

    darkMode --> uiElements
    exportOptions --> uiElements
    fontSelect --> uiElements
    fontSize --> uiElements
    languageSelect --> uiElements
    padding --> uiElements
    themeSelect --> uiElements

    public --> entryIndex

    app --- vite
    app --- postcss

    app -- "ShowsNotifications"--> hotToast

    %% Styles
    classDef entry fill:#f39c12,stroke:#333,stroke-width:2px;
    classDef app fill:#3498db,stroke:#333,stroke-width:2px;
    classDef editor fill:#2ecc71,stroke:#333,stroke-width:2px;
    classDef control fill:#9b59b6,stroke:#333,stroke-width:2px;
    classDef ui fill:#e67e22,stroke:#333,stroke-width:2px;
    classDef state fill:#e74c3c,stroke:#333,stroke-width:2px;
    classDef util fill:#1abc9c,stroke:#333,stroke-width:2px;
    classDef config fill:#34495e,stroke:#333,stroke-width:2px;
    classDef static fill:#95a5a6,stroke:#333,stroke-width:2px;
    classDef external fill:#7f8c8d,stroke:#333,stroke-width:2px;

    %% Click Events
    click main "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/main.jsx"
    click app "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/App.jsx"
    click codeEditor "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/CodeEditor.jsx"
    click darkMode "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/DarkModeSwitch.jsx"
    click exportOptions "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/ExportOptions.jsx"
    click fontSelect "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/FontSelect.jsx"
    click fontSize "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/FontSizeInput.jsx"
    click languageSelect "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/LanguageSelect.jsx"
    click padding "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/PaddingSlider.jsx"
    click themeSelect "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/components/controls/ThemeSelect.jsx"
    click uiElements "https://github.com/devrajdc/dc-code-screenshot/tree/main/src/components/ui"
    click store "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/store.js"
    click utils "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/lib/utils.js"
    click options "https://github.com/devrajdc/dc-code-screenshot/blob/main/src/options.js"
    click tailwind "https://github.com/devrajdc/dc-code-screenshot/blob/main/tailwind.config.js"
    click postcss "https://github.com/devrajdc/dc-code-screenshot/blob/main/postcss.config.js"
    click vite "https://github.com/devrajdc/dc-code-screenshot/blob/main/vite.config.js"
    click entryIndex "https://github.com/devrajdc/dc-code-screenshot/blob/main/index.html"
    click public "https://github.com/devrajdc/dc-code-screenshot/tree/main/public"
```
