# erenunalll/semantic-anomaly-grouping architecture

> Architecture diagram of the GitHub repository erenunalll/semantic-anomaly-grouping, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erenunalll/semantic-anomaly-grouping
- Repository: https://github.com/erenunalll/semantic-anomaly-grouping

## Overview

This repository provides a FastAPI service for finding semantically similar log-like records and grouping related records. Requests are sanitized and embedded by an external model server; vector search selects candidate pairs, which are returned directly or further grouped with canonical-record selection and chain-link mitigation. The graph follows the calls visible in the sampled API and core modules; documentation filenames suggest additional context, but their contents were not provided.

Main entry points: [`semantic_match.py`](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py) (Match Orchestration), [`main.py`](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/main.py) (FastAPI Endpoints), [`graph_grouping.py`](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py) (Cluster Orchestration), [`sanitize.py`](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/sanitize.py) (Text Sanitization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api["FastAPI Endpoints<br/>[main.py]"]
end

subgraph group_matching["Semantic Matching"]
  node_input["Request Preparation<br/>[semantic_match.py]"]
  node_sanitize["Text Sanitization<br/>[sanitize.py]"]
  node_match["Match Orchestration<br/>[semantic_match.py]"]
  node_vectors["Vector Search<br/>[semantic_match.py]"]
  node_pairs["Pair Selection<br/>[semantic_match.py]"]
  node_similarity_result["Similarity Response<br/>[semantic_match.py]"]
end

subgraph group_grouping["Record Grouping"]
  node_cluster["Cluster Orchestration<br/>[graph_grouping.py]"]
  node_components["Connected Groups<br/>[graph_grouping.py]"]
  node_mitigation["Chain Mitigation<br/>[graph_grouping.py]"]
  node_cluster_result["Cluster Response<br/>[graph_grouping.py]"]
end

node_client(("API Client"))
node_model["Embedding Server"]

node_client -->|"submits request"| node_api
node_api -->|"prepares input"| node_input
node_input -->|"sanitizes text"| node_sanitize
node_api -->|"runs similarity"| node_match
node_api -->|"runs clustering"| node_cluster
node_match -->|"requests embeddings"| node_model
node_match -->|"builds and searches"| node_vectors
node_match -->|"selects candidates"| node_pairs
node_match -->|"formats pairs"| node_similarity_result
node_cluster -->|"computes pairs"| node_match
node_cluster -->|"forms groups"| node_components
node_cluster -->|"refines groups"| node_mitigation
node_mitigation -->|"provides final groups"| node_cluster_result

click node_api "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/main.py"
click node_input "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py"
click node_sanitize "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/sanitize.py"
click node_match "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py"
click node_vectors "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py"
click node_pairs "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py"
click node_similarity_result "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py"
click node_cluster "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py"
click node_components "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py"
click node_mitigation "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py"
click node_cluster_result "https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_api,node_client toneBlue
class node_input,node_sanitize,node_match,node_vectors,node_pairs,node_similarity_result toneAmber
class node_cluster,node_components,node_mitigation,node_cluster_result,node_model toneMint
```

## Components

### API

- [FastAPI Endpoints](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/main.py): `main.py`

### Semantic Matching

- [Request Preparation](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py): `semantic_match.py`
- [Text Sanitization](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/sanitize.py): `sanitize.py`
- [Match Orchestration](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py): `semantic_match.py`
- [Vector Search](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py): `semantic_match.py`
- [Pair Selection](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py): `semantic_match.py`
- [Similarity Response](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/semantic_match.py): `semantic_match.py`

### Record Grouping

- [Cluster Orchestration](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py): `graph_grouping.py`
- [Connected Groups](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py): `graph_grouping.py`
- [Chain Mitigation](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py): `graph_grouping.py`
- [Cluster Response](https://github.com/erenunalll/semantic-anomaly-grouping/blob/main/graph_grouping.py): `graph_grouping.py`

### Other components

- **API Client**
- **Embedding Server**

## Connections

- API Client → FastAPI Endpoints: submits request (evidence: `main.py`)
- FastAPI Endpoints → Request Preparation: prepares input (evidence: `main.py`)
- Request Preparation → Text Sanitization: sanitizes text (evidence: `semantic_match.py`)
- FastAPI Endpoints → Match Orchestration: runs similarity (evidence: `main.py`)
- FastAPI Endpoints → Cluster Orchestration: runs clustering (evidence: `main.py`)
- Match Orchestration → Embedding Server: requests embeddings (evidence: `semantic_match.py`)
- Match Orchestration → Vector Search: builds and searches (evidence: `semantic_match.py`)
- Match Orchestration → Pair Selection: selects candidates (evidence: `semantic_match.py`)
- Match Orchestration → Similarity Response: formats pairs (evidence: `semantic_match.py`)
- Cluster Orchestration → Match Orchestration: computes pairs (evidence: `graph_grouping.py`)
- Cluster Orchestration → Connected Groups: forms groups (evidence: `graph_grouping.py`)
- Cluster Orchestration → Chain Mitigation: refines groups (evidence: `graph_grouping.py`)
- Chain Mitigation → Cluster Response: provides final groups (evidence: `graph_grouping.py`)
