# rnks2003/exp_dfa architecture

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

- Interactive diagram: https://gitdiagram.com/rnks2003/exp_dfa
- Repository: https://github.com/rnks2003/exp_dfa

## Overview

##### File Structure
- Top-level files:
- main.py – the Streamlit app entry point (UI + business logic)
- requirements.txt – lists Python dependencies
- .streamlit/config.toml – optional Streamlit deployment/config settings
- readme.md, .gitignore – docs and version control
- No separate “frontend” and “backend” folders: Streamlit handles UI and server logic in a single process.

##### Key Components
a. Streamlit UI Layer
- Renders controls: state-creator widgets, symbol inputs, buttons
- Displays graphs and tables in the user’s browser
b. DFA Builder & Validation Engine
- In-memory model of states, alphabet, transition functions
- Validates well-formedness (one transition per symbol, start/accept marked)
c. Simulation Engine
- Performs step-by-step or full-string DFA traversal
- Implements wildcard logic for `?` and `*`
d. Visualization Subsystem
- NetworkX builds the underlying graph structure
e. Data Presentation Layer
- Pandas DataFrame for transition tables
- Streamlit’s UI components for tables
f. Deployment/Runtime Environment
- Local Python environment or Streamlit Cloud
- Dependencies managed via requirements.txt

##### Relationships and Data Flow
- User (Browser) interacts with Streamlit UI →
- Streamlit server (main.py) invokes:
- DFA Builder → Validation → Simulation →
- Visualization (NetworkX + Matplotlib) →
- DataFrame rendering (Pandas) →
- Results are streamed back to the browser UI
- Configuration (.streamlit/config.toml) influences app settings (theme, port)

##### Architectural Patterns & Principles
- Component layering: UI, business logic (builder & simulator), visualization, and data presentation
- Single-process, event-driven architecture inherent to Streamlit
- Stateless between runs, state held in Streamlit’s session state
- Modular code separation: functions or classes in main.py for each subsystem

## Diagram (Mermaid)

```mermaid
graph TB
    %% Nodes
    Browser["User Browser"]:::ui
    StreamlitUI["Streamlit UI Layer"]:::ui
    DFABuilder["DFA Builder & Validator"]:::logic
    Simulator["Simulation Engine"]:::logic
    Visualizer["Graph Visualizer\n(NetworkX + Matplotlib)"]:::viz
    DataPresenter["Data Presentation Layer\n(Pandas & Streamlit Tables)"]:::viz
    ConfigLoader["Config Loader\n(.streamlit/config.toml)"]:::ext
    Dependencies["Dependency Management\n(requirements.txt)"]:::ext
    Documentation["Project Documentation\n(readme.md)"]:::ext
    VCS["Version Control Exclusions\n(.gitignore)"]:::ext

    %% Flow
    Browser -->|"user events"| StreamlitUI
    StreamlitUI -->|"state definitions"| DFABuilder
    DFABuilder -->|"validated DFA"| Simulator
    Simulator -->|"simulation result"| Visualizer
    Visualizer -->|"graph object"| DataPresenter
    DataPresenter -->|"table data"| StreamlitUI
    ConfigLoader -->|"app settings"| StreamlitUI

    %% Click events
    click StreamlitUI "https://github.com/rnks2003/exp_dfa/blob/main/main.py"
    click DFABuilder "https://github.com/rnks2003/exp_dfa/blob/main/main.py"
    click Simulator "https://github.com/rnks2003/exp_dfa/blob/main/main.py"
    click Visualizer "https://github.com/rnks2003/exp_dfa/blob/main/main.py"
    click DataPresenter "https://github.com/rnks2003/exp_dfa/blob/main/main.py"
    click ConfigLoader "https://github.com/rnks2003/exp_dfa/blob/main/.streamlit/config.toml"
    click Dependencies "https://github.com/rnks2003/exp_dfa/blob/main/requirements.txt"
    click Documentation "https://github.com/rnks2003/exp_dfa/blob/main/readme.md"
    click VCS "https://github.com/rnks2003/exp_dfa/blob/main/.gitignore"

    %% Styles
    classDef ui fill:#D0E1FF,stroke:#333,stroke-width:1px
    classDef logic fill:#DFFFD0,stroke:#333,stroke-width:1px
    classDef viz fill:#FFE1B0,stroke:#333,stroke-width:1px
    classDef ext fill:#E0E0E0,stroke:#333,stroke-width:1px
```
