# fuma-nama/fumadocs architecture

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

- Interactive diagram: https://gitdiagram.com/fuma-nama/fumadocs
- Repository: https://github.com/fuma-nama/fumadocs

## Overview

##### Main Components

a. Core Packages Layer:
- @fumadocs/core: The foundation layer handling core functionality
- @fumadocs/mdx: MDX processing and transformation
- @fumadocs/ui: UI components and layouts
- @fumadocs/openapi: OpenAPI integration
- @fumadocs/typescript: TypeScript documentation generation
- @fumadocs/twoslash: TypeScript playground integration

b. Integration Layer:
- Content Collections
- Internationalization (i18n)
- Search functionality (Algolia, Orama)
- OpenAPI documentation
- TypeScript documentation

c. User Interface Layer:
- Layouts (docs, home, notebook)
- Components (accordion, codeblock, tabs, etc.)
- Theme system
- Search UI

d. Build & CLI Tools:
- CLI package for project scaffolding
- Doc-gen for documentation generation
- Create-app for project initialization

##### Relationships to Highlight

- How the core package provides foundational services to other packages
- Demonstrate the flow from content (MDX files) through the processing pipeline
- How the UI components consume the processed content
- Integration points with external services (search, OpenAPI)

##### Architecture Pattern

**┌─────────────────────────────────────────────────────┐**
- Applications                        │
- (Documentation Sites built with Fumadocs)          │
- ┤
- UI Components                       │
- (Layouts, Components, Theme System)                │
- ┤
- Integration Layer                      │
- (Search, i18n, OpenAPI, TypeScript)               │
- ┤
- Core Layer                         │
- (MDX Processing, Content Management, Routing)      │
- ┘

##### Important Flows

- Content Processing Flow:
MDX Files → MDX Processing → UI Rendering → Final Output

- Build Process Flow:
Source Files → Doc Generation → Static Assets → Deployment

- Search Flow:
Content → Search Indexing → Search UI → Results

##### Additional Elements

- Version compatibility information
- Integration points with Next.js
- ESM-only nature of the packages

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Applications
        DocSites["Documentation Sites"]:::application
        Examples["Example Projects"]:::application
    end

    subgraph "UI Layer"
        UIComponents["UI Components"]:::ui
        Layouts["Layouts"]:::ui
        ThemeSystem["Theme System"]:::ui
    end

    subgraph "Integration Layer"
        Search["Search System"]:::integration
        I18n["Internationalization"]:::integration
        ContentCollections["Content Collections"]:::integration
        OpenAPITools["OpenAPI Tools"]:::integration
        TypeScriptDocs["TypeScript Documentation"]:::integration
    end

    subgraph "Core Layer"
        CoreFramework["Core Framework"]:::core
        MDXProcessing["MDX Processing"]:::core
        UICore["UI Core"]:::core
        OpenAPICore["OpenAPI Integration"]:::core
        TypeScriptCore["TypeScript Support"]:::core
        TwoslashCore["Twoslash Integration"]:::core
    end

    subgraph "Build Tools"
        CLI["CLI Package"]:::build
        DocGen["Documentation Generator"]:::build
        CreateApp["Project Creator"]:::build
    end

    %% Relationships
    CoreFramework --> UICore
    MDXProcessing --> UICore
    UICore --> UIComponents
    OpenAPICore --> OpenAPITools
    TypeScriptCore --> TypeScriptDocs
    TwoslashCore --> TypeScriptDocs

    UIComponents --> DocSites
    Layouts --> DocSites
    ThemeSystem --> DocSites

    Search --> DocSites
    I18n --> DocSites
    ContentCollections --> DocSites
    OpenAPITools --> DocSites
    TypeScriptDocs --> DocSites

    CLI --> CreateApp
    CreateApp --> DocSites
    DocGen --> DocSites

    %% Click Events
    click CoreFramework "https://github.com/fuma-nama/fumadocs/tree/dev/packages/core/"
    click MDXProcessing "https://github.com/fuma-nama/fumadocs/tree/dev/packages/mdx/"
    click UICore "https://github.com/fuma-nama/fumadocs/tree/dev/packages/ui/"
    click OpenAPICore "https://github.com/fuma-nama/fumadocs/tree/dev/packages/openapi/"
    click TypeScriptCore "https://github.com/fuma-nama/fumadocs/tree/dev/packages/typescript/"
    click TwoslashCore "https://github.com/fuma-nama/fumadocs/tree/dev/packages/twoslash/"
    click ContentCollections "https://github.com/fuma-nama/fumadocs/tree/dev/packages/content-collections/"
    click I18n "https://github.com/fuma-nama/fumadocs/tree/dev/packages/core/src/i18n/"
    click Search "https://github.com/fuma-nama/fumadocs/tree/dev/packages/core/src/search/"
    click OpenAPITools "https://github.com/fuma-nama/fumadocs/tree/dev/packages/openapi/src/"
    click TypeScriptDocs "https://github.com/fuma-nama/fumadocs/tree/dev/packages/typescript/src/"
    click Layouts "https://github.com/fuma-nama/fumadocs/tree/dev/packages/ui/src/layouts/"
    click UIComponents "https://github.com/fuma-nama/fumadocs/tree/dev/packages/ui/src/components/"
    click ThemeSystem "https://github.com/fuma-nama/fumadocs/tree/dev/packages/ui/src/theme/"
    click CLI "https://github.com/fuma-nama/fumadocs/tree/dev/packages/cli/"
    click DocGen "https://github.com/fuma-nama/fumadocs/tree/dev/packages/doc-gen/"
    click CreateApp "https://github.com/fuma-nama/fumadocs/tree/dev/packages/create-app/"
    click DocSites "https://github.com/fuma-nama/fumadocs/tree/dev/apps/docs/"
    click Examples "https://github.com/fuma-nama/fumadocs/tree/dev/examples/"

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#4CAF50,stroke:#2E7D32,color:white
    classDef integration fill:#FF9800,stroke:#EF6C00,color:white
    classDef build fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef application fill:#607D8B,stroke:#37474F,color:white

    %% Legend
    subgraph Legend
        CoreL["Core Components"]:::core
        UIL["UI Components"]:::ui
        IntegrationL["Integration Services"]:::integration
        BuildL["Build Tools"]:::build
        AppL["Applications"]:::application
    end
```
