- Purpose: Gate user data per account; drive owner-only actions.
- Implemented: Email/password auth; route guards via
onAuthStateChanged; Navbar avatar and sign-out. - Where:
react/src/components/ProtectecRoutes.jsx,react/src/components/Navbar.jsx, Login/Register pages. - Learnings/Challenges: Centralize guards; avoid UI flash on auth change; auth state drives
users/{uid}/…paths.
- Purpose: Source of truth for projects, logs, and public feed.
- Data model:
users/{uid}/projects/{projectId}withlogs/;publicPosts/{projectId}for Explore. - Implemented:
onSnapshotrealtime updates;serverTimestamp; batch delete logs on project delete. - Learnings/Challenges: Owner vs viewer access; resolve public owner via
publicPosts(uid+projectId).
- Purpose: Enforce per-user ownership; allow public read for shared posts.
- Implemented: Owner-only writes under
users/{uid}; authenticated reads; global read onpublicPostswith owner-only writes. - Where:
firestore.rules. - Learnings/Challenges: Nesting (
projects,logs) with the same owner rule; validate write identity on public docs.
- Purpose: Store project cover and log images.
- Implemented: Upload helpers set contentType; save
imageURL+imagePathfor cleanup. - Delete flow: Removes all log images and project image when deleting a project.
- Learnings/Challenges: CORS confusion early; always persist exact storage paths; size limits in rules (10MB).
- Purpose: Serverless logic for plan generation and reminders (blueprint).
- Implemented: Callable
generatePlanreturns deterministic 5-step plans; client calls viahttpsCallable. - Where:
functions/src/index.ts, client utilreact/src/lib/ai.ts. - Learnings/Challenges: Prefer callable to avoid CORS; keep demo logic deterministic; ensure APIs enabled during deploy.
- Purpose: Deploy the SPA reliably.
- Implemented: Vite build served from
react/dist; SPA rewrites to/index.html; predeploy builds the app. - Where:
firebase.json("public":react/dist, predeploy),react/package.jsonscripts. - Learnings/Challenges: Initially served
/publicplaceholder; point Hosting to build output and keep rewrites minimal.
- Purpose: Resilient UX with intermittent connectivity and dev network quirks.
- Implemented:
enableIndexedDbPersistence(db);initializeFirestorewithexperimentalAutoDetectLongPolling. - Where:
react/src/firebase.js. - Learnings/Challenges: Persistence + long‑polling improves reliability for local/dev and flaky networks.
- Purpose: Share selected projects publicly, keep private data under user paths.
- Implemented:
publicPosts/{projectId}stores{ uid, projectId, title, hobby, imageURL, createdAt }; Explore lists these. - Detail view: Resolves owner via
publicPostsand loadsusers/{ownerUid}/projects/{projectId}; read‑only for viewers. - Learnings/Challenges: Ensure
projectIdis saved inpublicPostsfor robust deep-links; legacy posts may need re-share.
- Purpose: Convert projects into 5 actionable milestones with progress tracking.
- Implemented: Normalize any AI output to exactly 5 steps; persist on “Suggest Plan”; interactive progress bar; viewer read‑only.
- Where:
react/src/lib/ai.ts,react/src/components/PlanProgress.jsx,react/src/pages/ProjectDetail.jsx. - Learnings/Challenges: Normalize at edges; avoid placeholder-only plans; keep one source of truth in Firestore.
- Purpose: Learn Firebase by building an end‑to‑end app combining Auth, Firestore, Storage, Functions, Hosting.
- What worked: Realtime snapshots; clean per-user data model; owner-only controls; persisted progress.
- Challenges: Hosting output path; callable vs HTTP (CORS); public→private owner resolution; robust media cleanup.
- Takeaways: Model data around ownership; persist file paths; use callable functions; enable offline persistence; build then host.