# ftthreign/savoryx_app architecture

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

- Interactive diagram: https://gitdiagram.com/ftthreign/savoryx_app
- Repository: https://github.com/ftthreign/savoryx_app

## Overview

Savoryx is a personal-finance product: its visible runtime is a cross-platform Flutter app shell backed by a Go API for device authentication, financial records, vaults, reconciliation, synchronization and exchange rates. The principal server workflow is an HTTP request entering the API router, reaching a domain service, and using persistence adapters; FX rates also arrive through a scheduled worker and an external provider. The supplied tree contains no Flutter/Dart application source, and several handlers and services were not excerpted, so those internal request links are shown as unverified rather than asserted.

Main entry points: [`server/cmd/api/main.go`](https://github.com/ftthreign/savoryx_app/blob/master/server/cmd/api/main.go) (API process), [`server/internal/adapter/repository/postgres`](https://github.com/ftthreign/savoryx_app/tree/master/server/internal/adapter/repository/postgres) (Postgres repositories), [`server/internal/adapter/worker/fx_cron_worker.go`](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/worker/fx_cron_worker.go) (FX scheduler), [`server/internal/core/service/auth_service.go`](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/auth_service.go) (Device auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App and API entry"]
  node_client(("Savoryx client"))
  node_flutter_hosts["Flutter platform hosts<br/>[main.cpp]"]
  node_api["API process<br/>[main.go]"]
end

subgraph group_http["HTTP interface"]
  node_router["HTTP router<br/>[router.go]"]
  node_auth_handler["Device auth handler<br/>[auth_handler.go]"]
end

subgraph group_domain["Finance services"]
  node_auth_service["Device auth<br/>[auth_service.go]"]
  node_finance_services["Finance services"]
  node_sync_service["Offline sync<br/>[sync_service.go]"]
  node_transaction_service["Transactions"]
  node_fx_service["Exchange rates<br/>[fx_service.go]"]
end

subgraph group_adapters["Infrastructure adapters"]
  node_pg_repositories["Postgres repositories"]
  node_postgres[("PostgreSQL")]
  node_tx_manager["Transaction manager<br/>[tx_manager.go]"]
  node_paseto["PASETO security<br/>[paseto.go]"]
  node_fx_worker["FX scheduler<br/>[fx_cron_worker.go]"]
  node_fx_client["Frankfurter client"]
  node_fx_cache["FX cache<br/>[memory_fx_cache.go]"]
end

node_frankfurter(("Frankfurter API"))

node_client -.->|"sends requests"| node_api
node_flutter_hosts -.->|"hosts app"| node_client
node_api -->|"serves routes"| node_router
node_api -->|"constructs"| node_auth_service
node_api -->|"constructs"| node_finance_services
node_api -->|"constructs"| node_sync_service
node_api -->|"constructs"| node_transaction_service
node_api -->|"constructs"| node_fx_service
node_api -->|"constructs"| node_pg_repositories
node_api -->|"starts worker"| node_fx_worker
node_router -.->|"routes to"| node_auth_handler
node_auth_handler -->|"registers device"| node_auth_service
node_auth_service -->|"uses device repository"| node_pg_repositories
node_auth_service -->|"uses token manager"| node_paseto
node_finance_services -.->|"uses repositories"| node_pg_repositories
node_sync_service -->|"reads and writes"| node_pg_repositories
node_transaction_service -->|"uses repositories"| node_pg_repositories
node_api -->|"constructs"| node_tx_manager
node_tx_manager -->|"manages transactions"| node_postgres
node_pg_repositories -.->|"queries"| node_postgres
node_api -->|"constructs"| node_fx_client
node_api -->|"constructs"| node_fx_cache
node_fx_worker -->|"fetches rates"| node_fx_client
node_fx_worker -->|"upserts rates"| node_pg_repositories
node_fx_worker -->|"invalidates cache"| node_fx_cache
node_fx_client -->|"requests rates"| node_frankfurter
node_fx_service -.->|"uses rate repository"| node_pg_repositories

click node_flutter_hosts "https://github.com/ftthreign/savoryx_app/blob/master/apps/windows/runner/main.cpp"
click node_api "https://github.com/ftthreign/savoryx_app/blob/master/server/cmd/api/main.go"
click node_router "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/handler/http/router.go"
click node_auth_handler "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/handler/http/auth_handler.go"
click node_auth_service "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/auth_service.go"
click node_finance_services "https://github.com/ftthreign/savoryx_app/tree/master/server/internal/core/service"
click node_sync_service "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/sync_service.go"
click node_transaction_service "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/transaction_service.go"
click node_fx_service "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/fx_service.go"
click node_pg_repositories "https://github.com/ftthreign/savoryx_app/tree/master/server/internal/adapter/repository/postgres"
click node_tx_manager "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/repository/postgres/tx_manager.go"
click node_paseto "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/security/paseto.go"
click node_fx_worker "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/worker/fx_cron_worker.go"
click node_fx_client "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/fx/frankfurter_client.go"
click node_fx_cache "https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/cache/memory_fx_cache.go"

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_client,node_flutter_hosts,node_api toneBlue
class node_router,node_auth_handler toneAmber
class node_auth_service,node_finance_services,node_sync_service,node_transaction_service,node_fx_service,node_frankfurter toneMint
class node_pg_repositories,node_postgres,node_tx_manager,node_paseto,node_fx_worker,node_fx_client,node_fx_cache toneRose
```

## Components

### App and API entry

- **Savoryx client**
- [Flutter platform hosts](https://github.com/ftthreign/savoryx_app/blob/master/apps/windows/runner/main.cpp): `apps/windows/runner/main.cpp`
- [API process](https://github.com/ftthreign/savoryx_app/blob/master/server/cmd/api/main.go): `server/cmd/api/main.go`

### HTTP interface

- [HTTP router](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/handler/http/router.go): `server/internal/adapter/handler/http/router.go`
- [Device auth handler](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/handler/http/auth_handler.go): `server/internal/adapter/handler/http/auth_handler.go`

### Finance services

- [Device auth](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/auth_service.go): `server/internal/core/service/auth_service.go`
- [Finance services](https://github.com/ftthreign/savoryx_app/tree/master/server/internal/core/service): `server/internal/core/service`
- [Offline sync](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/sync_service.go): `server/internal/core/service/sync_service.go`
- [Transactions](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/transaction_service.go): `server/internal/core/service/transaction_service.go`
- [Exchange rates](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/core/service/fx_service.go): `server/internal/core/service/fx_service.go`

### Infrastructure adapters

- [Postgres repositories](https://github.com/ftthreign/savoryx_app/tree/master/server/internal/adapter/repository/postgres): `server/internal/adapter/repository/postgres`
- **PostgreSQL**
- [Transaction manager](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/repository/postgres/tx_manager.go): `server/internal/adapter/repository/postgres/tx_manager.go`
- [PASETO security](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/security/paseto.go): `server/internal/adapter/security/paseto.go`
- [FX scheduler](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/worker/fx_cron_worker.go): `server/internal/adapter/worker/fx_cron_worker.go`
- [Frankfurter client](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/fx/frankfurter_client.go): `server/internal/adapter/fx/frankfurter_client.go`
- [FX cache](https://github.com/ftthreign/savoryx_app/blob/master/server/internal/adapter/cache/memory_fx_cache.go): `server/internal/adapter/cache/memory_fx_cache.go`

### Other components

- **Frankfurter API**

## Connections

- Savoryx client → API process: sends requests
- Flutter platform hosts → Savoryx client: hosts app
- API process → HTTP router: serves routes (evidence: `server/cmd/api/main.go`)
- API process → Device auth: constructs (evidence: `server/cmd/api/main.go`)
- API process → Finance services: constructs (evidence: `server/cmd/api/main.go`)
- API process → Offline sync: constructs (evidence: `server/cmd/api/main.go`)
- API process → Transactions: constructs (evidence: `server/cmd/api/main.go`)
- API process → Exchange rates: constructs (evidence: `server/cmd/api/main.go`)
- API process → Postgres repositories: constructs (evidence: `server/cmd/api/main.go`)
- API process → FX scheduler: starts worker (evidence: `server/cmd/api/main.go`)
- HTTP router → Device auth handler: routes to
- Device auth handler → Device auth: registers device (evidence: `server/internal/adapter/handler/http/auth_handler.go`)
- Device auth → Postgres repositories: uses device repository (evidence: `server/internal/core/service/auth_service.go`)
- Device auth → PASETO security: uses token manager (evidence: `server/internal/core/service/auth_service.go`)
- Finance services → Postgres repositories: uses repositories
- Offline sync → Postgres repositories: reads and writes (evidence: `server/internal/core/service/sync_service.go`)
- Transactions → Postgres repositories: uses repositories (evidence: `server/internal/core/service/transaction_service.go`)
- API process → Transaction manager: constructs (evidence: `server/cmd/api/main.go`)
- Transaction manager → PostgreSQL: manages transactions (evidence: `server/internal/adapter/repository/postgres/tx_manager.go`)
- Postgres repositories → PostgreSQL: queries
- API process → Frankfurter client: constructs (evidence: `server/cmd/api/main.go`)
- API process → FX cache: constructs (evidence: `server/cmd/api/main.go`)
- FX scheduler → Frankfurter client: fetches rates (evidence: `server/internal/adapter/worker/fx_cron_worker.go`)
- FX scheduler → Postgres repositories: upserts rates (evidence: `server/internal/adapter/worker/fx_cron_worker.go`)
- FX scheduler → FX cache: invalidates cache (evidence: `server/internal/adapter/worker/fx_cron_worker.go`)
- Frankfurter client → Frankfurter API: requests rates (evidence: `server/internal/adapter/fx/frankfurter_client.go`)
- Exchange rates → Postgres repositories: uses rate repository
