# tomas-santucho/ghostfolio-ppi-sync architecture

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

- Interactive diagram: https://gitdiagram.com/tomas-santucho/ghostfolio-ppi-sync
- Repository: https://github.com/tomas-santucho/ghostfolio-ppi-sync

## Overview

This repository is a PPI-to-Ghostfolio portfolio synchronization application. Its main workflow loads configuration, retrieves PPI account activity, normalizes and reconciles transactions, then imports them into Ghostfolio. Separate commands support bootstrap imports and MEP balance or holdings projections. The graph follows the CLI wiring and sampled sync logic; some details of unsampled projection and client implementations are represented only at their known source paths, so unverified links are omitted.

Main entry points: [`src/index.ts`](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/index.ts) (CLI entry point), [`src/sync.ts`](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/sync.ts) (Sync orchestration), [`src/mapping/ppi-to-normalized.ts`](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/ppi-to-normalized.ts) (PPI normalization), [`src/ppi/order-matching.ts`](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/order-matching.ts) (Order enrichment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_cli["CLI entry point<br/>[index.ts]"]
  node_config["Configuration<br/>[config.ts]"]
  node_runlock["Run lock<br/>[run-lock.ts]"]
  node_sync["Sync orchestration<br/>[sync.ts]"]
  node_bootstrap["Bootstrap holdings<br/>[bootstrap.ts]"]
  node_balance["MEP balance projection"]
  node_holdings["MEP holdings projection"]
end

subgraph group_integrations["External integrations"]
  node_ppi_client["PPI API client<br/>[client.ts]"]
  node_ppi_auth["PPI authentication<br/>[auth.ts]"]
  node_ppi_service["PPI service"]
  node_gf_client["Ghostfolio API client<br/>[client.ts]"]
  node_ghostfolio["Ghostfolio service"]
end

subgraph group_mapping["Transaction mapping"]
  node_normalize["PPI normalization"]
  node_fingerprint["Transaction identity<br/>[fingerprint.ts]"]
  node_order_matching["Order enrichment<br/>[order-matching.ts]"]
  node_currency["Currency mapping<br/>[currency.ts]"]
  node_cash_movement["Cash movement mapping<br/>[cash-movements.ts]"]
  node_cash_asset["Cash asset mapping<br/>[cash-assets.ts]"]
  node_settlement["Trade settlements"]
  node_gf_mapping["Ghostfolio activity mapping"]
  node_symbol_override["Symbol overrides"]
  node_symbol["Symbol normalization<br/>[symbols.ts]"]
  node_decimals["Decimal parsing<br/>[decimals.ts]"]
end

node_operator(("Operator"))

node_operator -->|"invokes"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"acquires lock"| node_runlock
node_cli -->|"runs sync"| node_sync
node_cli -->|"parses holdings"| node_bootstrap
node_cli -->|"runs projection"| node_balance
node_cli -->|"runs projection"| node_holdings
node_cli -->|"constructs"| node_ppi_client
node_cli -->|"constructs"| node_gf_client
node_ppi_client -->|"authenticates"| node_ppi_auth
node_ppi_client -->|"requests data"| node_ppi_service
node_gf_client -->|"requests imports"| node_ghostfolio
node_sync -->|"reads activity"| node_ppi_client
node_sync -->|"imports activities"| node_gf_client
node_sync -->|"normalizes transactions"| node_normalize
node_sync -->|"enriches orders"| node_order_matching
node_sync -->|"resolves cash assets"| node_cash_asset
node_sync -->|"maps settlements"| node_settlement
node_sync -->|"resolves symbols"| node_symbol_override
node_sync -->|"deduplicates activity"| node_fingerprint
node_sync -->|"converts activities"| node_gf_mapping
node_normalize -->|"assigns identity"| node_fingerprint
node_normalize -->|"normalizes currency"| node_currency
node_normalize -->|"normalizes symbol"| node_symbol
node_normalize -->|"classifies movement"| node_cash_movement
node_normalize -->|"parses amounts"| node_decimals
node_cash_asset -->|"normalizes currency"| node_currency
node_order_matching -->|"normalizes currency"| node_currency
node_order_matching -->|"normalizes symbol"| node_symbol
node_order_matching -->|"parses amounts"| node_decimals
node_settlement -->|"resolves cash assets"| node_cash_asset
node_settlement -->|"uses identity"| node_fingerprint
node_cli -->|"retrieves positions"| node_ppi_service

click node_cli "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/index.ts"
click node_config "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/config.ts"
click node_runlock "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/run-lock.ts"
click node_sync "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/sync.ts"
click node_bootstrap "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/bootstrap.ts"
click node_balance "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mep-balance-projection.ts"
click node_holdings "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mep-holdings-projection.ts"
click node_ppi_client "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/client.ts"
click node_ppi_auth "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/auth.ts"
click node_gf_client "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ghostfolio/client.ts"
click node_normalize "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/ppi-to-normalized.ts"
click node_fingerprint "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/fingerprint.ts"
click node_order_matching "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/order-matching.ts"
click node_currency "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/currency.ts"
click node_cash_movement "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/cash-movements.ts"
click node_cash_asset "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/cash-assets.ts"
click node_settlement "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/trade-settlements.ts"
click node_gf_mapping "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/normalized-to-ghostfolio.ts"
click node_symbol_override "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/symbol-overrides.ts"
click node_symbol "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/symbols.ts"
click node_decimals "https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/decimals.ts"

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_config,node_runlock,node_sync,node_bootstrap,node_balance,node_holdings toneBlue
class node_ppi_client,node_ppi_auth,node_ppi_service,node_gf_client,node_ghostfolio toneAmber
class node_normalize,node_fingerprint,node_order_matching,node_currency,node_cash_movement,node_cash_asset,node_settlement,node_gf_mapping,node_symbol_override,node_symbol,node_decimals toneMint
class node_operator toneIndigo
```

## Components

### Runtime orchestration

- [CLI entry point](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/index.ts): `src/index.ts`
- [Configuration](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/config.ts): `src/config.ts`
- [Run lock](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/run-lock.ts): `src/run-lock.ts`
- [Sync orchestration](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/sync.ts): `src/sync.ts`
- [Bootstrap holdings](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/bootstrap.ts): `src/bootstrap.ts`
- [MEP balance projection](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mep-balance-projection.ts): `src/mep-balance-projection.ts`
- [MEP holdings projection](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mep-holdings-projection.ts): `src/mep-holdings-projection.ts`

### External integrations

- [PPI API client](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/client.ts): `src/ppi/client.ts`
- [PPI authentication](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/auth.ts): `src/ppi/auth.ts`
- **PPI service**
- [Ghostfolio API client](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ghostfolio/client.ts): `src/ghostfolio/client.ts`
- **Ghostfolio service**

### Transaction mapping

- [PPI normalization](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/ppi-to-normalized.ts): `src/mapping/ppi-to-normalized.ts`
- [Transaction identity](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/fingerprint.ts): `src/mapping/fingerprint.ts`
- [Order enrichment](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/order-matching.ts): `src/ppi/order-matching.ts`
- [Currency mapping](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/currency.ts): `src/mapping/currency.ts`
- [Cash movement mapping](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/cash-movements.ts): `src/mapping/cash-movements.ts`
- [Cash asset mapping](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/cash-assets.ts): `src/mapping/cash-assets.ts`
- [Trade settlements](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/trade-settlements.ts): `src/mapping/trade-settlements.ts`
- [Ghostfolio activity mapping](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/normalized-to-ghostfolio.ts): `src/mapping/normalized-to-ghostfolio.ts`
- [Symbol overrides](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/symbol-overrides.ts): `src/mapping/symbol-overrides.ts`
- [Symbol normalization](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/mapping/symbols.ts): `src/mapping/symbols.ts`
- [Decimal parsing](https://github.com/tomas-santucho/ghostfolio-ppi-sync/blob/main/src/ppi/decimals.ts): `src/ppi/decimals.ts`

### Other components

- **Operator**

## Connections

- Operator → CLI entry point: invokes (evidence: `src/index.ts`)
- CLI entry point → Configuration: loads settings (evidence: `src/index.ts`)
- CLI entry point → Run lock: acquires lock (evidence: `src/index.ts`)
- CLI entry point → Sync orchestration: runs sync (evidence: `src/index.ts`)
- CLI entry point → Bootstrap holdings: parses holdings (evidence: `src/index.ts`)
- CLI entry point → MEP balance projection: runs projection (evidence: `src/index.ts`)
- CLI entry point → MEP holdings projection: runs projection (evidence: `src/index.ts`)
- CLI entry point → PPI API client: constructs (evidence: `src/index.ts`)
- CLI entry point → Ghostfolio API client: constructs (evidence: `src/index.ts`)
- PPI API client → PPI authentication: authenticates (evidence: `src/ppi/client.ts`)
- PPI API client → PPI service: requests data (evidence: `src/ppi/client.ts`)
- Ghostfolio API client → Ghostfolio service: requests imports (evidence: `src/ghostfolio/client.ts`)
- Sync orchestration → PPI API client: reads activity (evidence: `src/index.ts`)
- Sync orchestration → Ghostfolio API client: imports activities (evidence: `src/sync.ts`)
- Sync orchestration → PPI normalization: normalizes transactions (evidence: `src/sync.ts`)
- Sync orchestration → Order enrichment: enriches orders (evidence: `src/sync.ts`)
- Sync orchestration → Cash asset mapping: resolves cash assets (evidence: `src/sync.ts`)
- Sync orchestration → Trade settlements: maps settlements (evidence: `src/sync.ts`)
- Sync orchestration → Symbol overrides: resolves symbols (evidence: `src/sync.ts`)
- Sync orchestration → Transaction identity: deduplicates activity (evidence: `src/sync.ts`)
- Sync orchestration → Ghostfolio activity mapping: converts activities (evidence: `src/sync.ts`)
- PPI normalization → Transaction identity: assigns identity (evidence: `src/mapping/ppi-to-normalized.ts`)
- PPI normalization → Currency mapping: normalizes currency (evidence: `src/mapping/ppi-to-normalized.ts`)
- PPI normalization → Symbol normalization: normalizes symbol (evidence: `src/mapping/ppi-to-normalized.ts`)
- PPI normalization → Cash movement mapping: classifies movement (evidence: `src/mapping/ppi-to-normalized.ts`)
- PPI normalization → Decimal parsing: parses amounts (evidence: `src/mapping/ppi-to-normalized.ts`)
- Cash asset mapping → Currency mapping: normalizes currency (evidence: `src/mapping/cash-assets.ts`)
- Order enrichment → Currency mapping: normalizes currency (evidence: `src/ppi/order-matching.ts`)
- Order enrichment → Symbol normalization: normalizes symbol (evidence: `src/ppi/order-matching.ts`)
- Order enrichment → Decimal parsing: parses amounts (evidence: `src/ppi/order-matching.ts`)
- Trade settlements → Cash asset mapping: resolves cash assets (evidence: `src/mapping/trade-settlements.ts`)
- Trade settlements → Transaction identity: uses identity (evidence: `src/mapping/trade-settlements.ts`)
- CLI entry point → PPI service: retrieves positions (evidence: `src/index.ts`)
