Chapter 27 · Production Capstone: Design, Secure, Scale, Search, Recover, and Operate a Firestore Application

Present the Architecture with Measured Cost / Latency, Data-Governance Controls, Known Limits, and Criteria for Choosing Another Database

Present the final architecture with measured evidence, governance, known limits, vendor dependencies, recovery/rollback and explicit criteria for evaluating another database.

Advanced · 180–240 minutesarchitecture review · cost/latency evidence · governance · known limits · exit criteriaNode 22+ · Firebase CLI course baseline 15.30.0 · JS SDK 12.19.0 · Admin SDK 14.4.0 · rules-unit-testing 5.0.2Mandatory capstone demo project + Emulator Suite/no-cost · managed production verification explicitly separatedLast reviewed: 17 September 2026

1. Architecture review: the deliverable is evidence plus limits

The final AtlasMart artifact is not a diagram labeled “serverless, secure, scalable.” It is a decision package that another engineer can challenge: journeys, data contracts, query/index contracts, trust boundaries, SLO evidence, cost assumptions, recovery drill, deployment rollback, governance inventory and a list of conditions under which Firestore is no longer the right primary store.

Learning outcomes
  • Present the chosen architecture with evidence and explicit uncertainty.
  • Separate measured local results, managed production evidence and unverified assumptions.
  • Map governance controls across primary data, logs, exports/backups and deletion workflows.
  • Maintain a known-limit/vendor-dependency register instead of hiding constraints.
  • Define exit criteria for another database without declaring Firestore universally good or bad.
Execution and safety note

Use the Emulator Suite, a Firebase demo project, or an isolated test project for destructive, security-sensitive, billing-sensitive, migration, backup/restore, or write-heavy exercises unless the lesson explicitly marks managed verification as required. Treat shown output as expected evidence unless it is explicitly identified as captured output, and re-check current Firebase/Google Cloud edition, mode, quota, pricing, and security documentation before production execution.

Chapter 27 reproducibility baseline · reviewed 17 September 2026

AtlasMart keeps project ID demo-atlasmart-firestore, Standard edition / Native mode / Core operations, database (default), Node.js 22+, Firebase CLI course baseline 15.30.0, Firebase JavaScript SDK 12.19.0, Firebase Admin Node SDK 14.4.0, @firebase/rules-unit-testing 5.0.2, Firestore emulator 127.0.0.1:8080, Auth emulator 127.0.0.1:9099, and Emulator UI 127.0.0.1:4000. The mandatory capstone uses only a demo- project and local tooling. Managed location, production IAM/App Check, real composite/vector indexes, Query Explain/Insights, billing, quotas, Key Visualizer, scheduled backups/PITR, CMEK/network controls, Enterprise/Pipeline, and MongoDB-compatibility validation are optional managed evidence and are never inferred from emulator success. Where a managed Standard example needs a concrete location, this chapter uses us-central1 only as an explicit example—not a universal recommendation.

2. Final architecture at a glance

Layer Decision Why
Client application Firebase JS/mobile Core SDKs; Auth + Rules; optional App Check enforcement. Direct realtime/offline UX where useful, with untrusted-client policy at data boundary.
Operational database Firestore Standard, Native Core, (default). Launch journeys fit Core; no Pipeline/MongoDB migration requirement.
Data model Products, carts/items, inventory, orders, events; explicit schemaVersion. Access-pattern-oriented model with bounded document/query contracts.
Trusted backend Admin/server SDK via ADC/IAM; verified user identity + application authorization. Protect checkout/inventory/order state transitions from client privilege.
Atomicity Transaction for inventory reservation + order creation; idempotency key. Read-dependent invariant and retry-safe duplicate handling.
Realtime/offline Order listener; cart can queue offline; checkout online-only. UX benefit without pretending cached/offline state preserves server invariants.
Search/analytics Core indexed search; operational aggregation; vector optional and off by default; warehouse for large analytics. Avoid extra feature surfaces until requirements justify them.
Retention/recovery TTL policy only for appropriate events; scheduled backup/PITR optional managed policy + tested runbook. Lifecycle and recoverability are separate from application availability.
Delivery Demo-project emulator CI + source-controlled Rules/indexes + staged managed canary. Deterministic local proof plus explicit production-only proof.

3. Evidence register: do not mix proof scopes

Claim Evidence Scope/status
Tenant/user isolation Rules unit/integration tests with allow/deny cases. LOCAL PASS; managed Rules canary still recommended.
Checkout no oversell/replay Concurrent transaction + idempotency tests. LOCAL PASS; managed contention canary REQUIRED.
Composite browse/order queries Query contract + index JSON. LOCAL LOGIC PASS; managed index READY evidence REQUIRED.
p95/p99 Local distributions + managed canary target. LOCAL REGRESSION ONLY until managed run.
Query efficiency Saved local trace model. Query Explain/Insights VERIFY_MANAGED.
Cost Workload-unit model with dated prices/assumptions. FORECAST; compare with real billing/usage telemetry.
Recovery Deterministic local restore/cutover drill. RUNBOOK PASS; managed backup/PITR drill REQUIRED for production claim.
Offline UX Disconnect/reconnect/cache metadata tests. LOCAL PASS; platform-specific production behavior monitored.

4. Measured cost and latency must carry assumptions

capstone/evidence-summary.json
{  "reviewDate": "2026-09-17",  "architecture": "Standard Native Core",  "localLoad": {    "dataset": "synthetic AtlasMart",    "concurrency": 32,    "p50Ms": "<record test output>",    "p95Ms": "<record test output>",    "p99Ms": "<record test output>",    "meaning": "local regression only, not production capacity"  },  "costModel": {    "regionExample": "us-central1",    "trafficScenarios": ["best", "base", "worst"],    "priceSourceDate": "2026-09-17",    "pricesAreReplaceableInputs": true  },  "managedEvidence": {    "indexReadiness": "VERIFY_MANAGED",    "queryExplainInsights": "VERIFY_MANAGED",    "billingQuotaMetrics": "VERIFY_MANAGED",    "backupPitrRestore": "VERIFY_MANAGED",    "regionalP95P99": "VERIFY_MANAGED"  }}

Do not fabricate numbers in a production review. Replace placeholders only with captured test output. A forecast without workload distribution, region, retry/listener rates, index behavior and source date is false precision.

5. Governance control matrix

Risk / obligation Control Evidence / owner
Unauthorized client access Firebase Auth + deny-by-default Rules + query-compatible constraints. Rules tests; security owner.
Privileged server misuse Least-privilege IAM/ADC + application authorization + audit logging. IAM review + authz tests + logs; backend owner.
Abusive app instances App Check where justified, rate/backpressure controls, usage alerts. Managed enforcement/canary; platform owner.
PII leakage in logs Structured redaction and allowlisted fields/correlation IDs. Log fixtures + review; observability owner.
Right-to-delete Enumerated primary/subcollection/event/export/backup scope and legal-hold policy. Deletion inventory/audit record; data-governance owner.
Logical corruption PITR/backup policy + isolated restore + application cutover drill. Recovery report; SRE/data owner.
Location/residency Provisioning decision recorded before database creation; backup/export/network paths included. Architecture/governance ADR.

6. Known-limit register

  • Emulator does not track compound indexes, enforce all production limits or model all transaction/contention behavior.
  • Rules are not filters; client queries must be provably authorized. Server libraries bypass Rules and need IAM/application authorization.
  • Transactions may retry and fail offline; external side effects must be idempotent/outside callback.
  • Automatic scaling does not remove hot-document or narrow/sequential key-range risk; traffic ramping remains an application responsibility.
  • Deleting a parent document does not cascade arbitrary subcollections; deletion workflows enumerate nested data.
  • TTL is asynchronous, not exact-time scheduling; legal holds require explicit exclusion/control.
  • Realtime listeners create read/bandwidth/cost behavior and must be unsubscribed/lifecycle-managed.
  • Standard vector search has server/client and result/dimension boundaries and no realtime listener; Firestore does not generate embeddings.
  • Enterprise Native/Pipeline and MongoDB compatibility have separate query/index/pricing/client/security/tool surfaces; capability must be verified per feature.
  • Multi-region availability does not replace backup/PITR; recovery must be tested.
  • Pricing, quotas, locations, launch stages and SDK versions are dated dependencies and require periodic re-verification.

7. Vendor dependency register

Dependency Coupling Mitigation
Security Rules + client listener/offline semantics High if client talks directly to Firestore. Contract tests; isolate domain model from SDK where practical; document alternative backend path.
Firestore index/query semantics Medium/high for query shapes. Central query contracts; export domain events/data; avoid undocumented behavior.
Admin SDK/IAM Medium. Application service layer hides credential/database specifics; use ADC/keyless identities.
TTL/backups/PITR/Query Insights Managed-service operational coupling. Runbooks and evidence inventories; separate policy from provider command syntax.
Vector search Model/index/provider coupling. Store embedding metadata; keep retrieval evaluation and re-embedding pipeline explicit.

8. When another database may be the better primary system

This is not a ranking of databases. It is an exit-criteria register: specific workload properties that would trigger a new architecture evaluation.

Observed requirement Why it challenges current AtlasMart Firestore design Evaluation direction
Frequent ad-hoc multi-table joins/relational constraints across large changing sets Denormalization/transaction boundaries become dominant complexity. Evaluate a relational system or Enterprise Pipeline if its semantics/economics truly fit.
Large historical analytical scans, arbitrary grouping/windowing and BI concurrency Operational document store is being used as a warehouse. Move analytical workload to BigQuery/warehouse while retaining operational Firestore if appropriate.
High-degree graph traversals are the core workload Repeated adjacency traversal is not the capstone access pattern. Evaluate a graph-oriented store.
Sustained writes require serial mutation of one logical entity at extreme rate Single hot document/logical bottleneck cannot scale by wishful thinking. Redesign/shard domain; if invariant inherently serial, evaluate systems for that workload.
MongoDB ecosystem compatibility is a non-negotiable migration constraint Current Standard/Core architecture does not expose MongoDB API. Evaluate Firestore MongoDB compatibility with feature matrix or another MongoDB-compatible system.
Search relevance/faceting/full-text requirements dominate application behavior Operational queries/vector retrieval may not replace a search engine. Evaluate a dedicated search system integrated with source-of-truth database.

9. Wrong final presentation: hide unknowns

Anti-pattern

Replace every VERIFY_MANAGED with a green checkmark because the emulator test suite is green. This turns unknown production properties into false evidence and makes the architecture review less trustworthy.

The correct final review preserves uncertainty. A release can be approved only when the organization decides which managed gates are mandatory for its risk level and captures them. Unknown is a valid state; pretending it is pass is not.

10. Final mandatory capstone run

  1. From a clean clone, run firebase emulators:exec --project demo-atlasmart-firestore --only auth,firestore "npm test".
  2. Verify six journey contracts, Rules deny matrix, checkout contention/idempotency, offline cart/reconnect and order-listener lifecycle.
  3. Run local distribution benchmark and save p50/p95/p99/error JSON with environment metadata.
  4. Run aggregation/materialized-summary reconciliation and optional deterministic vector relevance harness.
  5. Execute local recovery drill and save RPO/RTO/count/hash/config evidence.
  6. Exercise schema/deploy canary rollback criteria from Chapter 26.
  7. Generate cost scenarios and confirm price/source date is separate from billable-unit assumptions.
  8. Produce architecture-review.md containing ADR, evidence register, governance matrix, known limits, vendor dependencies, managed verification gates and exit criteria.
Completion condition

The capstone is complete when another engineer can reproduce the local evidence, identify every managed-only unknown, understand why Standard/Core was selected, execute rollback/recovery steps, and tell exactly what evidence would cause the architecture to change.

11. Course completion judgment

A production Firestore system is not “serverless, therefore effortless.” The application still owns data modeling, authorization intent, query/index design, client cache UX, transaction/idempotency boundaries, hotspot distribution, lifecycle policy, observability, cost assumptions, deployment compatibility and recovery drills. Firestore removes infrastructure classes of work; it does not remove architecture.

The capstone’s final skill is not memorizing an SDK. It is deciding which Firestore mechanism belongs on a request path, proving what that mechanism actually guarantees, measuring its consequences, and knowing when the workload has crossed the boundary where another system deserves evaluation.

Knowledge check

  1. Why are VERIFY_MANAGED items valuable rather than embarrassing?
  2. What is the strongest reason the capstone chooses Standard Native Core?
  3. Which evidence should never be inferred from the emulator?
  4. Why is an exit-criteria register part of good architecture?
  5. What is the final distinction between a Firestore feature list and an operable Firestore system?
Review the answers

1. They preserve the boundary between evidence and assumption, so production-only properties are not falsely certified.

2. The launch user journeys require Core client realtime/offline/Rules and trusted server transactions, while no measured requirement needs Enterprise/Pipeline/MongoDB compatibility.

3. Managed index readiness, real quotas/contention/latency, IAM/App Check enforcement, billing telemetry and managed backup/PITR behavior, among others.

4. It makes workload-fit review objective: architecture changes when measured requirements cross known boundaries, not when teams become attached to a tool.

5. An operable system connects each mechanism to a requirement, trust boundary, test, metric/cost surface, failure mode, rollback/recovery action and known limit.

Summary and next step

This lesson established the working contract for Present the Architecture with Measured Cost/Latency, Data-Governance Controls, Known Limits, and Criteria for Choosing Another Database. Keep its edition/mode assumptions, trust boundary, verification evidence, and operational constraints explicit when reusing the pattern.

This completes the course sequence. Return to Firebase and Cloud Firestore course overview to review the curriculum and revisit any lesson evidence.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.