TL;DR: You used firebase_admin before initializing it. Call firebase_admin.initialize_app(cred) once at startup, before any auth/db/storage calls. Order matters.

```text
ValueError: The default Firebase app does not exist. Make sure to initialize the SDK by calling initialize_app().
```

## Fix it

1. At the top of your entrypoint, before any firebase_admin usage: import firebase_admin; from firebase_admin import credentials; cred = credentials.Certificate('[path-to-key].json'); firebase_admin.initialize_app(cred). Expected: no error.
2. If you already call it, check order: the failing line runs before initialize_app. Move init to the very top. Expected: fixed.
3. Verify: python -c "import firebase_admin; firebase_admin.initialize_app(); print(firebase_admin.get_app().name)". Expected: [DEFAULT].
4. For tests, initialize once per process; a second initialize_app() without a name raises a duplicate-app error.

## When this applies
- Any firebase_admin call raises this exact ValueError.

## When it doesn't
- The error is about the certificate or key file: credential problem, different fix.
- You need multiple projects: use initialize_app(cred, name='[name]') and get_app('[name]').

## Compatibility
- firebase-admin 4.x/5.x/6.x.

## Why it happens
firebase_admin keeps a registry of named apps; the default app must exist before module-level helpers (auth, db) can resolve it. Importing the submodules does not initialize anything.

## Edge cases
- In Cloud Functions, initialize at module scope, not inside the handler, to reuse across invocations.
- ApplicationDefault() credential works on GCP without a key file.
