# muratkeremozcan/cypress-react-component-test-examples architecture

> Architecture diagram of the GitHub repository muratkeremozcan/cypress-react-component-test-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muratkeremozcan/cypress-react-component-test-examples
- Repository: https://github.com/muratkeremozcan/cypress-react-component-test-examples

## Overview

##### Project Type and Purpose
- This is a frontend‐focused repository containing a small React application (built with Create React App and TypeScript) plus a rich suite of Cypress examples (component tests under cypress/component and end-to-end tests under cypress/e2e).
- Purpose: provide working Cypress 10+ examples for both component testing (CT) and e2e testing, along with continuous integration workflows.

##### Key Directories and Indicators
- src/ : the React application source (App.tsx, index.tsx, CSS, test harness).
- public/ & index.html : static assets served by the development server.
- cypress/ :
- component/ : hundreds of component‐level test examples organized by topic or library.
- e2e/ : end-to-end tests (e.g. sanity checks).
- support/, fixtures/ : Cypress support code and test data.
- .github/workflows/ : CI pipelines (build, lint, type-check, e2e, CT).
- package.json & yarn scripts: orchestrate start, cy:open, cy:run, cy:open-ct, cy:run-ct.

##### Main Components
A. Developer Workstation
- Node.js & Yarn/NPM
- Local filesystem containing repo
- IDE/editor
B. React Development Server
- Webpack dev server (CRA) serving public/index.html and compiled JS/CSS from src/
C. Cypress Runners
1. E2E Runner
- Spins up against the React Dev Server over HTTP
- Executes cypress/e2e spec files
2. Component Test Runner (CT)
- Bundles mounted React components via a special Webpack config
- Executes cypress/component spec files without full server
D. Continuous Integration (GitHub Actions)
- Checkout & cache node_modules
- Build step (yarn build or tsc)
- Lint & Type-check
- Cypress e2e tests (cy:run)
- Cypress CT tests (cy:run-ct)
E. External Services
- NPM/Yarn Registry for dependency installation
- (Optional) Cypress Dashboard for test reporting badge

##### Relationships & Data Flows
- Developer triggers Yarn commands → invokes CRA dev server or Cypress CLI
- CRA server serves assets → Browser / E2E runner hits http://localhost:3000
- CT runner mounts individual components → no HTTP server required
- CI triggers actions sequentially → caches dependencies → builds → tests → reports status

##### Architectural Patterns & Principles
- Clear separation of production app code (src/, public/) vs. test code (cypress/)
- Single‐page application (SPA) served by a dev server
- Two testing layers:
- E2E tests exercise full app through browser API
- Component tests isolate and mount individual React components
- Multi-stage CI for performance: cache → build → lint → type-check → test

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Machine"
        Dev["Developer"] 
        NodeYarn["Node.js & Yarn"] 
        FS["Local Filesystem"] 
        IDE["IDE / Editor"] 
    end

    Dev -->|"uses"| NodeYarn
    Dev -->|"edits"| FS
    Dev -->|"launches"| IDE
    NodeYarn -->|"yarn install"| NPM[(NPM Registry)]
    Dev -->|"yarn start"| CRA["CRA Dev Server"]
    
    CRA -->|"serves"| Public["public/index.html"]
    CRA -->|"compiles"| Src["src/"]
    CRA -->|"uses"| TSConf["tsconfig.json"]
    CRA -->|"http://localhost:3000"| E2ERunner["Cypress E2E Runner"]
    
    CTRunner["Cypress CT Runner"] 
    CTRunner -->|"mounts components"| Src

    subgraph "Cypress Component Tests"
        CompDir["cypress/component/"]
        SupportComp["cypress/support/component.tsx"]
        SupportCompIndex["cypress/support/component-index.html"]
    end
    CompDir --> CTRunner
    SupportComp --> CTRunner
    SupportCompIndex --> CTRunner

    subgraph "Cypress E2E Tests"
        E2EDir["cypress/e2e/"]
        SupportE2E["cypress/support/e2e.ts"]
    end
    E2EDir --> E2ERunner
    SupportE2E --> E2ERunner

    CypressConfig["cypress.config.ts"]
    Fixtures["cypress/fixtures/"]
    Commands["cypress/support/commands.ts"]
    CypressConfig --> E2ERunner
    CypressConfig --> CTRunner
    Fixtures --> E2ERunner
    Fixtures --> CTRunner
    Commands --> E2ERunner
    Commands --> CTRunner

    NodeYarn -->|"triggers"| CI["GitHub Actions CI"]
    subgraph "GitHub Actions CI"
        Cache["Cache dependencies"]
        Build["Build (yarn build / tsc)"]
        Lint["Lint & Type-check"]
        CI_E2E["Run Cypress E2E"]
        CI_CT["Run Cypress CT"]
    end
    CI --> Cache --> Build --> Lint --> CI_E2E --> CI_CT
    CI_CT -->|"report"| Dashboard[(Cypress Dashboard)]

    FS --> Package["package.json"]
    FS --> TSConfigFile["tsconfig.json"]
    FS --> Nvmrc[".nvmrc"]
    FS --> Readme["README.md"]
    FS --> Workflow1[".github/workflows/main.yml"]
    FS --> Workflow2[".github/workflows/merge-gatekeeper.yml"]

    classDef app fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px
    classDef test fill:#bbdefb,stroke:#1565c0,stroke-width:2px
    classDef ci fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px
    classDef ext fill:#e0e0e0,stroke:#757575,stroke-width:2px
    classDef dev fill:#f3e5f5,stroke:#6a1b9a,stroke-width:2px
    classDef doc fill:#ffffff,stroke:#424242,stroke-width:1px

    class Dev,NodeYarn,IDE,FS dev
    class CRA,Public,Src,TSConf app
    class E2ERunner,CTRunner test
    class CI,Cache,Build,Lint,CI_E2E,CI_CT ci
    class NPM,Dashboard ext
    class CompDir,SupportComp,SupportCompIndex,E2EDir,SupportE2E,CypressConfig,Fixtures,Commands,Package,TSConfigFile,Nvmrc,Readme,Workflow1,Workflow2 doc

    click Src "https://github.com/muratkeremozcan/cypress-react-component-test-examples/tree/master/src/"
    click Public "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/public/index.html"
    click Package "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/package.json"
    click TSConfigFile "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/tsconfig.json"
    click CompDir "https://github.com/muratkeremozcan/cypress-react-component-test-examples/tree/master/cypress/component/"
    click SupportComp "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/cypress/support/component.tsx"
    click SupportCompIndex "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/cypress/support/component-index.html"
    click E2EDir "https://github.com/muratkeremozcan/cypress-react-component-test-examples/tree/master/cypress/e2e/"
    click SupportE2E "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/cypress/support/e2e.ts"
    click CypressConfig "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/cypress.config.ts"
    click Fixtures "https://github.com/muratkeremozcan/cypress-react-component-test-examples/tree/master/cypress/fixtures/"
    click Commands "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/cypress/support/commands.ts"
    click Workflow1 "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/.github/workflows/main.yml"
    click Workflow2 "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/.github/workflows/merge-gatekeeper.yml"
    click Nvmrc "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/.nvmrc"
    click Readme "https://github.com/muratkeremozcan/cypress-react-component-test-examples/blob/master/README.md"
```
