# rocketchat/fuselage architecture

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

- Interactive diagram: https://gitdiagram.com/rocketchat/fuselage
- Repository: https://github.com/rocketchat/fuselage

## Overview

##### Project Type and Purpose
- This is a monorepo (managed by Yarn v4 workspaces & Turborepo) that bundles multiple npm packages under `packages/`, each one published separately.

##### File‐structure Analysis
- Top‐level files: CI/CD (`.github/workflows`), lint/prettify configs, Yarn/Turbo config, `.changeset` for releases.
- `/packages`: dozens of libraries, grouped roughly into:
- Foundation utilities: `css-in-js`, `css-supports`, `emitter`, `memo`, `string-helpers`
- Styling & tokens: `fuselage-tokens`, `stylis-logical-props-middleware`, `styled`
- React component library: `fuselage`, `fuselage-toastbar`
- Specialized: `mp3-encoder` (worker-based LAME encoder), `onboarding-ui` (higher‐level flows)
- `.changeset`: manages version bumps and changelogs for package releases.

##### README Insights
- Confirms a list of all `@rocket.chat/*` packages and their roles, with badges for versions and dependencies.
- No single‐page app: it’s a developer library ecosystem.

a. Main Components
- Monorepo Root: houses config (Lint, Prettier, Turbo, GitHub Actions)
- Yarn Workspaces & Turborepo: orchestrate task pipelines across packages
- Package Groups:
1. Core Utilities (css-in-js, emitter, memo, string-helpers, css-supports)
2. Styling Layer (fuselage-tokens, stylis middleware, styled)
4. Component Library (`fuselage`)
5. Specialized Packages (mp3-encoder, peggy-loader, onboarding-ui, prettier-config)
- Tools Folder: custom build scripts & testing utilities
- CI/CD: GitHub Actions invoking Turbo pipelines, `changeset` for versioning, publish to npm

b. Relationships & Interactions
- Developers → push code → GitHub
- GitHub Actions → runs Lint/Test/Build via Yarn & Turbo
- Turbo → parallelizes tasks (build/test) by detecting package dependency graph
- Packages depend on lower layers:
- UI primitives import Core Utilities & Styling Layer
- `fuselage` depends on Styling Layer & UI primitives
- `onboarding-ui` depends on `fuselage`, `layout`, `fuselage-forms/hooks`
- `.changeset` collates changes across packages → triggers release workflow

c. Architectural Patterns & Principles
- Monorepo with Yarn Workspaces & Turborepo: single source of truth, cross‐package caching, incremental builds
- Layered design:
- Utilities → Styling → Primitives → Components → Applications/Flows
- Separation of concerns: each package has isolated build/test config (Rollup, Jest, TS)
- Automated versioning & release (Changesets)

d. Key Technologies
- JavaScript/TypeScript, React, Rollup, Jest
- Yarn v4 Workspaces, Turborepo, Changesets
- GitHub Actions for CI/CD
- Eslint, Prettier, Husky pre‐commit hooks

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Monorepo Root
    Root["Monorepo Root"]:::config

    %% Infrastructure
    subgraph "Infrastructure"
        Yarn["Yarn Workspaces"]:::config
        Turbo["Turborepo"]:::config
        CI["CI/CD (GitHub Actions)"]:::ci
        Changeset[".changeset"]:::config
        Workflows[".github/workflows"]:::ci
        Root --> Yarn
        Root --> Turbo
        Root --> CI
        Root --> Changeset
        Root --> Workflows
        Yarn --> Turbo
        CI --> Turbo
        CI --> Changeset
        CI --> Workflows
    end

    %% Tools
    subgraph "Tools"
        DTB["Design Tokens Builder"]:::tools
        IB["Icons Builder"]:::tools
        LB["Logo Builder"]:::tools
        Lint["Lint & Fix Scripts"]:::tools
        WScripts["Workspace Scripts"]:::tools
        TU["Testing Utilities"]:::tools
        GU["General Tools Utils"]:::tools
        RU["README Updater"]:::tools
        Root --> DTB
        Root --> IB
        Root --> LB
        Root --> Lint
        Root --> WScripts
        Root --> TU
        Root --> GU
        Root --> RU
    end

    %% Package Layers
    subgraph "Core Utilities"
        CSSJS["css-in-js"]:::pkg
        CSSSupports["css-supports"]:::pkg
        Emitter["emitter"]:::pkg
        Memo["memo"]:::pkg
        StrHelpers["string-helpers"]:::pkg
        Root --> CSSJS
        Root --> CSSSupports
        Root --> Emitter
        Root --> Memo
        Root --> StrHelpers
    end

    subgraph "Styling Layer"
        Tokens["fuselage-tokens"]:::pkg
        Stylis["stylis-logical-props-middleware"]:::pkg
        Styled["styled"]:::pkg
        CSSJS --> Tokens
        CSSSupports --> Tokens
        Styled --> Tokens
    end

    subgraph "UI Primitives"
        Polyfills["fuselage-polyfills"]:::pkg
        Hooks["fuselage-hooks"]:::pkg
        Forms["fuselage-forms"]:::pkg
        Layout["layout"]:::pkg
        Icons["icons"]:::pkg
        Logo["logo"]:::pkg
        StrHelpers --> Polyfills
        Memo --> Hooks
        Emitter --> Forms
        Tokens --> Forms
        Tokens --> Layout
        Styled --> Layout
    end

    subgraph "Component Library"
        Fuselage["fuselage"]:::pkg
        Toastbar["fuselage-toastbar"]:::pkg
        Styled --> Fuselage
        Layout --> Fuselage
        Icons --> Fuselage
        Fuselage --> Toastbar
    end

    subgraph "Specialized Packages"
        MP3["mp3-encoder"]:::pkg
        Onboarding["onboarding-ui"]:::pkg
        Peggy["peggy-loader"]:::pkg
        PrettierCfg["prettier-config"]:::pkg
        MP3 --> Root
        Onboarding --> Fuselage
        Onboarding --> Layout
        Onboarding --> Forms
        Peggy --> Root
        PrettierCfg --> Root
    end

    %% Click Events
    click Root "https://github.com/rocketchat/fuselage/tree/main//"
    click Yarn "https://github.com/rocketchat/fuselage/blob/main//yarnrc.yml"
    click Turbo "https://github.com/rocketchat/fuselage/blob/main//turbo.json"
    click CI "https://github.com/rocketchat/fuselage/tree/main//.github/workflows"
    click Changeset "https://github.com/rocketchat/fuselage/blob/main//.changeset"
    click Workflows "https://github.com/rocketchat/fuselage/tree/main//.github/workflows"
    click CSSJS "https://github.com/rocketchat/fuselage/tree/main//packages/css-in-js"
    click CSSSupports "https://github.com/rocketchat/fuselage/tree/main//packages/css-supports"
    click Emitter "https://github.com/rocketchat/fuselage/tree/main//packages/emitter"
    click Memo "https://github.com/rocketchat/fuselage/tree/main//packages/memo"
    click StrHelpers "https://github.com/rocketchat/fuselage/tree/main//packages/string-helpers"
    click Tokens "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage-tokens"
    click Stylis "https://github.com/rocketchat/fuselage/tree/main//packages/stylis-logical-props-middleware"
    click Styled "https://github.com/rocketchat/fuselage/tree/main//packages/styled"
    click Polyfills "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage-polyfills"
    click Hooks "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage-hooks"
    click Forms "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage-forms"
    click Layout "https://github.com/rocketchat/fuselage/tree/main//packages/layout"
    click Icons "https://github.com/rocketchat/fuselage/tree/main//packages/icons"
    click Logo "https://github.com/rocketchat/fuselage/tree/main//packages/logo"
    click Fuselage "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage"
    click Toastbar "https://github.com/rocketchat/fuselage/tree/main//packages/fuselage-toastbar"
    click MP3 "https://github.com/rocketchat/fuselage/tree/main//packages/mp3-encoder"
    click Onboarding "https://github.com/rocketchat/fuselage/tree/main//packages/onboarding-ui"
    click Peggy "https://github.com/rocketchat/fuselage/tree/main//packages/peggy-loader"
    click PrettierCfg "https://github.com/rocketchat/fuselage/tree/main//packages/prettier-config"
    click DTB "https://github.com/rocketchat/fuselage/tree/main//tools/build-design-tokens"
    click IB "https://github.com/rocketchat/fuselage/tree/main//tools/build-icons"
    click LB "https://github.com/rocketchat/fuselage/tree/main//tools/build-logo"
    click Lint "https://github.com/rocketchat/fuselage/tree/main//tools/lint-all"
    click WScripts "https://github.com/rocketchat/fuselage/tree/main//tools/scripts"
    click TU "https://github.com/rocketchat/fuselage/tree/main//tools/testing-utils"
    click GU "https://github.com/rocketchat/fuselage/tree/main//tools/tools-utils"
    click RU "https://github.com/rocketchat/fuselage/tree/main//tools/update-readme"

    %% Styles
    classDef pkg fill:#E0F7FA,stroke:#006064,color:#006064;
    classDef tools fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32;
    classDef ci fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00;
    classDef config fill:#ECEFF1,stroke:#607D8B,color:#455A64;
```
