# pramodbasavarajmenasi/siftwise architecture

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

- Interactive diagram: https://gitdiagram.com/pramodbasavarajmenasi/siftwise
- Repository: https://github.com/pramodbasavarajmenasi/siftwise

## Overview

siftwise is a self-hosted test-impact service for CI: it records JUnit results and changed files, builds test history, then selects tests affected by a proposed change and returns commands with reasons. CI uploads flow through parsing and ingestion into Postgres; rollups update derived history. A developer or GitHub Action supplies a diff, while local Go/Python analysis and server-side history selection produce the test plan. The README documents the main workflow and action behavior; some route and domain connections are based on the cited excerpts or SOURCE INDEX, so unsampled internals are not expanded.

Main entry points: [`src/siftwise/cli/main.py`](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/main.py) (CLI commands), [`src/siftwise/api/routes/runs.py`](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/runs.py) (Run ingestion API), [`src/siftwise/api/main.py`](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/main.py) (API application), [`src/siftwise/api/routes/select.py`](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/select.py) (Selection API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["CLI and CI clients"]
  node_cli["CLI commands<br/>[main.py]"]
  node_ghaction["GitHub Actions glue<br/>[gha.py]"]
  node_pygraph["Python import graph<br/>[pygraph.py]"]
  node_gograph["Go package graph<br/>[gograph.py]"]
  node_repoconfig["Repo configuration<br/>[repoconfig.py]"]
end

subgraph group_api["HTTP API"]
  node_apiapp["API application<br/>[main.py]"]
  node_runroute["Run ingestion API<br/>[runs.py]"]
  node_selectroute["Selection API<br/>[select.py]"]
  node_historyroute["History API<br/>[history.py]"]
  node_reposroute["Repository rollup API<br/>[repos.py]"]
end

subgraph group_domain["Test intelligence"]
  node_junit["JUnit parser<br/>[junit.py]"]
  node_ingest["Run ingestion<br/>[ingest.py]"]
  node_selector["Test selector<br/>[selector.py]"]
  node_history["History and rollup<br/>[history.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_storage["Persistence"]
  node_models["Data models<br/>[models.py]"]
  node_database[("Postgres<br/>[db.py]")]
end

node_developer(("Developer"))
node_ci(("CI workflow"))
node_testcmd["Test runner"]

node_developer -->|"requests selection"| node_cli
node_ci -->|"runs action"| node_ghaction
node_ghaction -->|"invokes commands"| node_cli
node_cli -->|"builds import graph"| node_pygraph
node_cli -->|"analyzes Go packages"| node_gograph
node_cli -->|"loads repo config"| node_repoconfig
node_cli -->|"requests selection"| node_selectroute
node_selectroute -->|"selects tests"| node_selector
node_selector -->|"loads history"| node_history
node_selector -->|"uses test records"| node_models
node_selectroute -.->|"returns selection schema"| node_schemas
node_cli -->|"prints test command"| node_testcmd
node_ci -->|"uploads JUnit"| node_runroute
node_runroute -->|"parses XML"| node_junit
node_runroute -->|"creates run"| node_ingest
node_runroute -->|"validates metadata"| node_schemas
node_ingest -->|"stores results"| node_models
node_ci -->|"requests rollup"| node_reposroute
node_reposroute -->|"recomputes stats"| node_history
node_historyroute -.->|"queries test history"| node_history
node_apiapp -->|"registers route"| node_runroute
node_apiapp -->|"registers route"| node_selectroute
node_apiapp -->|"registers route"| node_historyroute
node_apiapp -->|"registers route"| node_reposroute
node_database -.->|"persists entities"| node_models
node_history -->|"rolls up results"| node_models
node_runroute -->|"uses sessions"| node_database
node_reposroute -->|"uses sessions"| node_database

click node_cli "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/main.py"
click node_ghaction "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/gha.py"
click node_pygraph "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/pygraph.py"
click node_gograph "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/gograph.py"
click node_repoconfig "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/repoconfig.py"
click node_apiapp "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/main.py"
click node_runroute "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/runs.py"
click node_selectroute "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/select.py"
click node_historyroute "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/history.py"
click node_reposroute "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/repos.py"
click node_junit "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/junit.py"
click node_ingest "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/ingest.py"
click node_selector "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/selector.py"
click node_history "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/history.py"
click node_schemas "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/schemas.py"
click node_models "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/models.py"
click node_database "https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/db.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_cli,node_ghaction,node_pygraph,node_gograph,node_repoconfig toneBlue
class node_apiapp,node_runroute,node_selectroute,node_historyroute,node_reposroute toneAmber
class node_junit,node_ingest,node_selector,node_history,node_schemas toneMint
class node_models,node_database toneRose
class node_developer,node_ci,node_testcmd toneIndigo
```

## Components

### CLI and CI clients

- [CLI commands](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/main.py): `src/siftwise/cli/main.py`
- [GitHub Actions glue](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/gha.py): `src/siftwise/cli/gha.py`
- [Python import graph](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/pygraph.py): `src/siftwise/cli/pygraph.py`
- [Go package graph](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/gograph.py): `src/siftwise/cli/gograph.py`
- [Repo configuration](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/cli/repoconfig.py): `src/siftwise/cli/repoconfig.py`

### HTTP API

- [API application](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/main.py): `src/siftwise/api/main.py`
- [Run ingestion API](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/runs.py): `src/siftwise/api/routes/runs.py`
- [Selection API](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/select.py): `src/siftwise/api/routes/select.py`
- [History API](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/history.py): `src/siftwise/api/routes/history.py`
- [Repository rollup API](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/api/routes/repos.py): `src/siftwise/api/routes/repos.py`

### Test intelligence

- [JUnit parser](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/junit.py): `src/siftwise/core/junit.py`
- [Run ingestion](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/ingest.py): `src/siftwise/core/ingest.py`
- [Test selector](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/selector.py): `src/siftwise/core/selector.py`
- [History and rollup](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/history.py): `src/siftwise/core/history.py`
- [API schemas](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/schemas.py): `src/siftwise/core/schemas.py`

### Persistence

- [Data models](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/core/models.py): `src/siftwise/core/models.py`
- [Postgres](https://github.com/pramodbasavarajmenasi/siftwise/blob/main/src/siftwise/db.py): `src/siftwise/db.py`

### Other components

- **Developer**
- **CI workflow**
- **Test runner**

## Connections

- Developer → CLI commands: requests selection (evidence: `README.md`)
- CI workflow → GitHub Actions glue: runs action (evidence: `README.md`)
- GitHub Actions glue → CLI commands: invokes commands (evidence: `src/siftwise/cli/gha.py`)
- CLI commands → Python import graph: builds import graph (evidence: `src/siftwise/cli/main.py`)
- CLI commands → Go package graph: analyzes Go packages (evidence: `src/siftwise/cli/main.py`)
- CLI commands → Repo configuration: loads repo config (evidence: `src/siftwise/cli/main.py`)
- CLI commands → Selection API: requests selection (evidence: `README.md`)
- Selection API → Test selector: selects tests
- Test selector → History and rollup: loads history (evidence: `src/siftwise/core/selector.py`)
- Test selector → Data models: uses test records (evidence: `src/siftwise/core/selector.py`)
- Selection API → API schemas: returns selection schema
- CLI commands → Test runner: prints test command (evidence: `README.md`)
- CI workflow → Run ingestion API: uploads JUnit (evidence: `README.md`)
- Run ingestion API → JUnit parser: parses XML (evidence: `src/siftwise/api/routes/runs.py`)
- Run ingestion API → Run ingestion: creates run (evidence: `src/siftwise/api/routes/runs.py`)
- Run ingestion API → API schemas: validates metadata (evidence: `src/siftwise/api/routes/runs.py`)
- Run ingestion → Data models: stores results
- CI workflow → Repository rollup API: requests rollup (evidence: `README.md`)
- Repository rollup API → History and rollup: recomputes stats (evidence: `src/siftwise/api/routes/repos.py`)
- History API → History and rollup: queries test history
- API application → Run ingestion API: registers route (evidence: `src/siftwise/api/main.py`)
- API application → Selection API: registers route (evidence: `src/siftwise/api/main.py`)
- API application → History API: registers route (evidence: `src/siftwise/api/main.py`)
- API application → Repository rollup API: registers route (evidence: `src/siftwise/api/main.py`)
- Postgres → Data models: persists entities
- History and rollup → Data models: rolls up results (evidence: `src/siftwise/core/history.py`)
- Run ingestion API → Postgres: uses sessions (evidence: `src/siftwise/api/routes/runs.py`)
- Repository rollup API → Postgres: uses sessions (evidence: `src/siftwise/api/routes/repos.py`)
