``` ┌────────────────────────────────────────────────────────────────┐ │ CLIENT (Browser) │ │ │ │ ┌────────────────────────────────────────────────────────┐ │ │ │ React Application (Vite) │ │ │ │ │ │ │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ │ │ Public │ │ Auth │ │ Dashboard │ │ │ │ │ │ Portal │ │ Pages │ │ (Owner) │ │ │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ │ │ │ │ │ │ │ ┌──────────────────────────────────────────────────┐ │ │ │ │ │ React Router (Navigation) │ │ │ │ │ └──────────────────────────────────────────────────┘ │ │ │ │ │ │ │ │ ┌──────────────────────────────────────────────────┐ │ │ │ │ │ Auth Context (Global State) │ │ │ │ │ └──────────────────────────────────────────────────┘ │ │ │ │ │ │ │ │ ┌──────────────────────────────────────────────────┐ │ │ │ │ │ Service Layer │ │ │ │ │ │ ┌──────────┐ ┌──────────┐ ┌────────────────┐ │ │ │ │ │ │ │ Auth │ │ Room │ │ Storage │ │ │ │ │ │ │ │ Service │ │ Service │ │ Service │ │ │ │ │ │ │ └──────────┘ └──────────┘ └────────────────┘ │ │ │ │ │ └──────────────────────────────────────────────────┘ │ │ │ │ │ │ │ └────────────────────────────────────────────────────────┘ │ └────────────────────────────────────────────────────────────────┘ │ │ HTTPS ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Firebase Backend (Serverless) │ │ │ │ ┌──────────────────┐ ┌──────────────────┐ ┌──────────────┐ │ │ │ Authentication │ │ Firestore │ │ Storage │ │ │ │ │ │ Database │ │ (Images) │ │ │ │ • Email/Pass │ │ │ │ │ │ │ │ • Google OAuth │ │ Collection: │ │ /rooms/ │ │ │ │ • JWT Tokens │ │ - rooms │ │ {id}/ │ │ │ │ │ │ │ │ *.jpg │ │ │ └──────────────────┘ └──────────────────┘ └──────────────┘ │ │ │ │ ┌────────────────────────────────────────────────────────────┐ │ │ │ Security Rules Engine │ │ │ │ • Firestore Rules • Storage Rules │ │ │ └────────────────────────────────────────────────────────────┘ │ └─────────────────────────────────────────────────────────────────┘ ```
``` ┌─────────┐ │ User │ └────┬────┘ │ ├─ Visit /login │ ▼ ┌─────────────────┐ │ Login Page │ └────┬────┬───────┘ │ │ │ └─ Google OAuth │ │ │ ▼ │ ┌──────────────────┐ │ │ Google Sign-In │ │ │ Popup │ │ └────┬─────────────┘ │ │ ├─────────┴─ Firebase Auth │ ▼ ┌──────────────────┐ │ Auth Context │ │ (Sets user state)│ └────┬─────────────┘ │ ▼ ┌──────────────────┐ │ Protected Route │ │ Redirect to │ │ /dashboard │ └──────────────────┘ ```
``` ┌────────────┐ │ Owner │ │ Dashboard │ └─────┬──────┘ │ ├─ Click "Add New Room" │ ▼ ┌─────────────────┐ │ Room Form │ │ Modal │ └────┬────────────┘ │ ├─ Fill form data ├─ Select images ├─ Submit │ ▼ ┌─────────────────────┐ │ Room Service │ │ createRoom() │ └────┬────────────────┘ │ ├─ 1. Create Firestore doc │ (get roomId) │ ├─ 2. Upload images │ to Storage │ (/rooms/{roomId}/) │ ├─ 3. Update Firestore doc │ with image URLs │ ▼ ┌─────────────────────┐ │ Success Toast │ │ Refresh Room List │ └─────────────────────┘ ```
``` ┌──────────────┐ │ Public User │ └──────┬───────┘ │ ├─ Visit /search │ ▼ ┌──────────────────┐ │ Search Page │ │ - Search Bar │ │ - Filters │ └────┬─────────────┘ │ ├─ Enter search criteria ├─ Apply filters │ ▼ ┌──────────────────────┐ │ useRooms Hook │ │ searchRooms() │ └────┬─────────────────┘ │ ▼ ┌──────────────────────┐ │ Room Service │ │ - Fetch from │ │ Firestore │ │ - Apply client-side │ │ filtering │ └────┬─────────────────┘ │ ▼ ┌──────────────────────┐ │ Room Grid │ │ Display results │ └────┬─────────────────┘ │ ├─ Click room card │ ▼ ┌──────────────────────┐ │ Room Detail Modal │ │ - Image carousel │ │ - Full details │ │ - Contact owner │ └──────────────────────┘ ```
``` App (AuthProvider) │ └── RouterProvider │ └── Root (Layout) ├── Header (Navigation) │ ├── Outlet (Page Content) │ │ │ ├── Home │ │ ├── HeroSection │ │ ├── AboutSection │ │ └── FeaturesSection │ │ │ ├── SearchRooms │ │ ├── SearchBar │ │ ├── FilterPanel │ │ ├── RoomGrid │ │ │ └── RoomCard (multiple) │ │ └── RoomDetailModal │ │ │ ├── Login │ │ ├── LoginForm │ │ └── GoogleSignIn │ │ │ ├── Dashboard (Protected) │ │ ├── Stats Cards │ │ ├── RoomList │ │ │ └── Room Items │ │ └── RoomForm (Modal) │ │ └── ImageUploader │ │ │ └── NotFound │ └── Footer ```
``` ┌──────────────────────────────────────────────────────┐ │ Global State (Context) │ │ │ │ AuthContext │ │ ├── user: User | null │ │ ├── loading: boolean │ │ └── onAuthStateChanged listener │ └──────────────────────────────────────────────────────┘ │ │ Provides to ▼ ┌──────────────────────────────────────────────────────┐ │ Component State (Local) │ │ │ │ useState hooks for: │ │ ├── Form inputs │ │ ├── Modal visibility │ │ ├── Loading states │ │ └── Error messages │ └──────────────────────────────────────────────────────┘ │ │ Calls ▼ ┌──────────────────────────────────────────────────────┐ │ Custom Hooks │ │ │ │ useRooms(filters?) │ │ ├── rooms: Room[] │ │ ├── loading: boolean │ │ ├── error: string | null │ │ └── refetch() │ │ │ │ useOwnerRooms(ownerId) │ │ ├── rooms: Room[] │ │ ├── loading: boolean │ │ └── refetch() │ └──────────────────────────────────────────────────────┘ │ │ Uses ▼ ┌──────────────────────────────────────────────────────┐ │ Service Layer │ │ │ │ authService │ │ ├── login() │ │ ├── register() │ │ ├── loginWithGoogle() │ │ └── logout() │ │ │ │ roomService │ │ ├── createRoom() │ │ ├── updateRoom() │ │ ├── deleteRoom() │ │ ├── getAllRooms() │ │ ├── searchRooms() │ │ └── getRoomsByOwner() │ │ │ │ storageService │ │ ├── uploadImages() │ │ └── deleteImage() │ └──────────────────────────────────────────────────────┘ │ │ Interacts with ▼ ┌──────────────────────────────────────────────────────┐ │ Firebase SDK │ │ │ │ ├── firebase/auth │ │ ├── firebase/firestore │ │ └── firebase/storage │ └──────────────────────────────────────────────────────┘ ```
```
- User Login/Register ↓
- Firebase Auth validates credentials ↓
- JWT token generated ↓
- Token stored in browser (httpOnly cookie) ↓
- Token sent with each request ↓
- Firebase SDK validates token ↓
- Access granted/denied based on rules ```
```javascript // Read: Anyone can view rooms allow read: if true;
// Create: Must be authenticated + ownerId matches auth UID allow create: if request.auth != null && request.resource.data.ownerId == request.auth.uid;
// Update/Delete: Must be the owner allow update, delete: if request.auth != null && resource.data.ownerId == request.auth.uid; ```
```javascript // Read: Anyone can view images allow read: if true;
// Write: Must be authenticated allow write: if request.auth != null; ```
- React Router automatically splits routes
- Each page is a separate bundle
- Loaded on-demand when user navigates
- Firebase Storage CDN delivery
- Automatic format optimization
- Lazy loading with ImageWithFallback component
- Firestore compound indexes (auto-created)
- Client-side caching via React state
- Pagination ready (not implemented by default)
- Vite's optimized production builds
- Tree-shaking removes unused code
- Minification and compression
- Good for: 1-10K users, 100-1K rooms
- Limitations: Client-side filtering, no pagination
For 10K+ users:
- Implement pagination (Firestore cursors)
- Add Algolia for advanced search
- Implement Redis caching layer
- Use Cloud Functions for complex operations
For 100K+ users:
- Consider migrating to Cloud Firestore collections with better indexing
- Implement CDN for static assets
- Add load balancing
- Implement rate limiting
For 1M+ users:
- Consider microservices architecture
- Separate read/write databases
- Implement event-driven architecture
- Add analytics and monitoring
- ✅ Serverless (no backend management)
- ✅ Real-time capabilities
- ✅ Built-in authentication
- ✅ Free tier generous enough for MVP
- ✅ Scales automatically
- ❌ Vendor lock-in concern
- ❌ Complex queries limited
- ✅ Component reusability
- ✅ Large ecosystem
- ✅ Virtual DOM performance
- ✅ TypeScript support
- ✅ Great developer experience
- ✅ Fast HMR (Hot Module Replacement)
- ✅ Optimized production builds
- ✅ Modern ESM support
- ✅ Better than CRA
- ✅ Utility-first approach
- ✅ Consistent design system
- ✅ Small production bundle
- ✅ No runtime CSS-in-JS overhead
- ✅ Easy responsive design
``` User Request ↓ Firebase CDN (Edge locations worldwide) ↓ Serves cached HTML/CSS/JS ↓ Browser executes React app ↓ Calls Firebase APIs (Auth, Firestore, Storage) ```
``` User Request ↓ Vercel/Netlify Edge Network ↓ Serves static files from CDN ↓ Browser executes React app ↓ Calls Firebase APIs (same as above) ```
-
Firebase Analytics
- User engagement metrics
- Screen view tracking
- Custom events (room views, searches)
-
Performance Monitoring
- Page load times
- API response times
- Error tracking
-
Crashlytics (for mobile apps)
- Crash reports
- User diagnostics
-
Cloud Monitoring
- Firestore usage
- Storage bandwidth
- Authentication metrics
- Algolia integration for full-text search
- Geographic search with maps
- Fuzzy matching for typos
- Live chat between users and owners
- Real-time availability updates
- Push notifications
- Payment processing (Stripe)
- Booking system with calendar
- Review and rating system
- Admin dashboard
- React Native mobile app
- Shared codebase with web
- Push notifications
- Offline support
Architecture Version: 1.0
Last Updated: February 2026
Maintained By: Development Team