Exercise 1: Two Write Paths, One Right Choice — Possible Solution ==================================================================== THE TWO WAYS TO WRITE ------------------------------ Per this chapter, a Firestore write can happen either as a direct client write - the browser's own Firestore SDK writing straight to the database with no server code involved at all - or via a Cloud Function, where the client calls a function that performs the write on its behalf, server-side. WHY DIRECT-CLIENT-WRITE IS RIGHT FOR ADDING AN ITEM ------------------------------ The chapter lists three genuine reasons a Cloud Function write would be better: needing elevated privilege the client shouldn't have, needing a value computed or verified server-side because it can't be trusted from the client, or needing the write to happen atomically alongside another side effect. None of these apply to adding a Pantry Item - there's no privileged operation involved, nothing about the item's data needs server-side verification, and there's no coupled side effect (like a notification or audit log) that must succeed or fail together with the write. Since none of the genuine reasons for a Cloud Function write apply, the simpler, lower-latency direct-client-write path is the correct choice here. WHY THIS WORKS AS AN ANSWER ------------------------------ It correctly names both write paths, correctly lists the chapter's own three scenarios where a Cloud Function write would be preferred, and correctly explains that the add-item flow matches none of those scenarios, which is exactly why the chapter concludes direct-client-write is the right choice rather than leaving the decision ambiguous.