# doocs/md architecture

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

- Interactive diagram: https://gitdiagram.com/doocs/md
- Repository: https://github.com/doocs/md

## Overview

##### Main Components
- Frontend Application:
- The core UI lives in the /src directory (with Vue components, entry points, utilities, etc.). This part includes the markdown editor, preview panes, UI components (in subdirectories such as /components and /components/ui), and configuration files (found under /src/config and /src/lib).
- Entry points (like the popup in /src/entrypoints and the background script) support different modes of operation.
- CLI & Local Deployment:
- The md-cli directory contains a Node.js–based command-line interface that users can install globally. This tool allows you to quickly spin up a private version of the editor.
- Docker & Server Components:
- The docker folder includes several Dockerfiles (Dockerfile.base, Dockerfile.nginx, Dockerfile.standalone, Dockerfile.static) and scripts to build images, push images, and release.
- The docker/latest/server/main.go is a Go-based server which may be responsible for handling API requests (for example, file uploads or serving built assets) when deployed in certain environments.
- CI/CD & Configuration:
- The .github/workflows directory (with multiple workflow YAML files) shows the automated build, release, and deployment pipeline for this project.
- Additional configuration files (editorconfig, .nvmrc, .vscode, eslint.config.mjs, postcss.config.js, etc.) help manage coding standards, build scripts, and deployment options.
- External Integrations:
- The README details support for multiple external image-hosting services (GitHub, Aliyun OSS, Tencent Cloud, etc.) along with a customizable upload logic.
- The system thus interacts with these external services for file uploads, which should be represented as external components.

##### Relationships and Data Flow
- User Interaction:
- The user accesses the application via a web browser (Chrome is recommended) that loads index.html along with the bundled Vue application.
- The application (editor UI) processes Markdown in real time (using utilities in /src/utils and rendering functions) and sends image uploads via API calls.
- Frontend ⇄ Backend Interaction:
- The Vue application might interact with a backend service (provided either by the md-cli Node.js server or the Go-based server run via Docker) via RESTful APIs for operations like file upload and content management.
- CLI / Docker Deployment:
- The md-cli tool acts as an alternative way to launch the service in a local environment.
- CI/CD Pipeline:
- GitHub Actions workflows (build, release, docker builds) that automatically trigger builds and deploys, ensuring a smooth integration/delivery pipeline.
- External Services:
- Components for external image-hosting services, indicating that the editor may send file uploads to third-party APIs based on configured tokens and parameters.

##### Architectural Patterns and Key Technologies
- Architectural Separation:
- Technologies & Frameworks:
- Frontend: Vue3, Vite, Tailwind (as inferred from tailwind.config.cjs), and various UI libraries/components.
- Backend: Node.js (for md-cli) and Go (in the Docker/server image).
- Build & Deployment: Docker, GitHub Actions, and associated shell scripts (in the /scripts directory).
- Design Principles:
- Modular design (as shown by well-organized directories for components, utilities, stores, and types) and separation of concerns (frontend UI vs backend operations vs deployment configurations).

##### Essential Elements
- Clear components for each major part:
- “User Browser” (client)
- “Vue3 Editor Application” (frontend that includes real-time markdown processing, custom themes, and rich UI components)
- “md-cli Node.js Server” (local deployment and serving of the editor)
- “Go-based API Server” (part of the Docker deployment for handling API requests)
- “Docker & Build Scripts” (containerized environments with multiple Dockerfiles and build scripts)
- “CI/CD Pipeline” (GitHub Actions build/release workflows)
- “External Image Hosting Services” (multiple third-party integrations for file uploads)
- The flow of user interactions (input, preview, file upload).
- Data flow from the frontend to the backend.
- Automated deployment flows via CI/CD actions.
- Annotations or legends:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        U["User Browser"]:::client
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FE1["Vue3 Editor Application"]:::frontend
        FE2["UI & Components"]:::frontend
        FE3["Entry Points"]:::frontend
        FE4["Configuration Files"]:::frontend
        FE5["Libraries"]:::frontend
        FE1 --> FE2
        FE1 --> FE3
        FE1 --> FE4
        FE1 --> FE5
    end

    %% CLI & Backend
    subgraph "CLI & Backend"
        direction TB
        B1["md-cli (Node.js Server)"]:::backend
        B2["Go-based API Server"]:::backend
    end

    %% Deployment & CI/CD
    subgraph "Deployment & CI/CD"
        direction TB
        D2["CI/CD Pipeline"]:::deployment
        D1["Docker & Deployment Files"]:::deployment
        RC1[".editorconfig"]:::deployment
        RC2[".nvmrc"]:::deployment
        RC3["eslint.config.mjs"]:::deployment
        RC4["postcss.config.js"]:::deployment
        D2 --> D1
        D1 --> B2
    end

    %% External Services
    subgraph "External Services"
        direction TB
        E1["External Image Hosting Services & Integration Docs"]:::external
    end

    %% Inter-layer Connections
    U --> FE1
    FE1 -->|"APIcalls"| B1
    FE1 -->|"APIcalls"| B2
    B2 -->|"uploads"| E1

    %% Classes
    classDef client fill:#ffeb3b,stroke:#333,stroke-width:2px;
    classDef frontend fill:#90caf9,stroke:#1e88e5,stroke-width:2px;
    classDef backend fill:#a5d6a7,stroke:#388e3c,stroke-width:2px;
    classDef deployment fill:#ce93d8,stroke:#8e24aa,stroke-width:2px;
    classDef external fill:#e57373,stroke:#d32f2f,stroke-width:2px;

    %% Click Events
    click FE2 "https://github.com/doocs/md/tree/main/src"
    click FE3 "https://github.com/doocs/md/tree/main/src/entrypoints"
    click FE4 "https://github.com/doocs/md/tree/main/src/config"
    click FE5 "https://github.com/doocs/md/tree/main/src/lib"
    click B1 "https://github.com/doocs/md/tree/main/md-cli"
    click D1 "https://github.com/doocs/md/tree/main/docker/docker/latest"
    click B2 "https://github.com/doocs/md/blob/main/docker/docker/latest/server/main.go"
    click D2 "https://github.com/doocs/md/tree/main/.github/workflows"
    click RC1 "https://github.com/doocs/md/blob/main/.editorconfig"
    click RC2 "https://github.com/doocs/md/blob/main/.nvmrc"
    click RC3 "https://github.com/doocs/md/blob/main/eslint.config.mjs"
    click RC4 "https://github.com/doocs/md/blob/main/postcss.config.js"
    click E1 "https://github.com/doocs/md/blob/main/README.md"
```
