Firebase to Backend-as-a-Service (BaaS) od Google. Dla MVP: najszybszy sposób na backend bez pisania API. Auth, database, storage, functions — wszystko out of the box.
Firebase Services dla MVP
1. Authentication
- Email/password, Google, Apple, Facebook login
- Zero backend code
- Security rules built-in
- Setup: 10 minut
2. Cloud Firestore (Database)
- NoSQL document database
- Real-time synchronization
- Offline support
- Auto-scaling
3. Cloud Storage
- File upload/download (images, PDFs, videos)
- CDN built-in
- Security rules
4. Cloud Functions
- Serverless backend logic
- Triggers (onCreate, onUpdate, onDelete)
- HTTP endpoints
- Scheduled tasks (cron)
5. Analytics
- User behavior tracking
- Conversion funnels
- Free, unlimited events
6. Crashlytics
- Crash reporting
- Real-time alerts
- Stack traces
💡 Assadante Stack
Flutter + Firebase to nasz go-to stack dla MVP. Zbudowaliśmy 20+ produktów na tym stacku. Działa, skaluje, jest szybki w development.
Firestore — jak projektować schema
Collections i Documents:
- Collection = folder (np. "users")
- Document = rekord (np. user z id "abc123")
- Subcollection = nested collection (np. "users/abc123/orders")
Best practices:
- Denormalizacja OK (duplikuj dane dla szybkości)
- Unikaj deep nesting (> 2 poziomy)
- Używaj references dla relacji many-to-many
- Batch writes dla consistency
Security Rules
Firestore Security Rules to firewall dla danych:
- Kto może czytać/pisać do kolekcji
- Walidacja danych (typy, długość, format)
- Custom logic (np. tylko owner może edytować)
Przykład: Tylko zalogowani mogą czytać users, tylko owner może edytować swój profil.
Cloud Functions — kiedy używać
Używaj Cloud Functions gdy:
- Potrzebujesz server-side logic (payment processing)
- Scheduled tasks (daily reports, cleanup)
- Triggers (send email on user signup)
- Heavy computation (nie blokuj UI)
Nie używaj gdy: Można zrobić client-side (Firestore queries, simple logic)
Firebase Pricing
Spark Plan (Free):
- 1 GB storage
- 10 GB/month bandwidth
- 50k reads/day, 20k writes/day
- Wystarczy dla MVP (< 1000 users)
Blaze Plan (Pay-as-you-go):
- Free tier included
- Potem płacisz za użycie
- ~$25-100/month dla 10k users
Firebase Alternatives
Supabase: Open-source alternative, PostgreSQL-based
Appwrite: Self-hosted BaaS
AWS Amplify: AWS equivalent
Dla MVP: Firebase najprostszy. Supabase jeśli potrzebujesz SQL.
📝 Zadanie
Stwórz Firebase project. Dodaj Authentication (email/password). Stwórz Firestore collection "users". Napisz Security Rules: tylko zalogowani mogą czytać, tylko owner może edytować swój dokument.