# bjoernrave/rave-ui architecture

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

- Interactive diagram: https://gitdiagram.com/bjoernrave/rave-ui
- Repository: https://github.com/bjoernrave/rave-ui

## Overview

##### Project type and purpose
- This is an open‑source React UI component library (“Rave‑Ui”) specialized in dynamic form inputs, tables, modals, theming, and localization.
- It ships as a single package that consumers install via npm/yarn. Storybook is used for live component demos, and Jest for automated testing.

##### File structure
- Top‑level folders:
- `.github/workflows/` – CI pipelines for build, test, bundle‑size checks.
- `storybook/` – Storybook configuration and setup files.
- `src/` – All application code:
– `src/FormItems/Basic/` – Primitive form controls (TextInput, DateInput, etc.).
– `src/locales/` – i18n resource files for “en” and “de.”
– Various higher‑order or composite components (`FormPage`, `DocumentViewer`, `ImageViewer`, `Table`, etc.).
– Entry point: `src/index.ts`.
- `src/tests/` – Jest tests for utility functions and components.
- `stories/` – Storybook stories illustrating component usage.
- Config files: `package.json`, `tsconfig.json`, `jest.config.js`, `biome.json` (formatter/linter), and CI workflows.

##### README for additional insights
- Lists peer dependencies on React, MUI, @emotion, React Hook Form, Zod, date‑fns, etc.

##### Main components
a. Core UI Library (src/index.ts)
b. Form Engine:
– Basic Inputs (`FormItems/Basic/*`)
– Composite Controls (`MultiCreate`, `EntitySelect`, `TableInput`, etc.)
– Form context & validation (React Hook Form + Zod + `SchemaContext`)
c. Theming & Styling
– Emotion + MUI theme integration (`lib/theme.ts`, `lib/styles.tsx`)
d. Localization
– i18n loader + JSON resources (`locales/en`, `locales/de`)
e. Stories & Demos
– Storybook server & configurations (`.storybook/`)
f. CI/CD
– GitHub Actions workflows for test, build, bundle size
g. Consumers
– External applications importing the library as a dependency

##### Relationships & interactions
- Consumer App → installs Rave‑Ui → imports components from `src/index.ts`.
- UI components → depend on theme & styling context.
- Form components → send/receive data via React Hook Form context & Zod schemas.
- Basic controls → form composites.
- Localization provider → supplies translation strings to components.
- Storybook → imports same entry point + mocks providers for live preview.
- CI workflows → run tests, lint, build artifacts, and publish to NPM.

##### Architectural patterns & design principles
- Component‑based Architecture: each input is a self‑contained React component.
- Provider pattern: ThemeProvider, LocalizationProvider, FormProvider.
- Composition over inheritance: composite form controls built by combining Basic inputs.
- Separation of concerns: `lib/` holds utilities; `FormItems/` holds UI; `stories/` holds demos.
- Extensibility: consumers can wrap or extend `SchemaContext`, override theme tokens, add new locales.

##### Technologies & frameworks to annotate
- React, TypeScript
- MUI (Material‑UI) + @emotion/react for styling
- React Hook Form + @hookform/resolvers + Zod for form management & validation
- date‑fns for date utilities
- react‑dropzone for file inputs
- Storybook for component sandbox
- Jest + Testing Library for automated tests

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Rave‑Ui Package"
        direction TB

        Core["Core UI Library\n(src/index.ts)"]:::code
        subgraph "Form Engine"
            direction TB
            subgraph "Basic Inputs"
                direction TB
                BooleanInput["BooleanInput"]:::code
                TextInput["TextInput"]:::code
                DateInput["DateInput"]:::code
            end
            subgraph "Composite Controls"
                direction TB
                MultiCreate["MultiCreate"]:::code
                EntitySelect["EntitySelect"]:::code
                TableInput["TableInput"]:::code
                MultiCheckbox["MultiCheckbox"]:::code
                FileInput["FileInput"]:::code
                FileUpload["FileUpload"]:::code
                WithCreationOption["WithCreationOption"]:::code
                PhoneInput["PhoneInput"]:::code
                FormGroup["FormGroup"]:::code
                FormModal["FormModal"]:::code
                FormPage["FormPage"]:::code
            end
            subgraph "Context & Validation"
                direction TB
                SchemaContext["SchemaContext"]:::code
                FormComponent["Form"]:::code
                DateTimeProvider["DateTimeProvider"]:::code
            end
        end

        subgraph "Theming & Styling"
            direction TB
            ThemeTS["theme.ts"]:::code
            StylesTSX["styles.tsx"]:::code
            ColorsTS["colors.ts"]:::code
            MiscTS["misc.ts"]:::code
            TypesTS["types.ts"]:::code
            DateUtil["date.ts"]:::code
        end

        subgraph Localization
            direction TB
            EnLocale["common.json\n(en)"]:::resource
            DeLocale["common.json\n(de)"]:::resource
            Loader["AppWrapper"]:::code
        end

        subgraph "Utility Components"
            direction TB
            DocumentViewer["DocumentViewer"]:::code
            ImageViewer["ImageViewer"]:::code
            TableComp["Table"]:::code
            BooleanIcon["BooleanIcon"]:::code
            ButtonGroup["ButtonGroup"]:::code
            DarkmodeSwitch["DarkmodeSwitch"]:::code
            Infos["Infos"]:::code
        end

        subgraph "Stories & Demos"
            direction TB
            SBMain[".storybook/main.js"]:::story
            SBPreview[".storybook/preview.tsx"]:::story
            SBWithRHF[".storybook/withRHF.tsx"]:::story
            StoriesInput["Input.stories.tsx"]:::story
            StoriesComposite["composites.stories.tsx"]:::story
            StoriesGeneral["general.stories.tsx"]:::story
        end

        subgraph "CI/CD Pipelines"
            direction TB
            MainWF["main.yml"]:::ci
            SizeWF["size.yml"]:::ci
            JestConfig["jest.config.js"]:::ci
            TestFiles["misc.test.tsx"]:::ci
        end
    end

    subgraph "External Dependencies"
        direction TB
        React["React"]:::extdep
        MUI["@mui/material"]:::extdep
        Emotion["@emotion/react"]:::extdep
        RHF["React Hook Form"]:::extdep
        Zod["Zod"]:::extdep
        DateFns["date‑fns"]:::extdep
        Dropzone["react‑dropzone"]:::extdep
        StorybookExt["Storybook"]:::extdep
        JestExt["Jest"]:::extdep
    end

    subgraph "Consumer Application"
        ConsumerApp["Consumer App"]:::consumer
    end

    ConsumerApp -->|"installs & imports"| Core
    Core -->|"exports components"| BooleanInput & TextInput & DateInput & MultiCreate & EntitySelect & TableInput
    BooleanInput -->|"used by"| MultiCreate
    TextInput -->|"used by"| MultiCreate
    DateInput -->|"used by"| FileInput
    Core -->|"uses theme"| ThemeTS
    ThemeTS -->|"styled by"| StylesTSX
    Core -->|"uses localization"| EnLocale & DeLocale & Loader
    Core -->|"uses validation"| SchemaContext & FormComponent & DateTimeProvider
    Core -->|"uses utilities"| DocumentViewer & ImageViewer & TableComp
    StoriesInput & StoriesComposite & StoriesGeneral -->|"import entry"| Core
    SBMain & SBPreview & SBWithRHF -->|"configure"| StorybookExt
    MainWF & SizeWF -->|"run tests/build"| JestExt & Core
    JestConfig & TestFiles -->|"define tests"| JestExt
    Core -->|"published via"| MainWF

    React & MUI & Emotion & RHF & Zod & DateFns & Dropzone -->|"peer deps"| Core

    classDef code fill:#f9f,stroke:#333,stroke-width:1px
    classDef extdep fill:#ffc,stroke:#333,stroke-width:1px
    classDef consumer fill:#cfc,stroke:#333,stroke-width:1px
    classDef resource fill:#ccf,stroke:#333,stroke-width:1px
    classDef story fill:#fcf,stroke:#333,stroke-width:1px
    classDef ci fill:#cff,stroke:#333,stroke-width:1px

    click Core "https://github.com/bjoernrave/rave-ui/blob/master/src/index.ts"
    click BooleanInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/BooleanInput.tsx"
    click TextInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/TextInput.tsx"
    click DateInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/DateInput.tsx"
    click MultiCreate "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/MultiCreate.tsx"
    click EntitySelect "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/EntitySelect.tsx"
    click TableInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/TableInput.tsx"
    click MultiCheckbox "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/MultiCheckbox.tsx"
    click FileInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/FileInput.tsx"
    click FileUpload "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/FileUpload.tsx"
    click WithCreationOption "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/WithCreationOption.tsx"
    click PhoneInput "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/PhoneInput.tsx"
    click FormGroup "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/FormGroup.tsx"
    click FormModal "https://github.com/bjoernrave/rave-ui/blob/master/src/FormModal.tsx"
    click FormPage "https://github.com/bjoernrave/rave-ui/blob/master/src/FormPage.tsx"
    click SchemaContext "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/SchemaContext.tsx"
    click FormComponent "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/Form.tsx"
    click DateTimeProvider "https://github.com/bjoernrave/rave-ui/blob/master/src/FormItems/Basic/DateTimeProvider.tsx"
    click ThemeTS "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/theme.ts"
    click StylesTSX "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/styles.tsx"
    click ColorsTS "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/colors.ts"
    click MiscTS "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/misc.ts"
    click TypesTS "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/types.ts"
    click DateUtil "https://github.com/bjoernrave/rave-ui/blob/master/src/lib/date.ts"
    click EnLocale "https://github.com/bjoernrave/rave-ui/blob/master/src/locales/en/common.json"
    click DeLocale "https://github.com/bjoernrave/rave-ui/blob/master/src/locales/de/common.json"
    click Loader "https://github.com/bjoernrave/rave-ui/blob/master/src/AppWrapper.tsx"
    click DocumentViewer "https://github.com/bjoernrave/rave-ui/blob/master/src/DocumentViewer.tsx"
    click ImageViewer "https://github.com/bjoernrave/rave-ui/blob/master/src/ImageViewer.tsx"
    click TableComp "https://github.com/bjoernrave/rave-ui/blob/master/src/Table.tsx"
    click BooleanIcon "https://github.com/bjoernrave/rave-ui/blob/master/src/BooleanIcon.tsx"
    click ButtonGroup "https://github.com/bjoernrave/rave-ui/blob/master/src/ButtonGroup.tsx"
    click DarkmodeSwitch "https://github.com/bjoernrave/rave-ui/blob/master/src/DarkmodeSwitch.tsx"
    click Infos "https://github.com/bjoernrave/rave-ui/blob/master/src/Infos.tsx"
    click SBMain "https://github.com/bjoernrave/rave-ui/blob/master/.storybook/main.js"
    click SBPreview "https://github.com/bjoernrave/rave-ui/blob/master/.storybook/preview.tsx"
    click SBWithRHF "https://github.com/bjoernrave/rave-ui/blob/master/.storybook/withRHF.tsx"
    click StoriesInput "https://github.com/bjoernrave/rave-ui/blob/master/stories/Input.stories.tsx"
    click StoriesComposite "https://github.com/bjoernrave/rave-ui/blob/master/stories/composites.stories.tsx"
    click StoriesGeneral "https://github.com/bjoernrave/rave-ui/blob/master/stories/general.stories.tsx"
    click MainWF "https://github.com/bjoernrave/rave-ui/blob/master/.github/workflows/main.yml"
    click SizeWF "https://github.com/bjoernrave/rave-ui/blob/master/.github/workflows/size.yml"
    click JestConfig "https://github.com/bjoernrave/rave-ui/blob/master/jest.config.js"
    click TestFiles "https://github.com/bjoernrave/rave-ui/blob/master/src/tests/misc.test.tsx"
```
