# anshita-bhasin/cypress_k6 architecture

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

- Interactive diagram: https://gitdiagram.com/anshita-bhasin/cypress_k6
- Repository: https://github.com/anshita-bhasin/cypress_k6

## Overview

##### Project Type and Purpose
- This is a **multi-module training repository** for:
- Learning core JavaScript (the “Javascript” folder)
- Front-end & API test automation with **Cypress** (the “cypress_training/cypress” folder)
- *(Intended)* performance/load testing with **k6** (per the README, even though we don’t see the k6 folder in your tree)

##### File Structure
- Top level:
- Javascript/ … → dozens of plain JS examples (arrays, loops, promises, classes, etc.)
- cypress_training/
– cypress.config.js → Cypress configuration
– cypress/
· fixtures/ → test data (JSON, Excel)
· downloads/ → captured files during tests
· e2e/… → all your `.cy.js` test specs
– support/ → shared commands/helpers
– package.json & node_modules → Node.js ecosystem for Cypress
- Key Patterns:
- **Separation of Concerns:** JS examples vs. E2E tests vs. performance tests
- **Test-Driven Layers:** Fixtures & commands feed into spec files, which drive the Cypress runner

##### Extract Additional Insights from the README
- The README explicitly lays out three **modules**:
1. JavaScript Basics (src or Javascript directory)
2. Cypress for UI/API testing
3. k6 for load testing
- It also describes the **execution flow**:
- `node src/example.js` for JS
- `npx cypress open` or `npx cypress run` for E2E
- `k6 run k6/load_test.js` for performance

##### Main Components and Their Interactions
A. **Developer Workstation** (Node.js environment)
- Runs all three modules
B. **JavaScript Examples Module**
- Files in `/Javascript`
- Executed directly by Node.js → console output
C. **Cypress E2E Test Module**
- Cypress Test Runner (Node process)
- loads:
- Test specs (`.cy.js`)
- Fixtures (JSON, Excel)
- Support files (commands.js, e2e.js)
- Spawns a **Browser** (Chrome/Electron)
- Drives the **System Under Test** (could be a local app or public web pages / APIs) via HTTP/DOM
- Writes outputs to `cypress/downloads` and on-screen test reports
D. **k6 Load Test Module** (per README)
- k6 CLI (Go-based tool)
- Load script (`k6/load_test.js`)
- Fires HTTP requests/virtual users at the same SUT endpoints
- Generates metrics (VU counts, latency, throughput)

##### Architectural Patterns & Design Principles
- **Modularity:** Three self-contained training modules
- **Separation of Concerns:** each layer (examples, functional tests, performance tests) lives in its own folder
- **Single Source of Truth for Config:** `cypress.config.js` centralizes environment settings
- **Reusable Test Helpers:** `cypress/support/commands.js`

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Zones
    subgraph "Developer Workstation"
        Node["Node.js v18.x"]:::nodejs
    end

    subgraph "JavaScript Examples Module"
        JSExamples["/Javascript"]:::examples
    end

    subgraph "Cypress E2E Testing"
        CypressRunner["Cypress Runner (v12.x)"]:::cypress
        Specs["Test Specs (.cy.js)"]:::cypress
        Fixtures["Fixtures (JSON, Excel)"]:::cypress
        Support["Support Files"]:::cypress
        Downloads["Downloads"]:::cypress
    end

    subgraph "Browser"
        Browser["Chrome/Electron"]:::cypress
    end

    subgraph "k6 Load Testing"
        K6CLI["k6 CLI (v0.x)"]:::k6
        LoadScript["load_test.js"]:::k6
        Metrics["Performance Metrics"]:::k6
    end

    subgraph "System Under Test / External APIs"
        SUT["SUT / Web Server"]:::external
    end

    %% Relationships
    Node -->|runs| JSExamples
    Node -->|executes| CypressRunner
    Node -->|executes| K6CLI
    JSExamples -->|console output| Node

    CypressRunner -->|loads| Specs
    CypressRunner -->|loads| Fixtures
    CypressRunner -->|loads| Support
    CypressRunner -->|writes| Downloads
    CypressRunner -->|spawns| Browser
    CypressRunner -->|HTTP request| SUT

    Browser -->|interacts| SUT
    Browser -->|renders/test| CypressRunner

    K6CLI -->|executes| LoadScript
    K6CLI -->|HTTP request| SUT
    K6CLI -->|records| Metrics

    %% Click Events
    click JSExamples "https://github.com/anshita-bhasin/cypress_k6/tree/main/Javascript/"
    click JSExamples "https://github.com/anshita-bhasin/cypress_k6/blob/main/README.md"
    click CypressRunner "https://github.com/anshita-bhasin/cypress_k6/blob/main/cypress_training/cypress.config.js"
    click Specs "https://github.com/anshita-bhasin/cypress_k6/tree/main/cypress_training/cypress/e2e/"
    click Fixtures "https://github.com/anshita-bhasin/cypress_k6/tree/main/cypress_training/cypress/fixtures/"
    click Downloads "https://github.com/anshita-bhasin/cypress_k6/tree/main/cypress_training/cypress/downloads/"
    click Support "https://github.com/anshita-bhasin/cypress_k6/blob/main/cypress_training/cypress/support/commands.js"
    click Support "https://github.com/anshita-bhasin/cypress_k6/blob/main/cypress_training/cypress/support/e2e.js"
    click Node "https://github.com/anshita-bhasin/cypress_k6/blob/main/cypress_training/package.json"
    click Node "https://github.com/anshita-bhasin/cypress_k6/blob/main/cypress_training/package-lock.json"
    click Node "https://github.com/anshita-bhasin/cypress_k6/tree/main/cypress_training/node_modules/"

    %% Styles
    classDef nodejs fill:#AEDFF7,stroke:#0366d6
    classDef examples fill:#cbe7ff,stroke:#0366d6
    classDef cypress fill:#b2f2bb,stroke:#2f9e44
    classDef k6 fill:#FFD8A8,stroke:#f76707
    classDef external fill:#E9ECEF,stroke:#495057
```
