# bartoszluka/bdsm-compatibility architecture

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

- Interactive diagram: https://gitdiagram.com/bartoszluka/bdsm-compatibility
- Repository: https://github.com/bartoszluka/bdsm-compatibility

## Overview

##### Project type and purpose
- This is a single-page application (SPA) written in Elm, served as a static site via Netlify.
- Its purpose is to accept two pasted BDSM-test result strings, parse them, compute a compatibility score, and render the result in the browser.

##### Main components
a. User’s Browser / Client
- Loads index.html
- Runs the Elm runtime
b. Elm Application (Model-View-Update architecture)
- Main.elm – initializes the app, defines Model, Msg, View, Update
- BdsmTestResults.elm – encapsulates the core compatibility-scoring logic
- ParserExtra.elm – helper functions for parsing raw test data
c. Static Assets & Configuration
- index.html – host page bootstrapping Elm
- elm.json – Elm dependencies & configuration
- netlify.toml – Netlify build/deploy settings
- optimize.sh / live.ps1 – optional build‐optimization or local‐serve scripts
d. Test Suite
- tests/ScoringTests.elm – Elm unit tests for the compatibility logic
e. Deployment Pipeline (Netlify / CI)
- Netlify build step (elm make, optimize.sh)
- Continuous deploy on git push

##### Relationships & Data Flow
- Within Elm:
- View dispatches Msgs (e.g. Paste1Changed, Paste2Changed, CalculateCompatibility)
- Update handles Msgs → updates Model or calls BdsmTestResults.parseAndScore
- BdsmTestResults uses ParserExtra to process raw input → returns compatibility score
- Update stores score in Model → View re-renders result
- No external API calls – purely client-side computation
- Tests invoke BdsmTestResults.parseAndScore directly, verifying correctness

##### Architectural patterns & design principles
- Elm’s TEA (The Elm Architecture – unidirectional data flow, immutable Model)
- Modular separation: parsing logic (ParserExtra), scoring logic (BdsmTestResults), UI orchestration (Main)
- Static hosting / CI-driven deploy (Netlify)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["User's Browser / Client"]:::client
    Browser -->|"loads index.html"| Index

    %% Static Assets & Config
    subgraph "Static Assets & Configuration"
        direction TB
        Index["index.html"]:::config
        ElmJson["elm.json"]:::config
        NetlifyToml["netlify.toml"]:::config
        Optimize["optimize.sh"]:::config
        LivePS1["live.ps1"]:::config
    end

    Index -->|"bootstraps Elm runtime"| Main

    %% Elm Application
    subgraph "Elm Application (Model-View-Update)"
        direction TB
        Main["Main.elm\n(Model-View-Update)"]:::frontend
        Results["BdsmTestResults.elm\n(Scoring Logic)"]:::frontend
        Parser["ParserExtra.elm\n(Parsing Helpers)"]:::frontend
    end

    Main -->|"dispatches Msgs"| Main
    Main -->|"calls parseAndScore"| Results
    Results -->|"uses parsing helpers"| Parser
    Parser -->|"returns processed data"| Results
    Results -->|"returns score to"| Main
    Main -->|"updates Model & re-renders"| Main

    %% Test Suite
    subgraph "Test Suite"
        direction TB
        TestSuite["ScoringTests.elm"]:::test
    end
    TestSuite -->|"tests parseAndScore"| Results

    %% Deployment Pipeline
    subgraph "Deployment Pipeline"
        direction TB
        Repo[(Git Repository)]:::deploy
        NetlifyCI["Netlify CI/Build"]:::deploy
        LiveSite[(Live Static Site)]:::deploy
    end

    Repo -->|"on git push"| NetlifyCI
    NetlifyCI -->|"runs elm make & optimize.sh"| LiveSite
    LiveSite -->|"serves to"| Browser

    %% Click Events
    click Index "https://github.com/bartoszluka/bdsm-compatibility/blob/main/index.html"
    click Main "https://github.com/bartoszluka/bdsm-compatibility/blob/main/src/Main.elm"
    click Results "https://github.com/bartoszluka/bdsm-compatibility/blob/main/src/BdsmTestResults.elm"
    click Parser "https://github.com/bartoszluka/bdsm-compatibility/blob/main/src/ParserExtra.elm"
    click ElmJson "https://github.com/bartoszluka/bdsm-compatibility/blob/main/elm.json"
    click NetlifyToml "https://github.com/bartoszluka/bdsm-compatibility/blob/main/netlify.toml"
    click Optimize "https://github.com/bartoszluka/bdsm-compatibility/blob/main/optimize.sh"
    click LivePS1 "https://github.com/bartoszluka/bdsm-compatibility/blob/main/live.ps1"
    click TestSuite "https://github.com/bartoszluka/bdsm-compatibility/blob/main/tests/ScoringTests.elm"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6;
    classDef config fill:#E6FFED,stroke:#28a745,color:#28a745;
    classDef deploy fill:#FFF5B1,stroke:#DBAB09,color:#DBAB09;
    classDef test fill:#FFE4E1,stroke:#D73A49,color:#D73A49;
    classDef client fill:#F0F8FF,stroke:#005CC5,color:#005CC5;
```
