# sherlo-io/sherlo architecture

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

- Interactive diagram: https://gitdiagram.com/sherlo-io/sherlo
- Repository: https://github.com/sherlo-io/sherlo

## Overview

##### Main Components to Identify
- CLI Tool (packages/cli):
- Acts as the primary entry point where developers run commands (e.g., “npx sherlo@latest init”).
- Contains multiple commands for initializing projects, managing dependencies, handling configurations, and running local builds/tests.

- GitHub Action (packages/action):
- Automates visual tests in CI/CD pipelines.
- Interfaces with repository events (such as pull request checks and release workflows) as seen in the extensive GitHub workflows in .github/workflows.

- React Native Storybook Integration (packages/react-native-storybook):
- Provides the integration layer with React Native Storybook.
- Contains platform-specific implementations (both Android and iOS) and helpers to enable visual testing of UI components.

- Configuration & Testing:
- The “configs” and “testing” directories are used to manage device configurations, sample stories, and end-to-end tests.
- Testing directories like testing/expo-storybook-8 show sample projects to validate integration with Expo and Storybook.

- CI/CD & Automation Workflows:
- The .github/workflows folder contains multiple YAML files handling different build scenarios (Android, iOS, Expo Cloud builds, stress testing, etc.).
- These workflows interact with both the CLI and Action packages.

##### Relationships and Interactions
- Developer invokes the CLI tool in their project to initialize Sherlo integration.
- The CLI interacts with the Storybook integration package to instrument the React Native Storybook setup.
- When code changes occur (or on scheduled builds), GitHub Actions are triggered to run visual tests. They call scripts in the action package (which in turn might leverage the CLI functionality).
- Build pipelines (Expo, iOS, Android) as defined in the CI/CD configuration use the workflows to automate builds and tests.
- Visual test results are then uploaded to the Sherlo Cloud service (not directly represented in the repo but implied as the backend for reviews) where UI diffs can be reviewed.

##### Architectural Patterns and Design Principles
- Monorepo / Modular Architecture:
- The project splits its functionality across multiple packages, enabling clean separation of concerns (CLI, GitHub Action, and React Native integration).
- Integration via Command Patterns:
- The CLI commands that initiate builds, tests, and updates encapsulate interactions with different subcomponents and workflows.
- Continuous Integration/Deployment:
- The robust set of GitHub workflows illustrates a focus on automated builds, testing, and release management.

##### Relevant Technologies and Frameworks
- Node.js/TypeScript for CLI and Action packages.
- React Native and Storybook for UI components.
- GitHub Actions for CI/CD automation.
- Expo for building mobile applications and managing different environments.
- Lerna for managing the monorepo structure.

##### Elements
- Use clear, descriptive labels for each component (e.g., "Sherlo CLI", "GitHub Action", "React Native Storybook Integration", "CI/CD Workflows", "Sherlo Cloud Backend").
- From Developer to CLI (user command input).
- From CLI to React Native Storybook Integration (initiating visual tests).
- From GitHub Action to CI/CD Workflows (automated test execution).
- From CI/CD Workflows back to a hypothetical Sherlo Cloud component or reporting module.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    Developer("Developer"):::user
    CLI("Sherlo CLI"):::cli
    RNStorybook("React Native Storybook Integration"):::integration
    Action("GitHub Action"):::action
    Workflows("CI/CD Workflows"):::ci
    Config("Configurations"):::config
    Testing("Testing & Sample Projects"):::testing
    Cloud("Sherlo Cloud Backend"):::cloud

    %% Relationships
    Developer -->|"runsCommand"| CLI
    CLI -->|"initiatesTests"| RNStorybook
    CLI -->|"readsConfig"| Config
    CLI -->|"executesTests"| Testing
    Developer -->|"codePush"| Action
    Action -->|"triggers"| Workflows
    Workflows -->|"executesCLI"| CLI
    CLI -->|"uploadsResults"| Cloud
    Action -->|"invokesCLI"| CLI

    %% Click Events
    click CLI "https://github.com/sherlo-io/sherlo/tree/dev/packages/cli"
    click Action "https://github.com/sherlo-io/sherlo/tree/dev/packages/action"
    click Workflows "https://github.com/sherlo-io/sherlo/tree/dev/.github/workflows"
    click RNStorybook "https://github.com/sherlo-io/sherlo/tree/dev/packages/react-native-storybook"
    click Config "https://github.com/sherlo-io/sherlo/tree/dev/configs"
    click Testing "https://github.com/sherlo-io/sherlo/tree/dev/testing/expo-storybook-8"

    %% Styles
    classDef user fill:#F6E2B3,stroke:#8B6914,stroke-width:2px;
    classDef cli fill:#C4E1FF,stroke:#1F78B4,stroke-width:2px;
    classDef integration fill:#C8FACC,stroke:#2E8B57,stroke-width:2px;
    classDef action fill:#FFD7B5,stroke:#E67E22,stroke-width:2px;
    classDef ci fill:#F9D5E5,stroke:#D81B60,stroke-width:2px;
    classDef config fill:#E0F7FA,stroke:#00ACC1,stroke-width:2px;
    classDef testing fill:#FFF3B0,stroke:#FFB300,stroke-width:2px;
    classDef cloud fill:#FFE0B2,stroke:#FB8C00,stroke-width:2px;
```
