# vonguyenleduy/stat-dsm architecture

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

- Interactive diagram: https://gitdiagram.com/vonguyenleduy/stat-dsm
- Repository: https://github.com/vonguyenleduy/stat-dsm

## Overview

Stat-DSM is a command-line research program for finding statistically discriminative sub-trajectories in labeled hurricane trajectories. Its workflow uses PostgreSQL trajectory data, searches for spatial neighbors and candidate subsequences, evaluates candidates against permuted labels, and reports an adjusted significance level. Most behavior is concentrated in one Python file, so the graph separates its domain stages without implying they are independent services. The excerpts show database access and parts of the mining/statistical logic; some orchestration links are documented only at a high level.

Main entry points: [`stat_dsm.py`](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py) (Command-line runner), [`max_euclidean.py`](https://github.com/vonguyenleduy/stat-dsm/blob/main/max_euclidean.py) (Top-k distance)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Sub-trajectory analysis"]
  node_runner["Command-line runner<br/>[stat_dsm.py]"]
  node_db_access["Trajectory data access<br/>[stat_dsm.py]"]
  node_candidate_search["Candidate mining<br/>[stat_dsm.py]"]
  node_neighbor_search["Neighbor expansion<br/>[stat_dsm.py]"]
  node_permutation_test["Permutation testing<br/>[stat_dsm.py]"]
  node_significance["Adjusted significance<br/>[stat_dsm.py]"]
end

subgraph group_support["Distance calculation"]
  node_distance["Top-k distance<br/>[max_euclidean.py]"]
end

node_user(("Researcher"))
node_postgres[("PostgreSQL database")]

node_user -->|"runs program"| node_runner
node_runner -.->|"loads data"| node_db_access
node_db_access -->|"queries trajectories"| node_postgres
node_candidate_search -->|"reads trajectories"| node_db_access
node_candidate_search -->|"expands candidates"| node_neighbor_search
node_neighbor_search -.->|"measures proximity"| node_distance
node_candidate_search -->|"tests candidates"| node_permutation_test
node_runner -->|"prepares label permutations"| node_permutation_test
node_permutation_test -->|"updates threshold"| node_significance
node_runner -.->|"reports result"| node_significance

click node_runner "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_db_access "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_candidate_search "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_neighbor_search "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_permutation_test "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_significance "https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py"
click node_distance "https://github.com/vonguyenleduy/stat-dsm/blob/main/max_euclidean.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_runner,node_db_access,node_candidate_search,node_neighbor_search,node_permutation_test,node_significance toneBlue
class node_distance,node_postgres toneAmber
class node_user toneIndigo
```

## Components

### Sub-trajectory analysis

- [Command-line runner](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`
- [Trajectory data access](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`
- [Candidate mining](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`
- [Neighbor expansion](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`
- [Permutation testing](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`
- [Adjusted significance](https://github.com/vonguyenleduy/stat-dsm/blob/main/stat_dsm.py): `stat_dsm.py`

### Distance calculation

- [Top-k distance](https://github.com/vonguyenleduy/stat-dsm/blob/main/max_euclidean.py): `max_euclidean.py`

### Other components

- **Researcher**
- **PostgreSQL database**

## Connections

- Researcher → Command-line runner: runs program (evidence: `README.md`)
- Command-line runner → Trajectory data access: loads data (evidence: `stat_dsm.py`)
- Trajectory data access → PostgreSQL database: queries trajectories (evidence: `stat_dsm.py`)
- Candidate mining → Trajectory data access: reads trajectories (evidence: `stat_dsm.py`)
- Candidate mining → Neighbor expansion: expands candidates (evidence: `stat_dsm.py`)
- Neighbor expansion → Top-k distance: measures proximity (evidence: `stat_dsm.py`)
- Candidate mining → Permutation testing: tests candidates (evidence: `stat_dsm.py`)
- Command-line runner → Permutation testing: prepares label permutations (evidence: `stat_dsm.py`)
- Permutation testing → Adjusted significance: updates threshold (evidence: `stat_dsm.py`)
- Command-line runner → Adjusted significance: reports result (evidence: `README.md`)
