How bumgeunsong/daily-writing-friends works
Project Type and Purpose
• Full-stack, serverless web application (“Daily Writing Friends”)
• Frontend: React + TypeScript SPA built with Vite
• Backend: Firebase BaaS (Authentication, Firestore, Cloud Functions, Hosting, Cloud Messaging)
• Purpose: help users build a daily writing habit with posting, commenting, notifications, and writing history tracking.
Top-Level File Structure and Architectural Clues
• firebase.json / .firebaserc / firestore_schema.txt → Firebase services config, Firestore schema
• functions/ → TypeScript Cloud Functions organized by domain (postings, commentings, replyings, writingHistory, notifications)
• public/ → static assets (manifest, service-worker for push notifications)
• src/ → React app source
• components/ (pages, UI primitives, navigation)
• contexts/ (Auth, Navigation, UI state)
• hooks/ (data fetching, state management, Firebase integrations)
• lib/ (React Query client, util functions)
• firebase.ts / messaging.ts → Firebase client SDK initialization and message handling
• index.html, vite.config.ts, tailwind.config.js → build and styling pipeline
Key Components
A. Frontend (Browser SPA)
• React layers: UI components, Contexts, Hooks
• Client-side Firebase SDKs: Auth, Firestore, Cloud Messaging
• Service Worker for push notifications (public/firebase-messaging-sw.js)
B. Firebase Hosting
• Serves index.html and static assets to users
C. Firebase Authentication
• Manages user sign-up, sign-in, session tokens
D. Cloud Firestore
• Storage of posts, comments, replies, notifications, writing history
• Real-time listeners on collections
E. Cloud Functions (Serverless Backends)
• Triggered by Firestore writes (create/update postings, commentings, replyings)
• Functions for notifications, counters, writing history, batching updates
• messageGenerator.ts + sendMessageOnNotification.ts → push notifications via Firebase Messaging
F. Firebase Cloud Messaging
• Delivers push notifications to the Service Worker in the browser
G. External Monitoring (Sentry / Centry)
• Error / performance monitoring (centry.ts integration)
Relationships and Data Flows
• User browser ↔ Firebase Auth (login, token refresh)
• Browser ↔ Firestore (read/write via React Query & custom hooks)
• Firestore write triggers → Cloud Function event handlers → update Firestore / send messages
• Cloud Function push → Firebase Cloud Messaging → Service Worker → Browser UI (toast notifications)
• Hosting serves SPA assets; SPA bootstraps connections to Auth, Firestore, Messaging
Architectural Patterns and Design Principles
• Serverless / event-driven microservices: each Cloud Function handles a single Firestore trigger or task
• SPA with clear separation of concerns: components / hooks / contexts / utils
• Real-time subscriptions for UI reactivity
• Domain-driven grouping: postings, commentings, replyings, writingHistory, notifications
Detail Level
• Service Worker flow for push notifications
• Real-time Firestore listeners used by React hooks
• Sentry/Centry integration as a side component tied to both client and Cloud Functions for monitoring