Chapter 2
dApp Architecture
A dApp spans four layers: smart contracts as the source of truth, a frontend for user interaction, indexers for efficient historical reads, and decentralized storage for metadata and assets. Not everything belongs on chain — good design puts trust-critical logic on chain and everything else off.
On chain: balances, ownership, swaps, and votes — anything requiring trustless verification. Contracts are expensive and public, so minimize storage and computation. Off chain: UI hosting, images, analytics, and cached API responses.
The design principle is simple: put the minimum on chain for trust guarantees; keep everything else off chain for speed and cost. Verify critical paths on chain; treat off-chain data as convenience with a fallback to direct reads.