# stuck3y/twinsie architecture

> Architecture diagram of the GitHub repository stuck3y/twinsie, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/stuck3y/twinsie
- Repository: https://github.com/stuck3y/twinsie

## Overview

##### Main Components

a. Client Layer:
- HTTP Clients (cURL, Postman)
- POST request to /twinsie endpoint
- JSON payload structure

b. Web Service Layer:
- Flask Web Server (app.py)
- Port 5000 exposure
- REST API endpoint (/twinsie)

c. Core Processing Layer (twinsie.py):
- Text Similarity Engine with three distinct methods:
1. Common Words Analysis (Jaccard-like)
2. Fuzzy Matching System
3. Word Position Analysis

##### Flow Representation

- Use rectangles for main service components
→ Client to Web Service (JSON POST request)
→ Web Service to Similarity Engine
→ Similarity Engine to Response
- Blue: Client Layer
- Green: Web Service Layer
- Yellow: Processing Layer

##### Detailed Component Breakdown

Create sub-sections within the Processing Layer showing:
a. Text Preprocessing
b. Three Analysis Methods:
- Common Words Calculator
- Fuzzy Matcher
- Analyzer
c. Score Aggregator (combines results into 0-1 score)

##### Infrastructure Elements

Docker-related components:
- Docker Container boundary
- Port mapping (5000:5000)
- Docker Compose orchestration

##### Technical Details

Specifications:
- Python 3.5/3.6 runtime
- Flask framework
- REST API specifications
- Docker deployment options

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#a8d1f0,stroke:#000
    classDef webservice fill:#90EE90,stroke:#000
    classDef processing fill:#FFE5B4,stroke:#000
    classDef docker fill:#B19CD9,stroke:#000
    classDef infrastructure fill:#FFB6C1,stroke:#000

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        Client["HTTP Clients\n(cURL, Postman)"]:::client
        Payload["JSON Payload\n{text1, text2}"]:::client
    end

    %% Web Service Layer
    subgraph WebService["Web Service Layer"]
        Flask["Flask Web Server\nPort 5000"]:::webservice
        API["/twinsie Endpoint"]:::webservice
    end

    %% Processing Layer
    subgraph ProcessingLayer["Core Processing Layer"]
        TextPrep["Text Preprocessing"]:::processing
        
        subgraph AnalysisMethods["Analysis Methods"]
            CommonWords["Common Words\nAnalysis"]:::processing
            FuzzyMatch["Fuzzy Matching\nSystem"]:::processing
            PositionAnalysis["Word Position\nAnalysis"]:::processing
        end
        
        Aggregator["Score Aggregator\n(0-1 Score)"]:::processing
    end

    %% Infrastructure Layer
    subgraph Infrastructure["Infrastructure"]
        Docker["Docker Container"]:::docker
        DockerCompose["Docker Compose"]:::docker
        Dependencies["Python Dependencies"]:::infrastructure
    end

    %% Connections
    Client --> Payload
    Payload --> API
    API --> Flask
    Flask --> TextPrep
    TextPrep --> CommonWords
    TextPrep --> FuzzyMatch
    TextPrep --> PositionAnalysis
    CommonWords --> Aggregator
    FuzzyMatch --> Aggregator
    PositionAnalysis --> Aggregator
    Aggregator --> Flask
    
    %% Component Mappings
    click Flask "https://github.com/stuck3y/twinsie/blob/main/app.py"
    click ProcessingLayer "https://github.com/stuck3y/twinsie/blob/main/twinsie.py"
    click Docker "https://github.com/stuck3y/twinsie/tree/main/Dockerfile"
    click DockerCompose "https://github.com/stuck3y/twinsie/blob/main/docker-compose.yml"
    click Dependencies "https://github.com/stuck3y/twinsie/blob/main/requirements.txt"

    %% Legend
    subgraph Legend["Legend"]
        L1["Client Components"]:::client
        L2["Web Service Components"]:::webservice
        L3["Processing Components"]:::processing
        L4["Docker Components"]:::docker
        L5["Infrastructure Components"]:::infrastructure
    end
```
