# How To Build Your First App with AI - Lesson 8 (cloud functions)

Source: https://www.youtube.com/watch?v=wlWcUVtT76s
Recap page: https://rapidrecap.app/video/wlWcUVtT76s
Generated: 2025-12-21T15:33:46.476+00:00

---
## Quick Overview

The video explains fundamental concepts for building scalable cloud functions, focusing on CRUD operations, timeouts (defaulting to 120 seconds, but shorter is better), memory allocation, handling HTTP/PubSub triggers, and local redeployment, emphasizing that backend logic should be handled server-side while the frontend manages UI feedback like loading states and errors.

**Key Points:**
- Cloud functions are deployed services that execute code based on events (like HTTP requests or Pub/Sub messages), running on a server (like Cloud Run) rather than the client.
- The core operations for functions are CRUD (Create, Read, Update, Delete), demonstrated by creating and deleting projects in the platform.
- Functions have timeouts, defaulting to 120 seconds (or 2 minutes), which is an upper limit; shorter timeouts are better for performance and cost efficiency.
- When a user action triggers a function, the UI should show a loading state (e.g., a spinner) until the backend returns a response or times out, ensuring the user is never left guessing.
- To prevent spam and abuse, rate limiting per tier (e.g., 5 requests/minute for free users) and UI debouncing are crucial to manage invocation volume.
- The AI handles complex logic like image moderation and data point association, meaning the front end should only handle UI state changes (loading, errors) and not the core business logic.
- The speaker recommends using the latest function generation (Gen 2) for better infrastructure and features like custom memory allocation.

![Screenshot at 08:08: The whiteboard illustrates the required separation of concerns: the frontend \(F\) handles UI feedback like timeouts \(120 seconds upper limit\) and errors, while the backend \(B\) handles the actual heavy lifting logic like CRUD operations and data persistence.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-08-08.jpg)

**Context:** This video is the eighth lesson in an ongoing series explaining how to build scalable backend services using cloud functions (likely Google Cloud Functions/Firebase Functions) integrated with an AI platform (Thumio). The presenter explains best practices for structuring and managing these serverless functions, covering topics like operational patterns (CRUD), resource management (timeouts, memory), trigger types (HTTP, Pub/Sub), and deployment strategies.

## Detailed Analysis

The tutorial focuses on best practices for developing scalable cloud functions, dividing the concepts into four main areas: CRUD, Timeouts, Memory, and Trigger types (HTTP/PubSub/On Listen). The presenter stresses that functions should be highly scalable and cost-effective. Regarding Timeouts, functions have a default upper limit of 120 seconds (2 minutes), but shorter durations are preferred for better performance and cost management; if the function exceeds this, it throws an error. The AI model itself (Gemini in this case) is used for heavy lifting, such as image moderation during project creation, which is why developers should aim for minimal custom logic in the function code itself, letting the AI handle complex data processing. The UI must always reflect the backend state, showing loading indicators during long operations and displaying clear errors if timeouts or other issues occur. Furthermore, robust spam prevention mechanisms like rate limiting per tier (e.g., 5 requests per minute for free users) and UI debouncing are essential to protect the backend from abuse, especially when users rapidly trigger actions like editing settings or creating/deleting resources. The speaker also briefly touches on Firebase pricing and the benefits of using newer function generations (Gen 2) for better infrastructure.

### Function 101

- CRUD
- Timeouts
- Memory
- HTTP / Pub Sub / On Listen
- redeploy local

### UI + Function

- UI matches timeout
- UI for all errors
- never handle logic

### Stop Spam

- Rate limit by tier
- Debounce in UI
- all data points user can access

### W Tips

- Delete account
- shorter duration better
- AI api handles all value / no custom work

![Screenshot at 00:00: The video begins showing the project dashboard within the Thumio AI Thumbnail Editor interface.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-00-00.jpg)
![Screenshot at 00:19: The presenter opens the 'Library' panel displaying various template styles available for use in thumbnail creation.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-00-19.jpg)
![Screenshot at 02:11: A diagram illustrating the concept of a function running on a server \(represented by a server rack in a field\) rather than locally.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-02-11.jpg)
![Screenshot at 02:58: The 'Function 101' slide outlines the core topics: CRUD, Timeouts, Memory, HTTP/PubSub/On Listen, and local redeployment.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-02-58.jpg)
![Screenshot at 04:19: The local Firebase Emulator Suite logs show successful execution of the 'ai-centrail-createProject' function, including verification and content moderation checks.](https://ss.rapidrecap.app/screens/wlWcUVtT76s/00-04-19.jpg)
