# 7etrahedral/nightwatch-poc architecture

> Architecture diagram of the GitHub repository 7etrahedral/nightwatch-poc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/7etrahedral/nightwatch-poc
- Repository: https://github.com/7etrahedral/nightwatch-poc

## Overview

This repository is a NightwatchJS-based browser automation framework, not an application under test. Its architecture is organized around BDD feature files, page objects, step definitions, and a Dockerized Selenium/Chrome execution layer.

1. **Test specification layer**
   - The top-level test intent lives in `tests/features/*.feature`.
   - There are two feature areas: `facebook_pages_check.feature` and `twitter_pages_check.feature`.
   - These files define human-readable scenarios and act as the entry point for the test flow.

2. **BDD glue layer**
   - `tests/step_definitions/**` binds the Gherkin scenarios to executable automation steps.
   - Step definitions are split by domain (`facebook`, `twitter`), which keeps feature logic separated from browser interaction details.
   - This layer translates scenario steps into calls on page objects.

3. **Page object layer**
   - `tests/page-objects/**` contains the browser interaction model.
   - Facebook has multiple page objects: `facebook_login_page.js`, `facebook_home_page.js`, `facebook_user_page.js`, and `facebook_create_pages_page.js`.
   - Twitter currently has a simpler set with `twitter_home_page.js`.
   - This is the main abstraction boundary between test intent and UI selectors/actions.

4. **Execution flow**
   - The runtime path is: feature file → step definition → page object → Nightwatch browser command.
   - That keeps scenario logic stable even if selectors or navigation details change.
   - The repository’s structure suggests tests are driven through Nightwatch’s BDD support.

5. **Browser automation runtime**
   - `package.json` (not shown, but implied) and the README indicate NightwatchJS is the core test runner.
   - `Gruntfile.js` likely orchestrates test-related tasks or command aliases.
   - `docker-chrome-conf.js` appears to provide Nightwatch/Chrome execution settings for containerized runs.

6. **Selenium infrastructure**
   - The `selenoid/` directory contains the browser execution environment.
   - `selenoid/docker-compose.yml` starts the Selenium-compatible infrastructure in Docker.
   - `selenoid/browsers.json` defines browser image/runtime configuration, which is a key infra boundary for Chrome execution.
   - This means tests are not expected to run against a local interactive browser by default; they are designed for remote containerized Chrome.

7. **Configuration and environment**
   - `env.sample` is the template for local environment variables, copied to `.env` before running.
   - This implies credentials and runtime settings are externalized rather than hardcoded.
   - The architecture likely depends on environment-driven configuration for test targets, credentials, and Selenium endpoint details.

8. **Reporting pipeline**
   - `reports/chrome/create-html-report-chrome.js` indicates a post-test HTML report generation step.
   - The `reports/chrome/` directory is the output/reporting boundary for test artifacts.
   - The README’s separate `npm run report-chrome` step suggests report generation is decoupled from test execution.

9. **Project organization by domain**
   - The test code is split by product area rather than by technical layer alone.
   - Facebook is modeled more deeply than Twitter, which suggests different scenario complexity or coverage depth.
   - This makes the repo easy to expand with additional feature domains while preserving the same BDD/page-object pattern.

10. **Tooling and quality controls**
   - `.eslintrc.js` provides JavaScript linting.
   - `.vscode/` suggests local editor support and team workflow consistency.
   - `package-lock.json` and `npm ci` in the README show dependency reproducibility is important.

11. **How the system is intended to run**
   - Setup: copy `env.sample` to `.env`, install dependencies, bring up Selenoid via Docker Compose, run the tests, then generate the HTML report.
   - The architecture is therefore a pipeline: configuration → remote browser grid startup → BDD test execution → reporting.

12. **Diagram boundaries to preserve**
   - Draw clear boundaries between:
     - Gherkin specs
     - step definitions
     - page objects
     - Nightwatch runtime
     - Selenoid/Docker browser infrastructure
     - report generation
   - The important external dependency is the browser grid, not a backend API or application server inside this repo.

Main entry points: [`tests/step_definitions/facebook/facebook_login_steps.js`](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/facebook/facebook_login_steps.js) (Facebook steps), [`docker-chrome-conf.js`](https://github.com/7etrahedral/nightwatch-poc/blob/master/docker-chrome-conf.js) (Chrome config), [`tests/step_definitions/twitter/twitter_steps.js`](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/twitter/twitter_steps.js) (Twitter steps), [`tests/page-objects/facebook/facebook_login_page.js`](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_login_page.js) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_specs["BDD specs"]
  node_feature_facebook["Facebook feature<br/>gherkin spec"]
  node_feature_twitter["Twitter feature<br/>gherkin spec"]
end

subgraph group_glue["Step glue"]
  node_steps_facebook["Facebook steps<br/>bdd steps"]
  node_steps_twitter["Twitter steps<br/>bdd steps<br/>[twitter_steps.js]"]
end

subgraph group_pages["Page objects"]
  node_page_fb_login["Login page<br/>page object"]
  node_page_fb_home["Home page<br/>page object"]
  node_page_fb_user["User page<br/>page object"]
  node_page_fb_create["Create pages<br/>page object"]
  node_page_tw_home["Twitter home<br/>page object"]
end

subgraph group_runtime["Test runtime"]
  node_nightwatch["Nightwatch<br/>test runner"]
  node_grunt["Grunt tasks<br/>task runner<br/>[Gruntfile.js]"]
  node_chrome_conf["Chrome config<br/>runner config"]
end

subgraph group_infra["Browser infra"]
  node_selenoid_compose["Compose stack<br/>docker compose<br/>[docker-compose.yml]"]
  node_browsers_json["Browsers config<br/>browser catalog<br/>[browsers.json]"]
end

subgraph group_reports["Reporting"]
  node_report_script["HTML report<br/>report generator"]
end

subgraph group_tooling["Tooling"]
  node_env_sample["Env sample<br/>env template<br/>[env.sample]"]
  node_eslint["ESLint<br/>lint config<br/>[.eslintrc.js]"]
end

node_feature_facebook -->|"drives"| node_steps_facebook
node_feature_twitter -->|"drives"| node_steps_twitter
node_steps_facebook -->|"uses"| node_page_fb_login
node_steps_facebook -->|"uses"| node_page_fb_home
node_steps_facebook -->|"uses"| node_page_fb_user
node_steps_facebook -->|"uses"| node_page_fb_create
node_steps_twitter -->|"uses"| node_page_tw_home
node_page_fb_login -->|"browser cmds"| node_nightwatch
node_page_fb_home -->|"browser cmds"| node_nightwatch
node_page_fb_user -->|"browser cmds"| node_nightwatch
node_page_fb_create -->|"browser cmds"| node_nightwatch
node_page_tw_home -->|"browser cmds"| node_nightwatch
node_nightwatch -->|"configured by"| node_chrome_conf
node_grunt -->|"orchestrates"| node_nightwatch
node_chrome_conf -->|"targets"| node_selenoid_compose
node_selenoid_compose -->|"loads"| node_browsers_json
node_report_script -->|"post-processes"| node_nightwatch
node_env_sample -.->|"feeds"| node_chrome_conf
node_eslint -.->|"supports"| node_grunt

click node_feature_facebook "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/features/facebook_pages_check.feature"
click node_feature_twitter "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/features/twitter_pages_check.feature"
click node_steps_facebook "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/facebook/facebook_login_steps.js"
click node_steps_twitter "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/twitter/twitter_steps.js"
click node_page_fb_login "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_login_page.js"
click node_page_fb_home "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_home_page.js"
click node_page_fb_user "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_user_page.js"
click node_page_fb_create "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_create_pages_page.js"
click node_page_tw_home "https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/twitter/twitter_home_page.js"
click node_grunt "https://github.com/7etrahedral/nightwatch-poc/blob/master/Gruntfile.js"
click node_chrome_conf "https://github.com/7etrahedral/nightwatch-poc/blob/master/docker-chrome-conf.js"
click node_selenoid_compose "https://github.com/7etrahedral/nightwatch-poc/blob/master/selenoid/docker-compose.yml"
click node_browsers_json "https://github.com/7etrahedral/nightwatch-poc/blob/master/selenoid/browsers.json"
click node_report_script "https://github.com/7etrahedral/nightwatch-poc/blob/master/reports/chrome/create-html-report-chrome.js"
click node_env_sample "https://github.com/7etrahedral/nightwatch-poc/blob/master/env.sample"
click node_eslint "https://github.com/7etrahedral/nightwatch-poc/blob/master/.eslintrc.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_feature_facebook,node_feature_twitter,node_env_sample,node_eslint toneBlue
class node_steps_facebook,node_steps_twitter toneAmber
class node_page_fb_login,node_page_fb_home,node_page_fb_user,node_page_fb_create,node_page_tw_home toneMint
class node_nightwatch,node_grunt,node_chrome_conf toneRose
class node_selenoid_compose,node_browsers_json toneIndigo
class node_report_script toneTeal
```

## Components

### BDD specs

Gherkin feature files that define test intent.

- [Facebook feature](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/features/facebook_pages_check.feature): gherkin spec · Facebook browser automation scenarios. · `tests/features/facebook_pages_check.feature`
- [Twitter feature](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/features/twitter_pages_check.feature): gherkin spec · Twitter browser automation scenarios. · `tests/features/twitter_pages_check.feature`

### Step glue

Step definitions that bind scenarios to browser actions.

- [Facebook steps](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/facebook/facebook_login_steps.js): bdd steps · Step definitions for Facebook scenarios. · `tests/step_definitions/facebook/facebook_login_steps.js`
- [Twitter steps](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/step_definitions/twitter/twitter_steps.js): bdd steps · Step definitions for Twitter scenarios. · `tests/step_definitions/twitter/twitter_steps.js`

### Page objects

Browser interaction abstractions used by steps.

- [Login page](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_login_page.js): page object · Facebook login interactions. · `tests/page-objects/facebook/facebook_login_page.js`
- [Home page](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_home_page.js): page object · Facebook home interactions. · `tests/page-objects/facebook/facebook_home_page.js`
- [User page](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_user_page.js): page object · Facebook user/profile interactions. · `tests/page-objects/facebook/facebook_user_page.js`
- [Create pages](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/facebook/facebook_create_pages_page.js): page object · Facebook page creation interactions. · `tests/page-objects/facebook/facebook_create_pages_page.js`
- [Twitter home](https://github.com/7etrahedral/nightwatch-poc/blob/master/tests/page-objects/twitter/twitter_home_page.js): page object · Twitter home interactions. · `tests/page-objects/twitter/twitter_home_page.js`

### Test runtime

Nightwatch execution and local test orchestration.

- **Nightwatch**: test runner · BDD-capable browser automation runtime.
- [Grunt tasks](https://github.com/7etrahedral/nightwatch-poc/blob/master/Gruntfile.js): task runner · Command orchestration and aliases for test workflows. · `Gruntfile.js`
- [Chrome config](https://github.com/7etrahedral/nightwatch-poc/blob/master/docker-chrome-conf.js): runner config · Nightwatch/Chrome execution settings. · `docker-chrome-conf.js`

### Browser infra

Dockerized Selenium/Chrome execution environment.

- [Compose stack](https://github.com/7etrahedral/nightwatch-poc/blob/master/selenoid/docker-compose.yml): docker compose · Starts the Selenium-compatible browser infrastructure. · `selenoid/docker-compose.yml`
- [Browsers config](https://github.com/7etrahedral/nightwatch-poc/blob/master/selenoid/browsers.json): browser catalog · Browser image/runtime definitions for the grid. · `selenoid/browsers.json`

### Reporting

Post-test report generation and artifacts.

- [HTML report](https://github.com/7etrahedral/nightwatch-poc/blob/master/reports/chrome/create-html-report-chrome.js): report generator · Creates the Chrome HTML test report. · `reports/chrome/create-html-report-chrome.js`

### Tooling

Developer workflow and lint/config support.

- [Env sample](https://github.com/7etrahedral/nightwatch-poc/blob/master/env.sample): env template · Template for runtime variables and credentials. · `env.sample`
- [ESLint](https://github.com/7etrahedral/nightwatch-poc/blob/master/.eslintrc.js): lint config · JavaScript linting rules. · `.eslintrc.js`

## Connections

- Facebook feature → Facebook steps: drives · Facebook scenarios are bound to step definitions.
- Twitter feature → Twitter steps: drives · Twitter scenarios are bound to step definitions.
- Facebook steps → Login page: uses · Facebook steps call into login interactions.
- Facebook steps → Home page: uses · Facebook steps call into home interactions.
- Facebook steps → User page: uses · Facebook steps call into user/profile interactions.
- Facebook steps → Create pages: uses · Facebook steps call into page creation interactions.
- Twitter steps → Twitter home: uses · Twitter steps call into home interactions.
- Login page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Home page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- User page → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Create pages → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Twitter home → Nightwatch: browser cmds · Page objects execute Nightwatch commands.
- Nightwatch → Chrome config: configured by · Runner settings define Chrome execution behavior.
- Grunt tasks → Nightwatch: orchestrates · Task runner can launch test workflows.
- Chrome config → Compose stack: targets · Runner configuration points at remote browser infrastructure.
- Compose stack → Browsers config: loads · Compose stack uses browser runtime definitions.
- HTML report → Nightwatch: post-processes · Report generation consumes test output.
- Env sample → Chrome config: feeds · Environment variables supply runtime configuration.
- ESLint → Grunt tasks: supports · Linting supports the JavaScript workflow.
