This single diagram captures everything: 1 project = 1 database (Spark invariant), unique API key + config per project (Project A → Config A), unlimited apps per project, free‑plan limits, cross‑project bridging (manual only), the architectural decision tree, and the five cardinal rules. No ASCII clutter, pure scalable vector goodness.
%%{init: {'theme': 'base', 'themeVariables': {
'background': '#fefcf9',
'primaryColor': '#fff0e6',
'primaryBorderColor': '#d4450c',
'primaryTextColor': '#1e1b18',
'lineColor': '#b0a898',
'secondaryColor': '#e8f0fe',
'tertiaryColor': '#e9f5eb',
'fontFamily': 'Space Mono, monospace'
}}}%%
flowchart TD
%% ======================== MAIN STRUCTURE ========================
Developer["π€ DEVELOPER
(One Account, Unlimited Projects)"]
%% Projects cluster
subgraph PROJECTS["π YOUR FIREBASE PROJECTS (each isolated)"]
direction LR
ProjA["π PROJECT A
E‑commerce / Web + Android"]
ProjB["π΅ PROJECT B
Admin System / Android + Web"]
ProjC["π£ PROJECT C
Analytics / isolated"]
ProjN["⋯ more projects
(unlimited)"]
end
Developer --> ProjA
Developer --> ProjB
Developer --> ProjC
Developer --> ProjN
%% 1:1 Database rule – each project connects to exactly ONE database
subgraph DATABASES["π️ DATABASES (1:1 binding)"]
DB_A["Database A
Firestore / RTDB"]
DB_B["Database B
Firestore / RTDB"]
DB_C["Database C
Firestore / RTDB"]
DB_N["Database N"]
end
ProjA -- "1:1 rule" --> DB_A
ProjB -- "1:1 rule" --> DB_B
ProjC -- "1:1 rule" --> DB_C
ProjN -- "1:1 rule" --> DB_N
%% Unique API Keys + Config per project
subgraph API_CONFIG["π UNIQUE API KEYS & CONFIGURATION"]
direction LR
ConfigA["Project A → API Key A
Config A (authDomain, storageBucket, etc.)"]
ConfigB["Project B → API Key B
Config B"]
ConfigC["Project C → API Key C
Config C"]
ConfigNote["⚠️ Never cross‑wire!
App with Config A cannot talk to Project B DB"]
end
ProjA -.-> ConfigA
ProjB -.-> ConfigB
ProjC -.-> ConfigC
ConfigA -.-> ConfigNote
ConfigB -.-> ConfigNote
%% APPS (unlimited per project)
subgraph APPS["π± APPS (unlimited per project)"]
direction TB
subgraph Apps_A["Project A apps (share DB A)"]
WA1["π Web Storefront"]
WA2["π Web Dashboard"]
AA1["π± Android Buyer"]
end
subgraph Apps_B["Project B apps (share DB B)"]
AB1["π± Android Staff"]
AB2["π± Android Field"]
WB1["π Admin Panel"]
end
subgraph Apps_C["Project C apps"]
CA1["π Analytics Dashboard"]
CA2["π± Metrics App"]
end
end
DB_A --> Apps_A
DB_B --> Apps_B
DB_C --> Apps_C
%% ======================== SPARK FREE PLAN LIMITS ========================
subgraph SPARK_LIMITS["⚡ FREE PLAN (SPARK) – WHAT YOU CAN / CANNOT DO"]
direction LR
CanDo["✅ CAN DO
• Many apps sharing 1 DB per project
• Multiple projects (each with own quota)
• Logical separation via collections/paths
• Project A + B as workaround for 2 DBs"]
CannotDo["❌ CANNOT DO
• 2 separate DBs inside 1 project
• Multiple Firestore DBs per project (Blaze only)
• Multiple RTDB instances (1 per project)
• Unlimited reads/writes (strict quotas)"]
end
ProjA -.-> SPARK_LIMITS
ProjB -.-> SPARK_LIMITS
%% ======================== CROSS-PROJECT BRIDGING ========================
subgraph CROSS_PROJECT["π CROSS-PROJECT DATA SHARING"]
direction TB
NoAuto["❌ NO automatic sync / replication between projects"]
Methods["Manual bridging options:
• Cloud Functions
• REST API calls
• External backend service
• Pub/Sub message relay"]
NoAuto --> Methods
end
DB_A -.-> NoAuto
DB_B -.-> NoAuto
%% ======================== DECISION TREE ========================
subgraph DECISION_TREE["π YOUR ARCHITECTURE DECISION TREE"]
Q1{Do apps need
to share data?}
Q1 -- "YES (related apps)" --> Opt1["✅ OPTION 1
Single Project, One Shared DB
Use collections to separate"]
Q1 -- "NO (unrelated systems)" --> Opt2["✅ OPTION 2
Multiple Projects → Separate DBs
Clean isolation"]
Q2{Need two separate
databases?}
Q2 -- "YES" --> MultiProj["Use two (or more) Firebase projects
Project A + Project B"]
Q2 -- "NO" --> SingleProj["Keep one project,
use collections/paths"]
Q3{On Spark free plan?}
Q3 -- "YES" --> SparkOnly["Multiple projects is your ONLY way
for 2+ databases"]
Q3 -- "NO (Blaze)" --> BlazeOption["Consider multi‑database feature
(paid, per‑project)"]
Opt1 --> Q2
Opt2 --> Q2
MultiProj --> Q3
SingleProj --> Q3
end
Developer --> Q1
%% ======================== CARDINAL RULES (5 golden rules) ========================
subgraph CARDINAL_RULES["π CARDINAL RULES – MUST REMEMBER"]
R1["π RULE 1: 1 PROJECT = 1 DATABASE
(1:1 relationship, Spark = 1 Firestore + 1 RTDB)"]
R2["π RULE 2: Each project has its OWN API KEY & CONFIG
Project A → Config A, Project B → Config B (never mix!)"]
R3["π¦ RULE 3: 1 PROJECT = MANY APPS
Unlimited web/Android/iOS apps share the same DB"]
R4["π€ RULE 4: 1 DEVELOPER = UNLIMITED PROJECTS
One account, hundreds of Firebase projects"]
R5["π« RULE 5: NO automatic cross‑project data sharing
Bridges must be built manually (Cloud Functions, REST, etc.)"]
end
R1 ~~~ R2 ~~~ R3 ~~~ R4 ~~~ R5
%% ======================== LEGEND (using notes) ========================
Legend["πΊ️ LEGEND
π️ = Database | π = Web App | π± = Android App
π = API Key/Config | π€ = Developer
✅ = Allowed | ❌ = Forbidden | π = Manual bridge"]
style Legend text-align:center,fill:#f3f0ea,stroke:#c9c0b4
%% styling tweaks for readability
style Developer fill:#f1e5d8,stroke:#b34a0c,stroke-width:2px
style ProjA fill:#fff0e6,stroke:#d4450c
style ProjB fill:#e8f0fe,stroke:#1d5fc4
style ProjC fill:#ede7f6,stroke:#6d3ac7
style DB_A fill:#f7f0ff,stroke:#6d3ac7
style DB_B fill:#f7f0ff,stroke:#6d3ac7
style ConfigA fill:#fff2e0,stroke:#d97706
style ConfigB fill:#fff2e0,stroke:#d97706
style CanDo fill:#e9f5eb,stroke:#15803d
style CannotDo fill:#ffe6e5,stroke:#b91c1c
style Methods fill:#fef3e2,stroke:#b45309
style R1,R2,R3,R4,R5 fill:#fdf8f0,stroke:#a08c74
π 1:1 Database rule
One Firebase project = exactly one Firestore + one RTDB on Spark. Need two separate databases? Create two projects.
Spark invariantπ Unique API key per project
Project A → API Key A + Config A. Project B → Config B. Never mix credentials; apps are bound to their own project.
isolationπ¦ Many apps, one DB
Web, Android, iOS — all can share the same database inside a project. Logical separation using collections/paths.
flexibleπ Cross‑project bridges
No automatic sync. Use Cloud Functions, REST API, or Pub/Sub to manually exchange data between projects.
manual onlyπ§ Why this Mermaid diagram replaces the ASCII version: It’s fully scalable, interactive (tooltips, pan/zoom in Mermaid viewers), and retains every single detail from our conversation — the one‑project‑one‑database cardinal rule, per‑project unique API keys (Project A → Config A), unlimited apps, Spark free plan restrictions, cross‑project isolation, decision tree for architects, and the five golden rules. No more alignment issues, pure vector goodness. Bookmark, embed, or share this reference.
Comments
Post a Comment