# inbestigator/dressed architecture

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

- Interactive diagram: https://gitdiagram.com/inbestigator/dressed
- Repository: https://github.com/inbestigator/dressed

## Overview

##### Project type and purpose
- This is a TypeScript-based monorepo (managed with Turborepo) that produces three interrelated NPM packages plus a Next.js–based documentation site.
- The core package (“dressed”) is a Discord-interaction framework: it provides a CLI, component definitions, request-handling server machinery, type definitions, utilities, and a build pipeline for Discord bots.
- Two support packages extend its functionality:
- “dressed-matcher” – a small library for matching interaction payloads or commands.
- “dressed-next” – Next.js adapter for serverless Discord webhook endpoints.
- The “www” folder is the documentation website built on Next.js, consuming dressed-next (and possibly dressed) to render interactive docs.

##### File structure
- Root: CI workflows (`.github/workflows`), lint/bundle configs, `turbo.json`, and three main folders: `packages`, `www`.
- packages/dressed
- `src/bin/dressed.ts`: CLI entry point (scaffold, generate, deploy).
- `src/bot`: Components (buttons, menus, etc.) + rate-limit logic + resource definitions (Discord REST endpoints).
- `src/server`: Build pipeline (parsers, bundlers) → HTTP server handlers (commands, components, events) → signature verification & utils for Express-style request handling.
- `src/types` & `src/utils`: Shared type definitions and helper functions (env, HTTP calls).
- packages/dressed-matcher: Minimal library with its own `src/index.ts` + tests.
- packages/dressed-next: Exposes a Next.js–style request handler (`src/index.ts`) plus configuration (`turbo.json`).
- `www`: A Next.js application that
- Uses dressed-next’s handler to mount Discord endpoints (example).
- Renders Markdown docs under `/src/app/docs` → static site generation.
- Has custom UI components, Tailwind CSS, and client-side hooks.

##### README for additional insights
- (Assuming the README describes the core workflow) The CLI boots up, scans source code for command definitions, compiles them into a webhook server, and deploys to a hosting provider or local environment.
- Dependencies: Node.js, Bun (optional), Next.js, Discord API.

##### Elements
– Clear labels: Developer, CLI, Build System, Package: dressed, Package: matcher, Package: next, Hosting, Discord, Documentation Site.
- Code flow (edit → build → publish → install)
- Runtime flow (Discord → HTTP server → handler → Discord)
- Documentation flow (packages → docs site)
- Rectangles for code modules (packages)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Layer
    Developer["Developer Workstation"]:::developer
    CLI["CLI (packages/dressed/src/bin/dressed.ts)"]:::process
    Developer --> CLI

    %% Build & CI Layer
    subgraph "Build & CI"
        direction TB
        Turborepo["Monorepo Build Orchestration (turbo.json)"]:::ci
        ESLint["Lint & Format"]:::process
        TS["TypeScript Compiler"]:::process
        Tests["Test Runner"]:::process
        TestWF["CI Workflow: test.yml"]:::ci
        PubWF["CI Workflow: publish.yml"]:::ci
    end
    CLI --> Turborepo
    Turborepo --> ESLint --> TS --> Tests
    Tests --> TestWF
    Tests --> PubWF

    %% Packages Layer
    subgraph "Packages" 
        direction TB
        subgraph "Core Package: dressed" 
            direction TB
            Manifest["package.json, tsconfig.json, jsr.json"]:::package
            CLIEntry["CLI Entry (dressed.ts)"]:::process
            BotComp["Bot Components (src/bot/components)"]:::package
            RateLimit["Rate Limit (ratelimit.ts)"]:::process
            Resources["Discord REST Resources (src/bot/resources)"]:::package
            subgraph "Server Module"
                direction TB
                BuildPipeline["Build Pipeline (src/server/build)"]:::process
                ServerCore["HTTP Server (index.ts, server.ts)"]:::process
                Handlers["Handlers (src/server/handlers)"]:::process
                Signature["Signature Verification (signature.ts)"]:::process
                ServerUtils["Server Utils (utils.ts)"]:::process
            end
            Types["Shared Types (src/types)"]:::package
            Utils["Shared Utils (src/utils)"]:::package
        end

        subgraph "Support Package: dressed-matcher"
            direction TB
            Matcher["Index (src/index.ts)"]:::package
        end

        subgraph "Support Package: dressed-next"
            direction TB
            NextAdapter["Index (src/index.ts)"]:::package
        end
    end

    %% Docs Site Layer
    subgraph "Documentation Site (www)"
        direction TB
        SiteManifest["package.json, next.config.ts, tsconfig.json"]:::docs
        Layout["App Layout (src/app/layout.tsx)"]:::docs
        Page["App Page (src/app/page.tsx)"]:::docs
        DocsLayout["Docs Layout (src/app/docs/layout.tsx)"]:::docs
        DocsPage["Docs Pages (src/app/docs/[...slug]/page.tsx)"]:::docs
        Components["UI Components (src/components)"]:::docs
        Styles["Tailwind (globals.css, tailwind.config.ts)"]:::docs
        Hooks["Hooks & Utils (src/hooks, src/lib)"]:::docs
    end

    %% Runtime Layer
    subgraph "Runtime & Hosting"
        direction TB
        NPMRegistry["NPM Registry"]:::external
        HTTPServer["HTTP Server / Serverless"]:::server
        DiscordAPI["Discord API"]:::external
    end

    %% Flows
    TS --> Manifest
    TS --> Matcher
    TS --> NextAdapter
    Manifest --> NPMRegistry
    Matcher --> NPMRegistry
    NextAdapter --> NPMRegistry
    NPMRegistry --> HTTPServer
    HTTPServer --> ServerCore
    HTTPServer --> Handlers
    Handlers --> Signature --> ServerUtils
    ServerCore --> DiscordAPI
    DiscordAPI --> HTTPServer

    %% Docs Consumption
    NextAdapter --> Layout
    Layout --> Page
    Page --> Components
    Components --> DocsLayout --> DocsPage
    DocsPage --> HTTPServer
    Styles --> Components
    Hooks --> Components

    %% Click Events
    click CLI "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/bin/dressed.ts"
    click Turborepo "https://github.com/inbestigator/dressed/blob/main/turbo.json"
    click TestWF "https://github.com/inbestigator/dressed/blob/main/.github/workflows/test.yml"
    click PubWF "https://github.com/inbestigator/dressed/blob/main/.github/workflows/publish.yml"
    click Manifest "https://github.com/inbestigator/dressed/blob/main/packages/dressed/package.json"
    click CLIEntry "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/bin/dressed.ts"
    click BotComp "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/bot/components"
    click RateLimit "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/bot/ratelimit.ts"
    click Resources "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/bot/resources"
    click BuildPipeline "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/server/build"
    click ServerCore "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/server/index.ts"
    click Handlers "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/server/handlers"
    click Signature "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/server/signature.ts"
    click ServerUtils "https://github.com/inbestigator/dressed/blob/main/packages/dressed/src/server/utils.ts"
    click Types "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/types"
    click Utils "https://github.com/inbestigator/dressed/tree/main/packages/dressed/src/utils"
    click Matcher "https://github.com/inbestigator/dressed/blob/main/packages/dressed-matcher/src/index.ts"
    click NextAdapter "https://github.com/inbestigator/dressed/blob/main/packages/dressed-next/src/index.ts"
    click SiteManifest "https://github.com/inbestigator/dressed/blob/main/www/package.json"
    click Layout "https://github.com/inbestigator/dressed/blob/main/www/src/app/layout.tsx"
    click Page "https://github.com/inbestigator/dressed/blob/main/www/src/app/page.tsx"
    click DocsLayout "https://github.com/inbestigator/dressed/blob/main/www/src/app/docs/layout.tsx"
    click DocsPage "https://github.com/inbestigator/dressed/blob/main/www/src/app/docs/[...slug]/page.tsx"
    click Components "https://github.com/inbestigator/dressed/tree/main/www/src/components"
    click Styles "https://github.com/inbestigator/dressed/blob/main/www/src/app/globals.css"
    click Styles "https://github.com/inbestigator/dressed/blob/main/www/tailwind.config.ts"
    click Hooks "https://github.com/inbestigator/dressed/blob/main/www/src/hooks/use-mobile.tsx"
    click Hooks "https://github.com/inbestigator/dressed/blob/main/www/src/lib/utils.ts"

    %% Styles
    classDef developer fill:#FFD580,stroke:#333,stroke-width:1px
    classDef ci fill:#FFE4E1,stroke:#333,stroke-width:1px
    classDef package fill:#E6E6FA,stroke:#333,stroke-width:1px
    classDef process fill:#D0F0C0,stroke:#333,stroke-width:1px
    classDef server fill:#AFEEEE,stroke:#333,stroke-width:1px
    classDef external fill:#F0E68C,stroke:#333,stroke-width:1px
    classDef docs fill:#FFFACD,stroke:#333,stroke-width:1px
```
