Skip to content

tRPC route catalogue

The api and data-provider expose tRPC routers under presentation/. This page enumerates the routers; precise input / output shapes live with the code (packages/business/shared/src/ for the wire DTOs).

Located in apps/backend/api/src/presentation/routers/.

RouterRole
usersProfile, settings, display currency, magic-link / OTP flows.
sessionsSession read / revoke.
accountsList, create, update, hide accounts.
account-typesCatalogue of account types.
institutionsList institutions. Create the synthetic manual institution.
institution-typesCatalogue of institution types.
holdingsCRUD on holdings, set/unset APY config, attach to vault / group.
tokensSearch tokens, materialise via TokenIdentityService.
transactionsRead the ledger. Filter by date range, kind, account, holding, transfer group.
vaultsCRUD on vaults, attach/detach holdings with percentage splits.
groupsCRUD on groups, attach holdings + accounts.
portfolioDashboard headline + chart series (reads portfolio_value_daily).
dashboardAggregate dashboard data — composes calls to portfolio + per-scope rollups.
integrationsConnect / disconnect provider integrations (Binance OAuth, exchange API keys, brokerage tokens, wallets). Owns encrypt/decrypt of credentials.
walletAdd / discover on-chain wallets.
screenshotsUpload screenshot to S3, enqueue screenshot-parse job.
file-importUpload CSV / file, enqueue file-import job.
storagePresigned URL minting for direct S3 reads.
jobsHMAC-gated operator endpoints: retry, remove, DLQ replay.
batch-operationsBatched mutations the SPA uses for bulk edits.
client-errorsEndpoint the SPA posts unhandled-error reports to.

Auth: every router except the user-facing magic-link entry points requires a Better-Auth session cookie. The jobs router additionally requires an HMAC signature using JOBS_HMAC_SECRET.

data-provider (apps/backend/data-provider)

Section titled “data-provider (apps/backend/data-provider)”

Located in apps/backend/data-provider/src/presentation/routers/. Composed in apps/backend/data-provider/src/presentation/router.ts.

RouterAuthRole
pricingBearerCurrent and historical prices via the routed provider stack (CoinGecko, Finnhub, DeFiLlama, Frankfurter, Yahoo Finance).
chainsBearerBlockchain balance + transaction reads (Etherscan V2 across EVM chains, Helius for Solana, Bitcoin RPC, Tron, TON, ENS).
aiBearerScreenshot parsing (OpenAI Vision). Optionally Perplexity / DeepSeek for token-identity assistance.
tokensBearerIdentity-related calls used by TokenIdentityService (CoinGecko slug lookup, Etherscan contract lookup, …).
emailBeareremail.send — used by the api to send magic-link / OTP / verification emails.
storageBearerPresigned URL minting + the rare server-side read path. The only service that holds S3/R2 credentials; api + worker request presigned URLs from here so creds never leave the data-provider.
ogBearerOpen Graph metadata fetch (used by the SPA’s link previews).
contactPublicLanding-page contact form: validates a submission, emails support, sends a receipt. Per-IP rate-limited. No bearer (called from the public marketing site).
keysCookieCloud-management surface (CLOUD_MANAGEMENT_ENABLED=true): mint, list, revoke cloud API keys scoped to the authenticated cloud user.
usageCookieCloud-management read-API: per-user / per-tier usage aggregation from cloud_usage_events.

Auth column: Bearer = DATA_PROVIDER_API_KEY (every api / worker call). Cookie = Better-Auth session, only available when CLOUD_MANAGEMENT_ENABLED=true and the data-provider is fronted by the cloud-frontend. Public = no auth (rate-limited per-IP).

Input / output shapes are zod schemas in packages/business/shared/src/. Every router’s payload schema is also the source of truth for the SPA’s tRPC client types.

Three gates fire in order:

  1. Bearer / cookie auth. No bearer / cookie → UNAUTHORIZED.
  2. Capability gate. A call needing a provider key (e.g. ai.parseScreenshot needs OPENAI_API_KEY) returns PRECONDITION_FAILED when unconfigured.
  3. Rate limit. Per-provider rate limiter (@scani/rate-limiter) returns TOO_MANY_REQUESTS when the upstream’s quota is hit. The api retries via BullMQ’s retry policy.
  1. Create the router file in the appropriate src/presentation/routers/ directory.
  2. Define the input / output zod schema in packages/business/shared/src/.
  3. Register the router in the app’s root router (index.ts alongside the existing routers).
  4. The SPA’s tRPC client picks it up automatically via the end-to-end-typed client factory.