- Open Firebase Console.
- Create a project for ClassWire.
- Open
Project settings. - Copy the
Project ID.
- Open
Build -> Firestore Database. - Click
Create database. - Start in production mode if you want locked-down rules from day one.
- Pick the closest region.
- Open
Project settings -> Service accounts. - Click
Generate new private key. - Download the JSON file.
- Either:
- Save its path in
FIREBASE_SERVICE_ACCOUNT_PATH, or - Paste the full JSON into
FIREBASE_SERVICE_ACCOUNT_JSON.
- Save its path in
ClassWire writes these collections automatically:
usersgmail_tokensuser_settingstimetable_cache
You do not need to create them by hand.
Add these to backend/.env:
FLASK_SECRET_KEY=replace-me
TOKEN_ENCRYPTION_KEY=replace-me-with-a-different-long-random-value
PUBLIC_BACKEND_URL=http://localhost:5000
FRONTEND_ORIGINS=http://localhost:5173
FIREBASE_PROJECT_ID=your-project-id
FIREBASE_SERVICE_ACCOUNT_PATH=C:\path\to\service-account.json
CLIENT_SECRET_JSON={"web":{...}}
AUTOMATION_SECRET=replace-me
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USERNAME=your-sender@gmail.com
SMTP_PASSWORD=your-app-password
SMTP_FROM_NAME=ClassWire
TZ=Asia/Karachi
GMAIL_QUERY_BASE=subject:("Class Schedule" OR schedule) in:inbox
CHECK_HOUR_LOCAL=20
CHECK_MINUTE_LOCAL=0
NEXT_DAY_AVAILABLE_HOUR=17
NEWER_THAN_DAYS=2If only your Flask backend should access Firestore directly, keep the client app out of Firestore entirely and use strict rules like:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
This works because the backend uses the Firebase Admin SDK, which bypasses client security rules.
The backend encrypts Gmail OAuth payloads before storing them in gmail_tokens. Keep TOKEN_ENCRYPTION_KEY stable; changing it invalidates previously stored tokens.