How sendbird/sendbird-uikit-react works
Project Type and Purpose
• This is a React-based UI kit library (“@sendbird/uikit-react”) that sits on top of the Sendbird JavaScript SDK.
• It provides ready-made, modular chat components (Channel, ChannelList, ChannelSettings, MessageSearch, OpenChannel, etc.) and an App shell that consumers can drop into their own web/mobile React projects.
• The repo also includes two demo apps (apps/testing and apps/visual-test) and a Storybook for visualizing components.
High-Level File Structure & Architecture
• Top-level config: CI/CD (.circleci/, .github/workflows), linting & formatting (.eslintrc.js, .stylelintrc.js), package management (yarnrc.yml, .yarn/), and build scripts (rollup.config.mjs, plopfile.js, scripts/).
• src/ – the core library:
• _externals/: third-party libs (lamejs).
• hooks/: generic React hooks.
• lib/: Sendbird context provider, pubSub, handlers for SDK events.
• modules/: feature modules (Channel, GroupChannel, ChannelList, ChannelSettings, CreateChannel, Thread, etc.). Each module has its own React context provider, hooks, dux (redux-like local state), and presentational sub-components.
• ui/: low-level, reusable presentational components (Button, Avatar, Modal, MessageInput, etc.).
• utils/: shared utility functions and type helpers.
• stories/: Storybook stories and MDX docs.
• apps/ – local demo projects:
• apps/testing: Vite-based playground using env variables for Sendbird App ID.
• apps/visual-test: visual regression test harness.
• Tests & CI:
• Unit & integration tests with Jest (jest.config.js, jest-setup.js).
• Visual tests (Playwright).
• CI pipelines automate lint, test, coverage, Storybook deployment, and package publishing.
Key Architectural Patterns
• Layered, modular design:
1. Core SDK layer (Sendbird JS SDK & external libs).
2. Context & state management layer (lib/Sendbird, module‐specific providers, dux).
3. Feature modules (modules/*): each encapsulates its own context, hooks, UI composition.
4. UI component layer (ui/*): stateless, reusable presentational components.
• React Context for global state (SendBirdProvider) and feature state (e.g., ChannelProvider).
• PubSub and event handlers abstract SDK callbacks.
• Pluggable build & code generation via Plop.js templates.
• Consumer Application
• Imports @sendbird/uikit-react (core library).
• Wraps root in <SendBirdProvider> → provides SDK, connection status.
• Renders feature components (<App>, <ChannelList>, <Channel>, etc.).
• UI Kit Library (src/)
• External Dependencies: React, TypeScript, Sendbird JS SDK, LameJS.
• Core Context Layer: SendBirdProvider → context value includes SDK instance, connection handlers.
• Module Layer: for each feature (Channel, GroupChannel, OpenChannel, etc.):
– React Context Provider
– Hooks for fetching data, sending messages, handling events
– Internal state (dux)
– Composition of ui/ components
• UI Layer: generic UI components (Button, Avatar, Modal, etc.) consumed by modules.
• Development & Build Tools
• Vite Dev Server (apps/testing) and Storybook
• RollupJS build pipeline
• Plop.js scaffolding for new components
• Yarn Berry workspaces and SDK integrations
• CI/CD Pipelines
• GitHub Actions / CircleCI: lint → test → coverage → storybook deploy → npm publish