Docs
Reference

Technical Reference

Non-technical technical reference for Torq architecture, APIs, schemas, contracts, events, indexers, GraphQL, and background jobs.

This page explains the technical system without assuming the reader can read code.

The most important rule is:

Chain -> Indexer -> Projector -> Postgres -> API -> Frontend

That rule means the app should show shared protocol state only after it has passed through the canonical read model.

Architecture stack

Protocol, data, API, and workspaces stay separate

Authoritypermissions, policy, and controlled actions
Workspacesoperators, lenders, borrowers, reporters
APIGraphQL and operator read surfaces
Projected truthPostgres current-state model
Protocol runtimeV2 shared markets and multi-vault kernel

Technical posture

Many DeFi frontends read contracts, index events, and show market state. Torq's technical design is stricter for shared state: the frontend should not reconstruct protocol truth for investor, operator, or admin views. The technical product is a controlled credit facility operating system with contracts, indexers, projectors, API surfaces, role workspaces, and post-write verification.

Architecture

LayerPlain meaningSource evidence
ContractsValue-moving runtime and authority rules.protocol/contracts/** and active V2 contract inventory.
IndexerWatches chain and runtime events.services/indexer/data/indexer/**.
ProjectorsConvert observed events into current-state rows.services/indexer/data/indexer/projectors/**.
PostgresStores canonical application truth.services/indexer/data/migrations/**.
APIsServe persisted state and controlled mutation surfaces.services/indexer/api/** and GraphQL schema files.
FrontendRole-specific workspaces that consume API state.apps/web/src/app/router.tsx and workspace pages.
DocsProduct manual and generated source map.apps/docs/content/docs/**.

APIs

API groupWhat it does
Public GraphQLServes read-oriented product state from Postgres.
Operator GraphQLServes operator and workspace mutation/read surfaces with stronger auth expectations.
Tracked mutation progressReports post-write execution and projection progress.
Wallet-flow healthHelps diagnose wallet execution path readiness.
Workspace messagesSupports messages, replies, amendments, target selection, and expiry.
Faucet ETH claimSupports local/test funding flows.
Quicknode streamsReceives stream events where configured.
Agent creditProvides borrower-route inputs for supported borrow and repay flows.

Database schema

Torq uses Postgres current-state and support tables to hold application truth. Migration files in services/indexer/data/migrations/** define the schema history.

Plain examples of table families:

  • vault current state
  • market current state
  • borrower debt and partition state
  • asset policy and registry rows
  • oracle and NAV report rows
  • permission and role rows
  • tracked mutation progress
  • workspace messages
  • accounting and reconciliation evidence

Smart contracts

The active V2 inventory includes:

Contract groupExamples
Core runtimeTorqSharedCreditMarketV2, shared market execution modules, TorqVaultKernelMultiVaultV2, vault kernel modules, TorqVaultMarketRegistryV2.
Governance and permissionsProtocolManagerGateV2, ProtocolPermissionManager, ScopedEntityAuthority, ScopedWorkspaceTimelockExecutor, TorqTimelock, wallet compliance policy.
Oracles and valuationSignedNavAdapterV2, SingleFeedAdapterV2, SupplyAwareSingleFeedAdapterV2, PairMultiHopAdapterV2, ConservativeMinAdapterV2, TorqOracleFactory.
Interest rate modelsAdaptive, capped, staged, and factory/deployer contracts.
PartnerVault partner manager and wrapper contracts.
Tranche and tokensTranche share token and supporting types/libraries.

Events

Events are contract or service records that say something happened. Torq uses events and snapshots so projectors can update Postgres.

Examples:

  • vault deposit or redemption activity
  • borrow, repay, collateral, or liquidation activity
  • oracle or NAV updates
  • role, permission, or timelock activity
  • market and vault configuration changes

Indexers

The indexer observes state, then projectors write deterministic current rows. A deterministic projector should give the same answer when replayed over the same inputs.

Why this matters: if every workspace uses the same projected rows, the lender, borrower, operator, and auditor can discuss one state instead of comparing different screens.

Truth path

Shared protocol state has one route into the product

Chain

V2 events and state

Indexer

Ingestion and snapshots

Projector

Domain-owned derivation

Postgres

Canonical app truth

API

Served read model

Workspace

Role-specific view

GraphQL

GraphQL is the API language Torq uses for many read and operator surfaces. In Torq, GraphQL is not the root truth source for shared protocol fields. It is a serving layer over Postgres.

Background jobs

Job familyPurpose
Snapshot indexingKeeps projected state current.
Live-feed relayMoves external feed data into supported paths.
Contract verificationTracks deployed contract verification state.
Workspace message expiryMaintains message lifecycle.
AI allocatorSupports allocator assistance where configured.
Projection repair or follow-upHelps reconcile pending tracked mutations.

File-size and release checks

The web app has a file-size budget and Preline/design-system gates for frontend runtime work. The manual documents these as operator/developer fields because docs and UI can otherwise drift away from the actual product.

For reviewers

Use Generated Source Map and Coverage Report for the current route, surface, action, API, schema, contract, accounting, and governance evidence used by this manual.

On this page