Why backends exist in Web3 — API gateway design
Debunking the 'blockchain is my backend' myth. Exposing Express proxy gateways to secure Pinata keys and run off-chain validations.

When beginners start building dApps, they often hear the phrase: "The blockchain is a serverless backend."
This leads to a dangerous architectural assumption: that a Web3 application should only consist of a Solidity contract and a React frontend, with no middle tier.
If you build an app this way, you will inevitably hit three massive walls:
- Credentials Leakage: How do you communicate with third-party APIs (like Pinata/IPFS or custom database services) without exposing secret keys in the browser bundle?
- Computational Limits: How do you run computationally heavy or private logic (like anti-abuse filters or machine learning moderation) that cannot run on a decentralized validator node?
- Sybil/Spam Protection: How do you prevent bots from spamming your contract transactions?
Let's look at why Socio3 V2 requires a dedicated Express backend proxy layer and how to design a secure API gateway.
1. The React Key Leak (The Danger)
In Socio3 V1, we uploaded files to IPFS directly from the browser using the Pinata SDK:
Since frontend JavaScript is parsed and executed directly on the user's browser, anyone can open their browser's dev tools, look at the network requests or search the loaded bundle, and extract your Pinata API keys. Within hours, spammers can use your keys to host gigabytes of illegal material on your account.
2. The API Gateway Proxy Pattern (The Solution)
To fix this vulnerability, Socio3 V2 routes all file uploads through an Express backend proxy. The frontend communicates with the backend, which forwards the request to Pinata using server-side environment variables.
Here is the implementation:
Now, the client never sees the Pinata API key. They only see their own upload payload.
3. API Gateway Jobs in Web3
In a production Web3 system, the backend's jobs include:
| Task | Where it runs | Why? | |------|---------------|------| | Cryptography | On-Chain (EVM) | Irreversible state validation and token rules. | | API Proxies | Express Server | Secure API credential management. | | Caching | Redis / The Graph | Instant loads without RPC rate limits. | | Heavy Processing | Express Server | Image compression, virus scanning, NSFW filtering. |
"Decentralized" does not mean "serverless." Every major dApp (including Uniswap, OpenSea, and Blur) uses traditional backend servers to proxy assets, run indexers, route transactions, and protect keys. The blockchain is the notary, not the host.
If a user uploads an inappropriate (NSFW) image to Socio3, where should the detection logic run? In the smart contract, on the client browser, or on the Express proxy backend? Design the pipeline and write your reasoning.
Was this lesson helpful?
Let us know what you think of this specification. (submitting anonymously)
