# Serverless backend

### Serverless APIs with Cloudflare Workers

GoPlausible leverages Cloudflare Workers to provide a scalable and efficient serverless API infrastructure. By utilizing Cloudflare’s global edge network, GoPlausible APIs operate with ultra-low latency, ensuring that users experience rapid response times regardless of their location. The serverless nature of Cloudflare Workers eliminates the need for managing traditional server infrastructure, allowing for automatic scaling and fault tolerance out of the box. This setup enhances security, reduces operational costs, and enables seamless integrations across the Algorand blockchain, making it an ideal choice for decentralized applications built on the Plausible protocol.

#### GoPlausible dApp Architecture

1. **Frontend - GoPlausible dApp (SPA, PWA):**
   * The GoPlausible frontend is a Single Page Application (SPA) and Progressive Web App (PWA), providing a seamless user experience across devices.
   * The dApp directly communicates with two key components:
     * **Cloudflare Worker API**: Handles serverless API requests for backend functionality.
     * **Nodlely.io Service Endpoints**: Connects directly with the Algorand blockchain to interact with on-chain data and perform transactions.
2. **Backend - Cloudflare Worker API:**
   * Serverless APIs are hosted on Cloudflare Workers to scale and manage backend operations.
   * For each user interaction, the Cloudflare Worker API simultaneously:
     * **Calls the GoPlausible Main Contract**: This is done in parallel to user requests to maintain control, provide attestations, and verify contract logic.
     * **Groups Transactions (TXNs)**: Ensures that user requests and attestation logic are within the same transaction group to ensure atomicity and correctness.
3. **Algorand Blockchain:**
   * **GoPlausible Main Contract**: This smart contract is responsible for managing the global state and validating the interactions that take place through the API and frontend. It ensures that every operation is attested and properly tracked.
   * **PLAUS Contract**: A separate smart contract is created for each PLAUS issuance (Verifiable Credential Issuance). Each PLAUS contract contains the logic to assess claims made for that particular proof, enabling flexible, decentralized validation mechanisms.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.goplausible.xyz/technical-documentation/serverless-backend.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
