# mfaisalkhatri/selenium-ai-test-generator architecture

> Architecture diagram of the GitHub repository mfaisalkhatri/selenium-ai-test-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mfaisalkhatri/selenium-ai-test-generator
- Repository: https://github.com/mfaisalkhatri/selenium-ai-test-generator

## Overview

This repository is an AI-powered Selenium Java test generator. The main workflow checks the selected LLM, reads a plain-English test case, builds a POM/TestNG-oriented prompt, generates code through OpenAI or Ollama, and writes parsed files to a timestamped output directory. README documents generated page objects, a test class, testng.xml, and README; the checked-in examples show search and registration scenarios. Edges reflect the shown Python calls or README workflow; generated artifacts are examples, not runtime modules.

Main entry points: [`main.py`](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/main.py) (Generation runner), [`tools.py`](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py) (LLM connectivity check), [`config.py`](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/config.py) (Application configuration), [`test_cases/input/sample_test_case.txt`](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/test_cases/input/sample_test_case.txt) (Test case input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Generation workflow"]
  node_input["Test case input"]
  node_orchestrator["Generation runner<br/>[main.py]"]
  node_connection["LLM connectivity check<br/>[tools.py]"]
  node_loader["Test case loader<br/>[tools.py]"]
  node_prompt["Prompt builder<br/>[tools.py]"]
  node_generator["Provider dispatch<br/>[tools.py]"]
  node_writer["File splitter and writer<br/>[tools.py]"]
  node_outputdir["Timestamped output"]
  node_artifacts["Java POM and TestNG artifacts"]
end

subgraph group_providers["LLM providers"]
  node_openai{{"OpenAI service"}}
  node_ollama{{"Ollama service"}}
end

subgraph group_settings["Configuration and logging"]
  node_config["Application configuration<br/>[config.py]"]
  node_logger["Application logger<br/>[logger.py]"]
end

node_user(("Test author"))

node_user -->|"writes case"| node_input
node_user -->|"starts generator"| node_orchestrator
node_orchestrator -->|"checks provider"| node_connection
node_orchestrator -->|"loads case"| node_loader
node_loader -->|"reads"| node_input
node_orchestrator -->|"requests generation"| node_prompt
node_prompt -->|"builds prompt"| node_generator
node_generator -->|"sends prompt"| node_openai
node_generator -->|"sends prompt"| node_ollama
node_orchestrator -->|"creates directory"| node_outputdir
node_orchestrator -->|"saves response"| node_writer
node_writer -->|"writes files"| node_outputdir
node_writer -->|"creates artifacts"| node_artifacts
node_connection -->|"checks models"| node_openai
node_connection -->|"checks endpoint"| node_ollama
node_orchestrator -->|"reads file paths"| node_config
node_connection -->|"reads provider settings"| node_config
node_generator -->|"reads model settings"| node_config
node_orchestrator -->|"logs workflow"| node_logger
node_connection -->|"logs checks"| node_logger

click node_input "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/test_cases/input/sample_test_case.txt"
click node_orchestrator "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/main.py"
click node_connection "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py"
click node_loader "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py"
click node_prompt "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py"
click node_generator "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py"
click node_writer "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py"
click node_outputdir "https://github.com/mfaisalkhatri/selenium-ai-test-generator/tree/main/test_cases/output"
click node_artifacts "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/test_cases/output/2026-08-13_18-46-45/SearchProductTest.java"
click node_config "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/config.py"
click node_logger "https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/logger.py"

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_input,node_orchestrator,node_connection,node_loader,node_prompt,node_generator,node_writer,node_outputdir,node_artifacts toneBlue
class node_openai,node_ollama toneAmber
class node_config,node_logger toneMint
class node_user toneIndigo
```

## Components

### Generation workflow

- [Test case input](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/test_cases/input/sample_test_case.txt): `test_cases/input/sample_test_case.txt`
- [Generation runner](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/main.py): `main.py`
- [LLM connectivity check](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py): `tools.py`
- [Test case loader](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py): `tools.py`
- [Prompt builder](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py): `tools.py`
- [Provider dispatch](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py): `tools.py`
- [File splitter and writer](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/tools.py): `tools.py`
- [Timestamped output](https://github.com/mfaisalkhatri/selenium-ai-test-generator/tree/main/test_cases/output): `test_cases/output`
- [Java POM and TestNG artifacts](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/test_cases/output/2026-08-13_18-46-45/SearchProductTest.java): `test_cases/output/2026-08-13_18-46-45/SearchProductTest.java`

### LLM providers

- **OpenAI service**
- **Ollama service**

### Configuration and logging

- [Application configuration](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/config.py): `config.py`
- [Application logger](https://github.com/mfaisalkhatri/selenium-ai-test-generator/blob/main/logger.py): `logger.py`

### Other components

- **Test author**

## Connections

- Test author → Test case input: writes case (evidence: `README.md`)
- Test author → Generation runner: starts generator (evidence: `README.md`)
- Generation runner → LLM connectivity check: checks provider (evidence: `main.py`)
- Generation runner → Test case loader: loads case (evidence: `main.py`)
- Test case loader → Test case input: reads (evidence: `tools.py`)
- Generation runner → Prompt builder: requests generation (evidence: `main.py`)
- Prompt builder → Provider dispatch: builds prompt (evidence: `tools.py`)
- Provider dispatch → OpenAI service: sends prompt (evidence: `tools.py`)
- Provider dispatch → Ollama service: sends prompt (evidence: `tools.py`)
- Generation runner → Timestamped output: creates directory (evidence: `main.py`)
- Generation runner → File splitter and writer: saves response (evidence: `main.py`)
- File splitter and writer → Timestamped output: writes files (evidence: `tools.py`)
- File splitter and writer → Java POM and TestNG artifacts: creates artifacts (evidence: `README.md`)
- LLM connectivity check → OpenAI service: checks models (evidence: `tools.py`)
- LLM connectivity check → Ollama service: checks endpoint (evidence: `tools.py`)
- Generation runner → Application configuration: reads file paths (evidence: `main.py`)
- LLM connectivity check → Application configuration: reads provider settings (evidence: `tools.py`)
- Provider dispatch → Application configuration: reads model settings (evidence: `tools.py`)
- Generation runner → Application logger: logs workflow (evidence: `main.py`)
- LLM connectivity check → Application logger: logs checks (evidence: `tools.py`)
