⚑ Developer Quick Reference

Essential commands, key files, environment setup, and common gotchas

πŸ’» Common Commands

Start Dev Server
npm start
Starts Angular dev server on port 4202
Production Build
npm run build:prod
Output: dist/solomon-app/browser
Deploy to Firebase
git ship
Merges the branch's pull request; GitHub Actions then tests and deploys
Start Emulators
npm run emulators
Emulator UI at http://localhost:4000
Production Preview
npx ng serve --configuration production --port 4202
Run locally with prod config
Run All Tests
npm run test:all
Browser, rules, functions and end-to-end tests. Run before git ship.
Run Security Rules Tests
npm run test:rules
Runs Firestore + Storage rules tests against local emulator
Deploy only through GitHub Actions: never run firebase deploy or firebase login on a laptop. A merge to main deploys: only functions/** changes run deploy-functions.yml (~2 min), and anything else runs deploy-and-release.yml (~10 min).

πŸ”§ Firebase Configuration

# Project Project ID: solomon-3ead2 Project Number: 756977799377 # Sites App: https://solomon-3ead2.web.app Docs: https://solomon-docs.web.app # Service Account SA: firebase-adminsdk-fbsvc@solomon-3ead2.iam.gserviceaccount.com # Functions Runtime Runtime: Node.js 20

Hosting Targets

Solomon uses dual hosting targets defined in .firebaserc:

  • app β†’ solomon-3ead2 β€” the main Angular application (dist/solomon-app/browser)
  • docs β†’ solomon-docs β€” this documentation site (docs/)

πŸ“‚ Key Files

package.json
Dependencies + npm scripts (Angular 22, Firebase 11)
angular.json
Build config, lazy loading, budget limits
firebase.json
Hosting targets, Firestore/Storage rules, emulators
.firebaserc
Project + target mapping (app + docs)
src/app/app.routes.ts
Route definitions, lazy-loaded, guarded
functions/src/index.ts
Cloud Functions: chat, TTS, session mgmt, Stripe
tests/rules/firestore.test.mjs
Firestore security rules tests (emulator)
tests/rules/storage.test.mjs
Firebase Storage security rules tests (emulator)

Core Services

Service Purpose
AuthServiceSign-in/up, user profiles, role-based access
SessionServiceCRUD for counseling sessions, couples/individual modes
MessageServiceReal-time message stream, sequence ordering
AiServiceWraps Cloud Function chat (5-min timeout, 2-min client)
EncryptionServiceAES-256-GCM encrypt/decrypt for messages
TtsServiceElevenLabs streaming TTS via Cloud Function
CounselorServiceCounselor profiles, annotations, assignments
InviteServiceCouples invite workflow
SubscriptionServiceStripe subscription management
PdfExportServicejsPDF-based session export

πŸ—„οΈ Firestore Collections

Collection Purpose
userProfilesUser identity, denomination, profile context
counselingSessionsSession metadata, participants, status
chatMessagesEncrypted conversation history, sequence-ordered
sessionKeysAES-256-GCM encryption keys per session
sessionInvitesCouples partner invite tokens (7-day expiry)
counselorAnnotationsPastoral notes on AI messages, encrypted
counselorChatsDirect messages between counselor & counselee
counselorApplicationsCounselor approval workflow
counselorSubscriptionsStripe subscription state
sessionGuidedPromptsCounselor-seeded prompts for session openers

πŸ”‘ Environment Variables

# Cloud Run (set via functions/.env in CI, NOT firebase.json secrets[]) ANTHROPIC_API_KEY # Claude API for AI counseling ELEVENLABS_API_KEY # ElevenLabs for TTS voice synthesis STRIPE_SECRET_KEY # Stripe for counselor subscriptions STRIPE_WEBHOOK_SECRET # Stripe webhook verification
Important: Do NOT use secrets: ["ANTHROPIC_API_KEY"] in firebase.json or onCall() β€” this causes deploy-time permission errors. Do NOT use gcloud run services update --update-env-vars β€” it creates a separate revision that gets wiped on the next Firebase deploy. Instead, write secrets to functions/.env in CI before firebase deploy.

⚠️ Common Gotchas

πŸ”’
SSL Certificate Errors on Firebase CLI

Some networks replace Google's certificates, and then Firebase CLI calls fail with certificate errors.

Fix: Point NODE_EXTRA_CA_CERTS at that network's root certificate. Never set NODE_TLS_REJECT_UNAUTHORIZED=0, which turns certificate checks off.
β˜•
Firebase Emulator requires Java 21 in CI

The Firebase Emulator used for security rules tests requires Java 21 with firebase-tools@15.6.0. The default Java version on GitHub Actions runners is insufficient.

Fix: Add actions/setup-java@v4 with distribution: temurin and java-version: "21" before the rules test step in CI.
πŸ”„
auth.currentUser is null on page refresh

Race condition β€” Firebase Auth hasn't restored the session yet when components initialize.

Fix: Check authService.currentUserProfile first, fallback to getUserProfile(auth.currentUser.uid).
πŸ“¦
Get Firebase objects through the injection tokens

Services, guards and components get Firebase with inject(AUTH), inject(FIRESTORE), inject(FUNCTIONS) or inject(STORAGE) from src/app/firebase.ts. Tests replace these tokens with emulator or offline instances. A direct call to getAuth() or getFirestore() in app code would bypass that and reach the live project.

Fix: add a new Firebase service as a token in src/app/firebase.ts and inject it
πŸ“…
Firestore Timestamp in templates

Firebase 11 returns Timestamps, not JS Dates. Angular's | date pipe throws NG02100 on raw Timestamp.

Fix: Add toDate(v: any): Date { return v?.toDate ? v.toDate() : v; } to component and use toDate(field) | date:... in templates.
🚫
firebase.json secrets[] causes permission errors

Using secrets: ["ANTHROPIC_API_KEY"] in firebase.json triggers deploy-time Secret Manager permission errors. Using gcloud run services update creates a revision that gets wiped on next deploy and fails when the old container image is garbage-collected.

Fix: Write secrets to functions/.env in CI before firebase deploy. Firebase 2nd-gen functions natively load .env files.
πŸ“
SCSS imports fail without includePaths

SCSS token imports like @use 'styles/tokens' won't resolve without the include path configured.

Fix: Ensure angular.json has stylePreprocessorOptions: { includePaths: ["src"] }.

πŸ“Š Build Budgets

  • Initial bundle: 1.5 MB warning / 4 MB error
  • Component styles: 15 KB warning / 45 KB error
  • Current initial bundle: ~622 KB (after firebase 12 β†’ 11 downgrade)
↑