# wxingheng/markdown-to-image-serve architecture

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

- Interactive diagram: https://gitdiagram.com/wxingheng/markdown-to-image-serve
- Repository: https://github.com/wxingheng/markdown-to-image-serve

## Overview

##### Component Details

Frontend Components (Top Section):
- Pages (/app/*, /poster)
- UI Components (src/components)
- Markdown Editor
- Preview Component

API Layer (Middle Section):
- /api/generatePoster
- /api/generatePosterImage
- /api/getImage
- /api/images/[filename]

Processing Layer (Lower Section):
- Markdown Processing Pipeline
- Puppeteer Rendering Service
- Image Storage Handler

##### Flow Representations

- Client → API Endpoints (REST calls)
- API → Markdown Processor
- Markdown Processor → Puppeteer Service
- Puppeteer → Image Storage
- Image Storage → Client Response

##### Technical Details

Annotations for:
- Next.js 13+ App Router
- Puppeteer Browser Instance
- MDX Processing
- Tailwind CSS Styling
- API Response Formats

##### Integration Points

Highlight:
- External API access points
- Vercel deployment connection
- Docker container boundaries
- File system interaction points

##### Deployment options (Vercel/Docker)

Remember to include notes about scalability considerations and the stateless nature of the service, as this is designed to be deployed on Vercel's serverless infrastructure.

This system design should clearly show how the application transforms Markdown input into image output while maintaining a clean separation of concerns between the frontend interface, API layer, and processing services.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WI["Web Interface"]:::frontend
        PG["Poster Generation"]:::frontend
        DI["Documentation Interface"]:::frontend
        EC["Editor Component"]:::frontend
        PC["Preview Component"]:::frontend
        HC["Header Component"]:::frontend
        FC["Footer Component"]:::frontend
    end

    subgraph "API Layer"
        PGA["/api/generatePoster"]:::api
        IGA["/api/generatePosterImage"]:::api
        GIA["/api/getImage"]:::api
        DIA["/api/images/[filename]"]:::api
    end

    subgraph "UI Components"
        BC["Button Component"]:::ui
        CC["Card Component"]:::ui
        IC["Input Components"]:::ui
        SC["Selection Components"]:::ui
    end

    subgraph "Markdown Processing"
        DC["Documentation Content"]:::markdown
        HC2["Home Content"]:::markdown
        MC["MDX Configuration"]:::markdown
    end

    subgraph "Configuration"
        NC["Next.js Config"]:::config
        TC["Tailwind Config"]:::config
        DC2["Docker Config"]:::config
        EC2["Environment Config"]:::config
    end

    subgraph "Examples"
        ED["Example Directory"]:::example
        AE["API Examples"]:::example
    end

    subgraph "Utilities"
        GU["General Utilities"]:::util
        CSU["Client-side Utilities"]:::util
    end

    WI --> PGA
    PG --> IGA
    DI --> GIA
    EC --> PC
    PGA --> DC
    IGA --> GIA
    GIA --> DIA

    %% Click Events
    click WI "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/app/page.tsx"
    click PG "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/app/poster/page.tsx"
    click DI "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/app/docs/page.tsx"
    click EC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/Editor.tsx"
    click PC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/PosterView.tsx"
    click HC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/Header.tsx"
    click FC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/Footer.tsx"
    click PGA "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/pages/api/generatePoster.ts"
    click IGA "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/pages/api/generatePosterImage.ts"
    click GIA "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/pages/api/getImage.js"
    click DIA "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/pages/api/images/[filename].ts"
    click DC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/markdown/docs.mdx"
    click HC2 "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/markdown/home.mdx"
    click MC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/mdx-components.tsx"
    click BC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/ui/button.tsx"
    click CC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/ui/card.tsx"
    click IC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/ui/textarea.tsx"
    click SC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/components/ui/select.tsx"
    click NC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/next.config.mjs"
    click TC "https://github.com/wxingheng/markdown-to-image-serve/blob/master/tailwind.config.ts"
    click DC2 "https://github.com/wxingheng/markdown-to-image-serve/tree/master/Dockerfile"
    click EC2 "https://github.com/wxingheng/markdown-to-image-serve/blob/master/.env.production"
    click ED "https://github.com/wxingheng/markdown-to-image-serve/tree/master/example/"
    click GU "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/lib/utils.ts"
    click CSU "https://github.com/wxingheng/markdown-to-image-serve/blob/master/src/lib/useMounted.tsx"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef ui fill:#e74c3c,stroke:#c0392b,color:white
    classDef markdown fill:#f1c40f,stroke:#f39c12,color:black
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white
    classDef example fill:#1abc9c,stroke:#16a085,color:white
    classDef util fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1["Frontend"]:::frontend
        L2["API"]:::api
        L3["UI Components"]:::ui
        L4["Markdown"]:::markdown
        L5["Configuration"]:::config
        L6["Examples"]:::example
        L7["Utilities"]:::util
    end
```
