# marceloakalopes/medium2md architecture

> Architecture diagram of the GitHub repository marceloakalopes/medium2md, 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/marceloakalopes/medium2md
- Repository: https://github.com/marceloakalopes/medium2md

## Overview

##### Project Type and Purpose
- Project Type: This is a full-stack Next.js application that focuses on converting Medium articles into Markdown format.
- Purpose: The tool facilitates quick and customizable conversion of Medium articles for backup, migration, or offline reading.

##### File Structure
- Top-Level Directories:
– app: Contains the core Next.js “app” directory with pages and layouts.
- app/api/convert: Houses the API endpoint (route.ts) responsible for handling conversion requests.
- app/editor: Contains the client-side logic for the editor interface (layout.tsx and page.tsx).
- Other pages like app/page.tsx and app/layout.tsx represent the main entry points.
– components: Contains UI components such as sidebars, toolbars, and various UI elements (avatar, button, dialog, etc.). This indicates a modular component-based design.
– lib: Contains libraries with conversion logic (lib/medium/convert.ts) and various utility functions.
– context and hooks: Indicate state management (EditorContext) and custom hooks (such as use-mobile and use-toast) that manage specific functionality.
– Configuration Files: next.config.mjs, tailwind.config.ts, and postcss.config.mjs among others, which set up the build and styling environments.

##### Core Components and Their Relationships
- Frontend/UI Layer:
– Pages and layouts in the “app” directory form the overall structure of the web client.
– The “app/editor” section is dedicated to a specialized editor interface.
– The “components” folder provides reusable UI elements that are integrated into the pages.
- API Layer:
– The “app/api/convert/route.ts” serves as an endpoint where conversion requests are handled.
– This endpoint likely interacts with the conversion logic located in “lib/medium/convert.ts”.
- Business Logic:
– The “lib/medium” and “lib/utils.ts” provide the core conversion logic and utility functions.
- State Management and Client-Side Behavior:
– The “context” directory (with EditorContext.ts) and “hooks” directory support state management and component interactivity.
- Styling and Configurations:
– Global styles and configuration files (e.g., tailwind.config.ts and globals.css) establish the overall look and behavior of the application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        A["Next.js Main Pages & Layouts"]:::frontEnd
        B["Editor Interface"]:::frontEnd
        C["UI Components"]:::frontEnd
        D["State Management (Context & Hooks)"]:::frontEnd
        UIC["UI Kit"]:::frontEnd
        H["Custom Hooks"]:::frontEnd
    end

    subgraph "Backend"
        E["Conversion API Endpoint"]:::backEnd
        F["Conversion Library"]:::library
        U["Utility Functions"]:::library
    end

    G["Configuration & Build Tools"]:::config

    %% Connections
    G --> A
    G --> B
    A -->|"conversionRequest"| E
    B -->|"conversionRequest"| E
    E -->|"processArticle"| F
    F -->|"includes"| U
    A -->|"usesComponents"| C
    B -->|"usesComponents"| C
    C -->|"includes"| UIC
    A -->|"managesState"| D
    B -->|"managesState"| D
    D -->|"includes"| H

    %% Click Events
    click A "https://github.com/marceloakalopes/medium2md/blob/main/app/page.tsx"
    click B "https://github.com/marceloakalopes/medium2md/blob/main/app/editor/layout.tsx"
    click E "https://github.com/marceloakalopes/medium2md/blob/main/app/api/convert/route.ts"
    click F "https://github.com/marceloakalopes/medium2md/blob/main/lib/medium/convert.ts"
    click U "https://github.com/marceloakalopes/medium2md/blob/main/lib/utils.ts"
    click C "https://github.com/marceloakalopes/medium2md/tree/main/components"
    click UIC "https://github.com/marceloakalopes/medium2md/tree/main/components/ui"
    click D "https://github.com/marceloakalopes/medium2md/blob/main/context/EditorContext.ts"
    click H "https://github.com/marceloakalopes/medium2md/blob/main/hooks/use-mobile.tsx"
    click G "https://github.com/marceloakalopes/medium2md/blob/main/next.config.mjs"

    %% Styles
    classDef frontEnd fill:#FDEBD0,stroke:#E59866,stroke-width:2px;
    classDef backEnd fill:#D5F5E3,stroke:#58D68D,stroke-width:2px;
    classDef library fill:#D6EAF8,stroke:#3498DB,stroke-width:2px;
    classDef config fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
```
