# bowen7/regex-vis architecture

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

- Interactive diagram: https://gitdiagram.com/bowen7/regex-vis
- Repository: https://github.com/bowen7/regex-vis

## Overview

##### Project Type and Purpose
- Regex-Vis is a full-stack (frontend-heavy) application that focuses on regex visualization and interactive editing.
- Its primary functionality is split between rendering the UI (inputs, displays, interactive graphs) and processing regex through parsing modules, editor features, and regex AST (abstract syntax tree) generation.

##### Analyzing the File Structure
- Top-level files like package.json, index.html, and Docker-related files (Dockerfile, docker-compose.yml) indicate standard web application deployment and development.
- The main source code resides in the src directory, which is further organized into subdirectories:
a. components: Contains reusable UI components (buttons, inputs, dialogs, theme provider, etc.) used to build the user interface.
b. modules: Houses feature-specific modules such as:
- "editor": The interactive regex editor interface with features like tabs for editing, legends, and content representations.
- "graph": For generating and displaying the regex’s visual graphs and AST nodes.
- "home", "playground", and "samples": Likely responsible for providing different views or testing areas.
c. parser: Contains modules responsible for parsing regex. This includes tokenization (lexer), AST generation, processing modifiers (like look-around, quantifiers, etc.), and visiting nodes.
d. atom: Contains smaller units (atoms) for handling regex operations like insertion, removal, or grouping. Tests in this directory further clarify that these modules represent granular operations that underpin the editor and parser functionalities.
e. utils and other supporting directories: They provide shared hooks, utility functions, and constants that facilitate the overall app behavior.

##### Diagramming the Architecture
a. Main Components:
- User Interface (Presentation Layer):
- Components (all in src/components) handling UI elements, state management, language selection, themeing, and navigation (e.g., header, language-select, logo, mode-toggle).
- Editor & Interaction Module:
- Regex Parser & Processing:
- The parser component (src/parser) processes the regular expression patterns. Its submodules tokenize input, build ASTs, and incorporate modifiers for various regex features.
- Graphical Visualization:
- Modules in src/modules/graph construct visual representations (e.g., AST graphs) using nodes, connectors, and custom components to render the visualized regex.
- Testing Framework & Utilities:
- The tests directory indicates a robust set of tests ensuring correct behavior for UI components, parser modules, and atom functionalities.

b. Relationships and Interactions:
- The UI components capture user input and send regex patterns to the editor module.
- Editor components interact with the parser to convert raw regex strings into a structured internal representation (AST).
- The graph module consumes the parsed regex data to generate a live visual graph.
- Shared utilities and hooks (src/utils) support state management, focus, debouncing, and other interactive behaviors across components.

c. Architectural Patterns:
- Separation of Concerns – the project is modularized into clear layers (UI, editor, parser, graph), which keeps concerns separated.
- Component-based Architecture – mirroring typical React patterns for reusable UI and state-driven views.
- Clear testing boundaries – with dedicated __tests__ directories ensuring each module (atom and parser) performs as expected.

##### Including Relevant Technologies and Libraries
- Frontend is built using React and TypeScript.
- Testing frameworks are integrated (as per the tests directory).
- Styles are managed with Tailwind CSS (tailwind.config.ts and postcss.config.js).
- ESLint, Prettier, and Vite provide a modern development environment.
- Dockerfiles and deployment configurations (vercel.json) hint at containerized builds and cloud deployment practices.

##### Final Advice
- Be very detailed – capture every layer and significant module of the project.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User Interface (Presentation Layer)"]:::ui
    end

    %% Editor and Visualization Layer
    subgraph "Editor & Visualization"
        Editor["Editor Module (Interactive Regex Editing)"]:::logicEditor
        Graph["Graphical Visualization (AST & Regex Graph Rendering)"]:::logicGraph
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        Parser["Regex Parser & Processing"]:::parser
        Atom["Atom Operations (Granular Regex Functions)"]:::atom
        Utils["Utilities & Shared Hooks"]:::utils
        Constants["Constants & Configurations"]:::constants
    end

    %% Additional Components
    Testing["Testing Framework"]:::testing
    Deploy["Project Deployment & Configuration Files"]:::deploy

    %% Relationships
    UI -->|"sendsRegex"| Editor
    Editor -->|"parsesRegex"| Parser
    Parser -->|"buildsAST"| Graph
    Parser -->|"invokesAtom"| Atom

    Utils -->|"supportsUI"| UI
    Utils -->|"supportsEditor"| Editor

    Constants -->|"configuresEditor"| Editor
    Constants -->|"configuresParser"| Parser

    Testing ---|"validatesUI"| UI
    Testing ---|"validatesParser"| Parser
    Testing ---|"validatesAtom"| Atom

    Deploy -.->|"deploysUI"| UI
    Deploy -.->|"deploysEditor"| Editor
    Deploy -.->|"deploysParser"| Parser
    Deploy -.->|"deploysGraph"| Graph

    %% Click Events
    click UI "https://github.com/bowen7/regex-vis/tree/main/src/components"
    click Editor "https://github.com/bowen7/regex-vis/tree/main/src/modules/editor"
    click Graph "https://github.com/bowen7/regex-vis/tree/main/src/modules/graph"
    click Parser "https://github.com/bowen7/regex-vis/tree/main/src/parser"
    click Atom "https://github.com/bowen7/regex-vis/tree/main/src/atom"
    click Utils "https://github.com/bowen7/regex-vis/tree/main/src/utils"
    click Constants "https://github.com/bowen7/regex-vis/tree/main/src/constants"
    click Testing "https://github.com/bowen7/regex-vis/tree/main/tests"
    click Deploy "https://github.com/bowen7/regex-vis/tree/main/Dockerfile"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logicEditor fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef logicGraph fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef parser fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef atom fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef utils fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef constants fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef testing fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef deploy fill:#D6EAF8,stroke:#2980B9,stroke-width:2px;
```
