# sampathreddy22/examplars architecture

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

- Interactive diagram: https://gitdiagram.com/sampathreddy22/examplars
- Repository: https://github.com/sampathreddy22/examplars

## Overview

Examplars is a runnable collection of Python design-pattern examples; the documented current pattern is a money-transfer Saga. A user selects a pattern through the CLI, which dispatches to the demo: it resets and seeds the database, starts transfers, and displays balances and saga logs. The orchestrator persists saga progress, runs validation, debit, credit, and audit steps, and compensates completed steps in reverse after failure. The README describes adding more patterns, but only Saga is present in the tree. The graph reflects sampled source and README evidence; it does not imply external distributed services.

Main entry points: [`patterns/saga/orchestrator.py`](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/orchestrator.py) (Saga orchestrator), [`patterns/saga/db.py`](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/db.py) (SQLite saga database), [`patterns/saga/main.py`](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/main.py) (Transfer demo), [`patterns/cli.py`](https://github.com/sampathreddy22/examplars/blob/master/patterns/cli.py) (Pattern dispatcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Pattern entry"]
  node_dispatcher["Pattern dispatcher<br/>[cli.py]"]
end

subgraph group_saga["Transfer saga"]
  node_demo["Transfer demo<br/>[main.py]"]
  node_orchestrator["Saga orchestrator<br/>[orchestrator.py]"]
  node_validation["Validate transfer<br/>[steps.py]"]
  node_debit["Debit source<br/>[steps.py]"]
  node_credit["Credit destination<br/>[steps.py]"]
  node_audit["Record transfer<br/>[steps.py]"]
end

subgraph group_state["Saga state"]
  node_database[("SQLite saga database<br/>[db.py]")]
end

node_user(("CLI user"))

node_user -->|"selects pattern"| node_dispatcher
node_dispatcher -->|"dispatches to"| node_demo
node_demo -->|"starts transfers"| node_orchestrator
node_demo -->|"resets, seeds, reads"| node_database
node_orchestrator -->|"persists saga state"| node_database
node_orchestrator -->|"runs, compensates"| node_validation
node_orchestrator -->|"runs, compensates"| node_debit
node_orchestrator -->|"runs, compensates"| node_credit
node_orchestrator -->|"runs, compensates"| node_audit
node_validation -->|"reads accounts"| node_database
node_debit -->|"updates accounts"| node_database
node_credit -->|"updates accounts"| node_database
node_audit -->|"writes transfer log"| node_database

click node_dispatcher "https://github.com/sampathreddy22/examplars/blob/master/patterns/cli.py"
click node_demo "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/main.py"
click node_orchestrator "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/orchestrator.py"
click node_validation "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py"
click node_debit "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py"
click node_credit "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py"
click node_audit "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py"
click node_database "https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/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_dispatcher,node_user toneBlue
class node_demo,node_orchestrator,node_validation,node_debit,node_credit,node_audit toneAmber
class node_database toneMint
```

## Components

### Pattern entry

- [Pattern dispatcher](https://github.com/sampathreddy22/examplars/blob/master/patterns/cli.py): `patterns/cli.py`

### Transfer saga

- [Transfer demo](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/main.py): `patterns/saga/main.py`
- [Saga orchestrator](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/orchestrator.py): `patterns/saga/orchestrator.py`
- [Validate transfer](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py): `patterns/saga/steps.py`
- [Debit source](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py): `patterns/saga/steps.py`
- [Credit destination](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py): `patterns/saga/steps.py`
- [Record transfer](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/steps.py): `patterns/saga/steps.py`

### Saga state

- [SQLite saga database](https://github.com/sampathreddy22/examplars/blob/master/patterns/saga/db.py): `patterns/saga/db.py`

### Other components

- **CLI user**

## Connections

- CLI user → Pattern dispatcher: selects pattern (evidence: `patterns/cli.py`)
- Pattern dispatcher → Transfer demo: dispatches to (evidence: `patterns/cli.py`)
- Transfer demo → Saga orchestrator: starts transfers (evidence: `patterns/saga/main.py`)
- Transfer demo → SQLite saga database: resets, seeds, reads (evidence: `patterns/saga/main.py`)
- Saga orchestrator → SQLite saga database: persists saga state (evidence: `patterns/saga/orchestrator.py`)
- Saga orchestrator → Validate transfer: runs, compensates (evidence: `patterns/saga/orchestrator.py`)
- Saga orchestrator → Debit source: runs, compensates (evidence: `patterns/saga/orchestrator.py`)
- Saga orchestrator → Credit destination: runs, compensates (evidence: `patterns/saga/orchestrator.py`)
- Saga orchestrator → Record transfer: runs, compensates (evidence: `patterns/saga/orchestrator.py`)
- Validate transfer → SQLite saga database: reads accounts (evidence: `patterns/saga/steps.py`)
- Debit source → SQLite saga database: updates accounts (evidence: `patterns/saga/steps.py`)
- Credit destination → SQLite saga database: updates accounts (evidence: `patterns/saga/steps.py`)
- Record transfer → SQLite saga database: writes transfer log (evidence: `patterns/saga/steps.py`)
