S O U R C E C O D E
<script src=<span data-prism="string">"https:<span data-prism="comment">//cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.min.js"></script>
<script>
document.addEventListener(string">"DOMContentLoaded", function () {
mermaid.initialize({
startOnLoad: true,
theme: string">"base"
});
});
</script>
<hr>
<!-- MEGA MERMAID DIAGRAM -->
<div class=<span data-prism="string">"mermaid-container">
<pre class=<span data-prism="string">"mermaid" style=<span data-prism="string">"text-<span data-prism="property">align: center;">
%%{init: {039;theme039;: 039;base039;, 039;themeVariables039;: {
039;background039;: 039;#fefcf9039;,
039;primaryColor039;: 039;#fff0e6039;,
039;primaryBorderColor039;: 039;#d4450c039;,
039;primaryTextColor039;: 039;#1e1b18039;,
039;lineColor039;: 039;#b0a898039;,
039;secondaryColor039;: 039;#e8f0fe039;,
039;tertiaryColor039;: 039;#e9f5eb039;,
039;fontFamily039;: 039;Space Mono, monospace039;
}}}%%
flowchart TD
%% ======================== MAIN STRUCTURE ========================
Developer["š¤ DEVELOPER<br />(One Account, Unlimited Projects)string">"]
%% Projects cluster
subgraph PROJECTS["š YOUR FIREBASE PROJECTS (each isolated)string">"]
direction LR
ProjA["š PROJECT A<br />E‑commerce / Web + Androidstring">"]
ProjB["šµ PROJECT B<br />Admin System / Android + Webstring">"]
ProjC["š£ PROJECT C<br />Analytics / isolatedstring">"]
ProjN["⋯ more projects<br />(unlimited)"]
end
Developer --&gt; ProjA
Developer --&gt; ProjB
Developer --&gt; ProjC
Developer --&gt; ProjN
%% 1:<span data-prism="number">1 Database rule – each project connects to exactly ONE database
subgraph DATABASES[string">"š️ DATABASES (1:<span data-prism="number">1 binding)"]
DB_A["Database A<br />Firestore / RTDBstring">"]
DB_B["Database B<br />Firestore / RTDBstring">"]
DB_C["Database C<br />Firestore / RTDBstring">"]
DB_N["Database Nstring">"]
end
ProjA -- "1:<span data-prism="number">1 rule" --&gt; DB_A
ProjB -- string">"1:<span data-prism="number">1 rule" --&gt; DB_B
ProjC -- string">"1:<span data-prism="number">1 rule" --&gt; DB_C
ProjN -- string">"1:<span data-prism="number">1 rule" --&gt; DB_N
%% Unique API Keys + Config per project
subgraph API_CONFIG["š UNIQUE API KEYS & CONFIGURATIONstring">"]
direction LR
ConfigA["Project A → API Key A<br />Config A (authDomain, storageBucket, etc.)string">"]
ConfigB["Project B → API Key B<br />Config Bstring">"]
ConfigC["Project C → API Key C<br />Config Cstring">"]
ConfigNote["⚠️ Never cross‑wire!<span data-prism="tag"><br />App with Config A cannot talk to Project B DB"]
end
ProjA -.-&gt; ConfigA
ProjB -.-&gt; ConfigB
ProjC -.-&gt; ConfigC
ConfigA -.-&gt; ConfigNote
ConfigB -.-&gt; ConfigNote
%% APPS (unlimited per project)
subgraph APPS[string">"š± APPS (unlimited per project)"]
direction TB
subgraph Apps_A[string">"Project A apps (share DB A)"]
WA1[string">"š Web Storefront"]
WA2[string">"š Web Dashboard"]
AA1[string">"š± Android Buyer"]
end
subgraph Apps_B[string">"Project B apps (share DB B)"]
AB1[string">"š± Android Staff"]
AB2[string">"š± Android Field"]
WB1[string">"š Admin Panel"]
end
subgraph Apps_C[string">"Project C apps"]
CA1[string">"š Analytics Dashboard"]
CA2[string">"š± Metrics App"]
end
end
DB_A --&gt; Apps_A
DB_B --&gt; Apps_B
DB_C --&gt; Apps_C
%% ======================== SPARK FREE PLAN LIMITS ========================
subgraph SPARK_LIMITS[string">"⚡ FREE PLAN (SPARK) – WHAT YOU CAN / CANNOT DO"]
direction LR
CanDo["✅ CAN DO<br />• Many apps sharing 1 DB per project<br />• Multiple projects (each with own quota)<br />• Logical separation via collections/paths<br />• Project A + B as workaround for 2 DBsstring">"]
CannotDo["❌ CANNOT DO<br />• 2 separate DBs inside 1 project<br />• Multiple Firestore DBs per project (Blaze only)<br />• Multiple RTDB instances (1 per project)<br />• Unlimited reads/<span data-prism="function">writes (strict quotas)"]
end
ProjA -.-&gt; SPARK_LIMITS
ProjB -.-&gt; SPARK_LIMITS
%% ======================== CROSS-<span data-prism="constant">PROJECT BRIDGING ========================
subgraph CROSS_PROJECT[string">"š CROSS-<span data-prism="constant">PROJECT DATA SHARING"]
direction TB
NoAuto[string">"❌ NO automatic sync / replication between projects"]
Methods["Manual bridging options:<span data-prism="tag"><br />• Cloud Functions<br />• REST API calls<br />• External backend service<br />• Pub/<span data-prism="type">Sub message relay"]
NoAuto --&gt; Methods
end
DB_A -.-&gt; NoAuto
DB_B -.-&gt; NoAuto
%% ======================== DECISION TREE ========================
subgraph DECISION_TREE[string">"š YOUR ARCHITECTURE DECISION TREE"]
Q1{Do apps need<br />to share data?}
Q1 -- string">"YES (related apps)" --&gt; Opt1["✅ OPTION 1<br />Single Project, One Shared DB<br />Use collections to separatestring">"]
Q1 -- "NO (unrelated systems)" --&gt; Opt2["✅ OPTION 2<br />Multiple Projects → Separate DBs<br />Clean isolation"]
Q2{Need two separate<br />databases?}
Q2 -- string">"YES" --&gt; MultiProj["Use two (or more) Firebase projects<br />Project A + Project Bstring">"]
Q2 -- "NO" --&gt; SingleProj["Keep one project,<br />use collections/pathsstring">"]
Q3{On Spark free plan?}
Q3 -- "YES" --&gt; SparkOnly["Multiple projects is your ONLY way<br />for 2+ databasesstring">"]
Q3 -- "NO (Blaze)" --&gt; BlazeOption["Consider multi‑database feature<br />(paid, per‑project)"]
Opt1 --&gt; Q2
Opt2 --&gt; Q2
MultiProj --&gt; Q3
SingleProj --&gt; Q3
end
Developer --&gt; Q1
%% ======================== CARDINAL RULES (5 golden rules) ========================
subgraph CARDINAL_RULES[string">"š CARDINAL RULES – MUST REMEMBER"]
R1["š RULE 1: 1 PROJECT = 1 DATABASE<br />(1:<span data-prism="number">1 relationship, Spark = 1 Firestore + 1 RTDB)string">"]
R2["š RULE 2: Each project has its OWN API KEY & CONFIG<br />Project A → Config A, Project B → Config B (never mix!)string">"]
R3["š¦ RULE 3: 1 PROJECT = MANY APPS<br />Unlimited web/<span data-prism="type">Android/iOS apps share the same DBstring">"]
R4["š¤ RULE 4: 1 DEVELOPER = UNLIMITED PROJECTS<br />One account, hundreds of Firebase projectsstring">"]
R5["š« RULE 5: NO automatic cross‑project data sharing<br />Bridges must be built manually (Cloud Functions, REST, etc.)string">"]
end
R1 ~~~ R2 ~~~ R3 ~~~ R4 ~~~ R5
%% ======================== LEGEND (using notes) ========================
Legend["šŗ️ LEGEND<br />š️ = Database |&nbsp; š = Web App |&nbsp; š± = Android App<br />š = API Key/<span data-prism="type">Config |&nbsp; š¤ = Developer<br />✅ = Allowed |&nbsp; ❌ = Forbidden |&nbsp; š = Manual bridge"]
style Legend text-<span data-prism="property">align:center,fill:#f3f0ea,stroke:#c9c0b4
%% styling tweaks for readability
style Developer fill:#f1e5d8,stroke:#b34a0c,stroke-<span data-prism="property">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
</pre>
</div>
<hr />
%%{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
Comments
Post a Comment