.md
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
# Firebase Configuration - AI Study Assistant
|
||||
|
||||
> ⚠️ **ATUALIZADO**: Este documento foi corrigido para refletir a configuração REAL do projeto.
|
||||
>
|
||||
> **Notas Importantes:**
|
||||
> - ❌ Cloud Functions: NÃO implementado
|
||||
> - ❌ Performance Monitoring: NÃO implementado
|
||||
> - ❌ Remote Config: NÃO implementado
|
||||
> - ❌ Roles admin/super_admin: NÃO implementados (apenas student/teacher)
|
||||
> - ✅ Estrutura real: users, materials, contentChunks, quizzes, classes, enrollments, userChats
|
||||
|
||||
## 🔥 COMPLETE FIREBASE SETUP GUIDE
|
||||
|
||||
---
|
||||
|
||||
## 📋 OVERVIEW
|
||||
|
||||
This document provides comprehensive instructions for setting up Firebase for the AI Study Assistant project, including authentication, database, storage, cloud functions, and security configurations.
|
||||
This document provides instructions for setting up Firebase for the AI Study Assistant project. Note: This is a **Flutter + Firebase BaaS** architecture without a custom backend.
|
||||
|
||||
---
|
||||
|
||||
@@ -32,15 +41,18 @@ This document provides comprehensive instructions for setting up Firebase for th
|
||||
|
||||
### 1.2 Enable Required Services
|
||||
|
||||
#### Firebase Services to Enable:
|
||||
#### Firebase Services Actually Used:
|
||||
- ✅ Firebase Authentication
|
||||
- ✅ Cloud Firestore
|
||||
- ✅ Cloud Storage
|
||||
- ✅ Cloud Functions
|
||||
- ✅ Firebase Analytics
|
||||
- ✅ Firebase Crashlytics
|
||||
- ✅ Firebase Performance Monitoring
|
||||
- ✅ Firebase Remote Config
|
||||
- ✅ Firebase Cloud Messaging
|
||||
|
||||
#### Firebase Services NOT Used:
|
||||
- ❌ Cloud Functions (not needed - logic in Flutter)
|
||||
- ❌ Firebase Performance Monitoring (not implemented)
|
||||
- ❌ Firebase Remote Config (not implemented)
|
||||
|
||||
#### Enable Commands:
|
||||
```bash
|
||||
@@ -53,10 +65,9 @@ firebase firestore:databases:create
|
||||
# Enable Storage
|
||||
firebase storage:buckets:create teachit-content
|
||||
|
||||
# Enable Functions
|
||||
firebase functions:config:set
|
||||
|
||||
# Enable Analytics (automatically enabled)
|
||||
|
||||
# Note: Cloud Functions not needed
|
||||
```
|
||||
|
||||
---
|
||||
@@ -105,17 +116,23 @@ firebase functions:config:set
|
||||
|
||||
### 2.2 User Management Configuration
|
||||
|
||||
#### Custom Claims Setup:
|
||||
```javascript
|
||||
// Cloud Function to set custom claims
|
||||
exports.setCustomClaims = functions.auth.user().onCreate(async (user) => {
|
||||
const customClaims = {
|
||||
role: 'student', // Default role
|
||||
schoolId: 'default',
|
||||
permissions: ['basic_access']
|
||||
};
|
||||
|
||||
await admin.auth().setCustomUserClaims(user.uid, customClaims);
|
||||
#### User Roles (Only 2 implemented):
|
||||
```dart
|
||||
// lib/core/services/auth_service.dart
|
||||
class AuthService {
|
||||
static const String studentRole = 'student';
|
||||
static const String teacherRole = 'teacher';
|
||||
// ❌ adminRole - NOT IMPLEMENTED
|
||||
// ❌ superAdminRole - NOT IMPLEMENTED
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** Role assignment is done client-side during signup:
|
||||
```dart
|
||||
await FirebaseFirestore.instance.collection('users').doc(user.uid).set({
|
||||
'role': selectedRole, // 'student' or 'teacher'
|
||||
'email': user.email,
|
||||
'createdAt': FieldValue.serverTimestamp(),
|
||||
});
|
||||
```
|
||||
|
||||
@@ -131,17 +148,25 @@ exports.setCustomClaims = functions.auth.user().onCreate(async (user) => {
|
||||
3. Choose location (e.g., `europe-west1`)
|
||||
4. Set up security rules
|
||||
|
||||
#### Database Structure:
|
||||
#### Actual Database Structure:
|
||||
```javascript
|
||||
// Collections Structure
|
||||
schools/{schoolId}
|
||||
├── users/{userId}
|
||||
├── learningStates/{studentId}
|
||||
├── contentChunks/{chunkId}
|
||||
├── quizzes/{quizId}
|
||||
├── quizAttempts/{attemptId}
|
||||
├── interactions/{interactionId}
|
||||
└── auditLogs/{logId}
|
||||
// Collections Structure (as implemented in code)
|
||||
|
||||
// Top-level collections:
|
||||
users/{userId} // User profiles with role
|
||||
schools/{schoolId} // Schools/institutions
|
||||
materials/{materialId} // Teacher uploaded content
|
||||
contentChunks/{chunkId} // Text chunks with mock embeddings
|
||||
quizzes/{quizId} // Quiz definitions
|
||||
classes/{classId} // Teacher-created classes
|
||||
enrollments/{enrollmentId} // Student class memberships
|
||||
userChats/{userId}/conversations/{convId}/messages/{msgId} // Chat history
|
||||
|
||||
// Collections NOT implemented:
|
||||
// ❌ learningStates/{studentId} - Not in codebase
|
||||
// ❌ quizAttempts/{attemptId} - Not implemented
|
||||
// ❌ interactions/{interactionId} - Replaced by userChats subcollection
|
||||
// ❌ auditLogs/{logId} - Not implemented
|
||||
```
|
||||
|
||||
### 3.2 Security Rules
|
||||
|
||||
Reference in New Issue
Block a user