# anyproto/anytype-api architecture

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

- Interactive diagram: https://gitdiagram.com/anyproto/anytype-api
- Repository: https://github.com/anyproto/anytype-api

## Overview

##### Project type and purpose
- This is a static documentation website (developer portal) built with Docusaurus (a React‐based SSG).
- It pulls in OpenAPI specs to generate API reference pages, MDX/Markdown for guides & examples, and custom React components for features like the changelog.

##### File structure
- Top-level project root contains:
– Configuration: docusaurus.config.ts, sidebars.ts, openapi.config.ts, Dockerfile, GitHub Actions workflows
– docs/: all MDX docs (guides, examples, reference versions, OpenAPI YAML)
– src/: React components, CSS, pages for the site theme
– static/: images & other static assets
- package.json defines dependencies (Docusaurus, plugins for OpenAPI).
- .github/workflows includes CI jobs for building, testing, and deploying the site.

##### Readme insights
- Describes the purpose (guides, API reference, examples)
- Instructs on local dev (`npm run start`), build & serve (`npm run build` + `npm run serve`)
- Mentions search index generation at build time

##### Main components and relationships
a. Authoring & Source Content
– MDX/Markdown files in docs/ (guides, examples, reference)
– OpenAPI YAML specs in docs/reference & openapi.config.ts (to feed the OpenAPI plugin)
– React components in src/components (ChangelogSection, HomepageFeatures)
– Static assets in static/img
b. Build Toolchain
– Docusaurus SSG (driven by docusaurus.config.ts & sidebars.ts)
– OpenAPI plugin reads specs → generates API pages
– Webpack/Babel from Docusaurus compiles React + CSS → static assets + HTML
– Search index generator (built in during `npm run build`)
c. CI/CD Pipeline
– GitHub Actions (stainless.yml, deploy_released.yml)
– Steps: checkout → install deps → lint/test → `npm run build` → publish to hosting (e.g., GitHub Pages, Netlify, or Docker image from Dockerfile)
d. Runtime / Hosting
– Static hosting (CDN) serves the built files
– Browser clients request HTML/CSS/JS → dynamic client-side routing & search

##### Important patterns & design principles
- Static Site Generation (no server runtime)
- Component-based UI (React)
- Plugin architecture (Docusaurus + OpenAPI plugin)
- Clear separation: Content (docs/) vs. Presentation (src/) vs. Configuration (config files)
- CI/CD for reproducible builds → automatic publishing

##### Don’t overthink—capture every logical component
- Source content (MDX, YAML, React code, assets)
- Build/configuration (TS config files, package.json)
- Plugins & frameworks (Docusaurus core, OpenAPI plugin)
- CI/CD orchestration
- Deployment & hosting
- End-user consumption

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Authoring & Source Content"
        SG["Guides"]:::content
        SE["Examples"]:::content
        RF["API Reference Pages"]:::content
        OS1["openapi-2025-03-17.yaml"]:::content
        OS2["openapi-2025-04-22.yaml"]:::content
        OS3["openapi-2025-05-20.yaml"]:::content
        OS4["swagger-2025-02-12.yaml"]:::content
        CC1["ChangelogSection"]:::content
        CC2["HomepageFeatures"]:::content
        CSSContent["custom.css"]:::content
        SN["Static Assets"]:::content
        EXC1["journal.py"]:::content
        EXC2["key.py"]:::content
    end

    subgraph "Configuration Files"
        DC["docusaurus.config.ts"]:::config
        SC["sidebars.ts"]:::config
        OC["openapi.config.ts"]:::config
    end

    subgraph "Build Toolchain"
        DU["Docusaurus SSG"]:::build
        OP["OpenAPI Plugin"]:::build
        WB["Webpack/Babel"]:::build
        SI["Search Index Generator"]:::build
        PKG["package.json & lock"]:::build
    end

    subgraph "CI/CD Pipeline"
        GA1["stainless.yml"]:::ci
        GA2["deploy_released.yml"]:::ci
        DF["Dockerfile"]:::ci
    end

    subgraph "Hosting & Runtime"
        HO["CDN/Static Hosting"]:::hosting
        BR["End-User Browser"]:::runtime
    end

    SG --> DU
    SE --> DU
    RF --> DU
    EXC1 --> DU
    EXC2 --> DU
    CC1 --> DU
    CC2 --> DU
    CSSContent --> DU
    SN --> DU

    OS1 --> OP
    OS2 --> OP
    OS3 --> OP
    OS4 --> OP
    OP --> DU

    DC --> DU
    SC --> DU
    OC --> DU
    PKG --> DU

    DU --> WB
    WB --> HO
    DU --> SI
    SI --> HO

    GA1 --> DU
    GA2 --> DF
    DF --> HO

    HO --> BR

    click SG "https://github.com/anyproto/anytype-api/tree/main/docs/guides/"
    click SE "https://github.com/anyproto/anytype-api/tree/main/docs/examples/"
    click RF "https://github.com/anyproto/anytype-api/tree/main/docs/reference/"
    click OS1 "https://github.com/anyproto/anytype-api/blob/main/docs/reference/openapi-2025-03-17.yaml"
    click OS2 "https://github.com/anyproto/anytype-api/blob/main/docs/reference/openapi-2025-04-22.yaml"
    click OS3 "https://github.com/anyproto/anytype-api/blob/main/docs/reference/openapi-2025-05-20.yaml"
    click OS4 "https://github.com/anyproto/anytype-api/blob/main/docs/reference/swagger-2025-02-12.yaml"
    click OC "https://github.com/anyproto/anytype-api/blob/main/openapi.config.ts"
    click DC "https://github.com/anyproto/anytype-api/blob/main/docusaurus.config.ts"
    click SC "https://github.com/anyproto/anytype-api/blob/main/sidebars.ts"
    click CC1 "https://github.com/anyproto/anytype-api/blob/main/src/components/ChangelogSection/index.js"
    click CC1 "https://github.com/anyproto/anytype-api/blob/main/src/components/ChangelogSection/styles.module.css"
    click CC2 "https://github.com/anyproto/anytype-api/blob/main/src/components/HomepageFeatures/index.js"
    click CC2 "https://github.com/anyproto/anytype-api/blob/main/src/components/HomepageFeatures/styles.module.css"
    click CSSContent "https://github.com/anyproto/anytype-api/blob/main/src/css/custom.css"
    click EXC1 "https://github.com/anyproto/anytype-api/blob/main/src/examples/journal.py"
    click EXC2 "https://github.com/anyproto/anytype-api/blob/main/src/examples/key.py"
    click SN "https://github.com/anyproto/anytype-api/tree/main/static/img/"
    click PKG "https://github.com/anyproto/anytype-api/blob/main/package.json"
    click PKG "https://github.com/anyproto/anytype-api/blob/main/package-lock.json"
    click GA1 "https://github.com/anyproto/anytype-api/blob/main/.github/workflows/stainless.yml"
    click GA2 "https://github.com/anyproto/anytype-api/blob/main/.github/workflows/deploy_released.yml"
    click DF "https://github.com/anyproto/anytype-api/tree/main/Dockerfile"

    classDef content fill:#D6EAF8,stroke:#2471A3,color:#1B4F72
    classDef config fill:#FADBD8,stroke:#C0392B,color:#641E16
    classDef build fill:#FDEBD0,stroke:#DC7633,color:#8E44AD
    classDef ci fill:#EBDEF0,stroke:#9B59B6,color:#512E5F
    classDef hosting fill:#D5F5E3,stroke:#27AE60,color:#1E8449
    classDef runtime fill:#D5D8DC,stroke:#566573,color:#2C3E50
```
