# whaoa/markdown-nice architecture

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

- Interactive diagram: https://gitdiagram.com/whaoa/markdown-nice
- Repository: https://github.com/whaoa/markdown-nice

## Overview

##### Project Type and Purpose
- Project Type: A single-page application (SPA) focused on markdown editing and previewing.
- Purpose: To provide users with a rich in-browser markdown editor featuring various themes, dialogs, and built-in functionality (e.g., image hosting, local history). It customizes the original markdown-nice project by removing some features (login, theme store, update prompts) and adding themes like “极简黑” and “凝夜紫”.

##### File Structure
- Build & Configuration:
- Top-level configuration files (e.g., .eslintrc, .prettierrc, webpack configs in the “config” folder) reflect a modern JavaScript development setup.
- Scripts directory includes build, start, and test scripts.
- Public Assets:
- The “public” folder hosts static files (index.html, manifest.json) which are served at runtime.
- Application Source Code:
- The “src” folder contains all application code.
- “src/index.js”/“src/App.js” act as the entry points.
- Templates:
- “src/template” holds code and markdown templates to support various themes and styles.
- State and Utilities:
- “src/store” module holds state management files (content, dialog, navbar, etc.) which manage application state and interactions.
- “src/utils” include helper functions, converters, image hosting utilities, and additional enhancement logic that underpins core behaviors.

##### Key Elements
A. Main Components:
- Build/Configuration Layer: Represent the scripts, webpack, ESLint, and Prettier configurations – essentially the build pipeline used to produce the final bundle.
- Application Layer:
- Entry Point (main.js, src/index.js) which initializes the application.
- Core UI (App.js) that orchestrates the component hierarchy.
- Store/State Management: Modules in “src/store” that manage application data and interactions.
- Template & Theme Management: Modules in “src/template” that provide theme support and markdown styling.
- Utility Functions: “src/utils” modules that support various functions (language highlighting, markdown parsing, etc.).
- External Services:
- Image Hosting components (AliOSS.js, QiniuOSS.js) showing external integrations.

B. Relationships and Interactions:
- Flow from the HTML (public/index.html) into the bundled JavaScript (via main.js/src/index.js).
- How the App component loads and organizes various UI components.
- That Utilities and Templates provide support functions across UI components.
- Integrations with external image hosting services as separate components that interact with UI elements.

C. Architectural Patterns and Design Principles:
- Component-based architecture: Emphasize how the application breaks down the UI into modular, reusable components (dialogs, side menus, sidebars, etc.).
- Separation of Concerns: Separate configuration/build, public assets, view components, and business logic (store and utilities).

D. Technologies and Frameworks:
- React (implied by the file structure and component naming conventions)
- Webpack as the module bundler (config in the “config” folder)
- ESLint/Prettier for code styling and quality
- Possibly state management libraries (the “src/store” abstraction) though not explicitly Redux; still, the pattern is clearly centralized state management.
- CSS and static assets (stored alongside components) that allow theme customization.

##### Final Advice
- Boundaries between layers and responsibilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build & Configuration Layer
    subgraph "Build & Configuration"
        ESLINT[".eslintrc"]:::build
        PRETTIER[".prettierrc"]:::build
        WEBPACK["Webpack Configurations"]:::build
        SCRIPTS["Scripts"]:::build
    end

    %% Public Assets Layer
    subgraph "Public Assets"
        INDEXHTML["index.html"]:::public
        MANIFEST["manifest.json"]:::public
    end

    %% Application Layer
    subgraph "Application Layer"
        ENTRY["Entry Point (src/index.js)"]:::entry
        APP["App Component (src/App.js)"]:::app

        %% UI Components
        subgraph "UI Components"
            DIALOGS["Dialog Components"]:::ui
            MENUS["Menu Components"]:::ui
            SIDEBARS["Sidebar Components"]:::ui
            SEARCH["Search Box"]:::ui
            ICONS["Icon Components"]:::ui
        end

        STORE["State Store Modules"]:::store
        TEMPLATES["Templates & Themes"]:::template
        UTILS["Utilities"]:::utils
        EXTIMG["Image Hosting Services"]:::ext
    end

    %% Data Flow Connections
    INDEXHTML -->|"loads"| ENTRY
    ENTRY -->|"initializes"| APP
    APP -->|"renders"| DIALOGS
    APP -->|"renders"| MENUS
    APP -->|"renders"| SIDEBARS
    APP -->|"renders"| SEARCH
    APP -->|"renders"| ICONS
    APP -->|"updates"| STORE
    APP -->|"applies"| TEMPLATES
    APP -->|"utilizes"| UTILS
    DIALOGS -->|"integrates"| EXTIMG
    STORE -->|"syncs"| DIALOGS
    UTILS -->|"supports"| APP

    %% Click Events for Build & Configuration Layer
    click ESLINT "https://github.com/whaoa/markdown-nice/blob/main/.eslintrc"
    click PRETTIER "https://github.com/whaoa/markdown-nice/blob/main/.prettierrc"
    click WEBPACK "https://github.com/whaoa/markdown-nice/blob/main/config/webpack.config.js"
    click SCRIPTS "https://github.com/whaoa/markdown-nice/blob/main/scripts/build.js"

    %% Click Events for Public Assets Layer
    click INDEXHTML "https://github.com/whaoa/markdown-nice/blob/main/public/index.html"
    click MANIFEST "https://github.com/whaoa/markdown-nice/blob/main/public/manifest.json"

    %% Click Events for Application Layer
    click ENTRY "https://github.com/whaoa/markdown-nice/blob/main/src/index.js"
    click APP "https://github.com/whaoa/markdown-nice/blob/main/src/App.js"

    %% Click Events for UI Components
    click DIALOGS "https://github.com/whaoa/markdown-nice/tree/main/src/component/Dialog"
    click MENUS "https://github.com/whaoa/markdown-nice/tree/main/src/component/MenuLeft"
    click SIDEBARS "https://github.com/whaoa/markdown-nice/tree/main/src/component/Sidebar"
    click SEARCH "https://github.com/whaoa/markdown-nice/tree/main/src/component/SearchBox"
    click ICONS "https://github.com/whaoa/markdown-nice/tree/main/src/icon"

    %% Click Events for State & Utilities
    click STORE "https://github.com/whaoa/markdown-nice/tree/main/src/store"
    click TEMPLATES "https://github.com/whaoa/markdown-nice/tree/main/src/template"
    click UTILS "https://github.com/whaoa/markdown-nice/tree/main/src/utils"
    click EXTIMG "https://github.com/whaoa/markdown-nice/tree/main/src/component/ImageHosting"

    %% Styles
    classDef build fill:#FAD7A0,stroke:#C0392B,stroke-width:2px;
    classDef public fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
    classDef entry fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef app fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef ui fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef store fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef template fill:#AED6F1,stroke:#3498DB,stroke-width:2px;
    classDef utils fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef ext fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
```
