# santhoshtr/sfst architecture

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

- Interactive diagram: https://gitdiagram.com/santhoshtr/sfst
- Repository: https://github.com/santhoshtr/sfst

## Overview

##### Project Type & Purpose
- It is an open-source tool focused on finite state transducers for morphological analysis.
- Its purpose is to compile FSTs from source specifications (via scanner and parser generators like Flex and Bison) and to provide both command-line utilities and Python bindings for further integration.
- The README highlights the use of SFST in morphological analysis (with examples in the “data” folder such as SMOR, XMOR, and easy) and explains how to compile and install the tools.

##### Analyzing the File Structure
- Top-Level Components:
- /src: Contains the core C++ source code that implements the transducer logic.
- Files like fst-compiler.yy, default-scanner.ll, fst-infl variants, and others indicate various stages in the FST workflow (parsing, scanning, transforming, generating outputs, etc.).
- /data: Includes example transducer data (SMOR, XMOR, easy) which serve as both demonstrations and starting points for custom morphological analyzers.
- /doc: Contains manuals and tutorials (SFST-Manual.pdf, SFST-Tutorial.pdf) that detail usage and internal workings.
- /python: Contains the Python interface (using pybind11) with its own CMakeLists and tests. This bridges the C++ core with Python for easier integration.
- Build & CI Configurations: Files such as CMakeLists.txt at various levels, .github/workflows scripts, and setup.py indicate an emphasis on cross-platform builds, CI, and installation automation.
- Patterns:
- A clear separation between the core (C/C++ logic in src), high-level examples and data (data folder), a Python integration layer (python), and documentation (doc).
- Use of CMake as the build system, complemented by CI for automated building and testing.

##### Essential Elements
- Core libraries/executables (src)
- Integration layers (python)
- External dependencies and tooling (Flex, Bison, CI systems)
- Documentation and user guidance (doc & man pages)

- How the core FST engine (and its internal components) interacts with data inputs and compiles into command-line utilities.
- The inclusion of a Python module that wraps around these functionalities.
- The peripheral but crucial roles that build, CI automation, and documentation play in the overall project.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Core Components"
        src["Core FST Engine"]:::core
        utilities["Command-Line Utilities"]:::cmd
        py["Python Bindings"]:::python
    end

    dataConf["Data & Configuration"]:::data
    buildci["Build & CI Infrastructure"]:::ci
    doc["Documentation & Manpages"]:::doc
    dep_flex["Flex"]:::external
    dep_bison["Bison"]:::external

    dep_flex -->|"feeds"| src
    dep_bison -->|"feeds"| src
    dataConf -->|"inputTo"| src
    src -->|"generates"| utilities
    utilities -->|"exposedVia"| py
    buildci -->|"orchestrates"| src
    buildci -->|"orchestrates"| py
    buildci -->|"supports"| doc
    doc -->|"guides"| src
    doc -->|"guides"| py
    doc -->|"documents"| dataConf

    click src "https://github.com/santhoshtr/sfst/tree/master/src"
    click dataConf "https://github.com/santhoshtr/sfst/tree/master/data"
    click py "https://github.com/santhoshtr/sfst/tree/master/python"
    click doc "https://github.com/santhoshtr/sfst/tree/master/doc"
    click buildci "https://github.com/santhoshtr/sfst/blob/master/CMakeLists.txt"

    classDef core fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef data fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef python fill:#cce5ff,stroke:#003399,stroke-width:2px;
    classDef cmd fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef ci fill:#ffe6cc,stroke:#ff9900,stroke-width:2px;
    classDef external fill:#ccffdd,stroke:#006600,stroke-width:2px;
    classDef doc fill:#e6ccff,stroke:#660099,stroke-width:2px;
```
