How strxangxl/embeddedchat works
Main Components
• Frontend: The “react” package is the core UI library. It contains numerous components such as views, hooks, themes, and UI elements required for the chat interface. In addition, there are related packages like “react-native”, “layout_editor”, “ui-elements”, and “ui-kit” that provide mobile-specific components, layout customization, and additional UI libraries.
• Backend/Integration Layers: The “api” package houses backend behaviors, API integrations, and related logic to communicate with Rocket.Chat. Likewise, the “auth” package deals with the authentication process, offering various login options and OAuth integrations.
• Supporting/Utility Packages:
• “rc-app” is another backend component that deals with Rocket.Chat-specific endpoints.
• “docs” is used for documentation and developer guides.
• “e2e-react”, “htmlembed”, and “markups” provide testing, HTML embedding, and markup management respectively.
• Build/Dev Infrastructure: There are configuration files for GitHub workflows (CI/CD), Husky hooks for commit checks, and Lerna for managing package versions.
• External Systems: The architecture depends on an external Rocket.Chat server (which needs to have “Enable CORS” turned on) that all components interact with for chat functionalities.
Relationships and Interactions
• The “react” package (frontend/UI) calls the “api” package to fetch and send data.
• The “api” package, in turn, uses the “auth” package (or has a dependency on it) to perform authentication tasks.
• The “rc-app” may represent an alternative integration point to handle specific Rocket.Chat endpoints.
• Test and development packages (like “e2e-react”) integrate by simulating user interactions with the “react” package.
Architectural Patterns and Design Principles
• The project clearly follows a modular, package-based architecture that promotes separation of concerns:
• Frontend (React-based UI, theming, Storybook for live component development)
• Middleware/API layer for server communication (API and Auth)
• Utility layers for documentations, tests, and embedding capabilities.
• How packages depend on each other (for example, the “react” package depends on the “api” package, which in turn depends on the “auth” package).
• Use of configuration files (rollup.config.js for bundling, tsconfig.json for TypeScript) that reflect each package’s individual build process.