# Crashfree India — Contacts Hub: Team Sync Setup

The dashboard (`contacts-hub.html`) works standalone right now (data saved in your browser only).
To make it **shared across the whole team in real time**, connect it to a free Firebase project.
This takes about 5 minutes and only you can do it (it needs your Google login).

## Step 1 — Create a Firebase project
1. Go to https://console.firebase.google.com
2. Click **Add project** → name it e.g. `crashfree-contacts` → disable Google Analytics (not needed) → **Create project**.

## Step 2 — Enable Firestore database
1. In the left sidebar, click **Build → Firestore Database**.
2. Click **Create database**.
3. Choose **Start in production mode** → pick a location close to India (e.g. `asia-south1`) → **Enable**.

## Step 3 — Set Firestore security rules
Since there's no login for team members yet, allow open read/write for now (fine for an internal, unlisted URL — do not share the link publicly).

1. In Firestore, go to the **Rules** tab.
2. Replace the contents with:
   ```
   rules_version = '2';
   service cloud.firestore {
     match /databases/{database}/documents {
       match /contacts/{contactId} {
         allow read, write: if true;
       }
       match /meta/{docId} {
         allow read, write: if true;
       }
     }
   }
   ```
3. Click **Publish**.

## Step 4 — Register a Web App and get your config
1. In the Firebase Console, click the **gear icon → Project settings**.
2. Scroll to **Your apps** → click the **`</>`** (Web) icon.
3. Give it a nickname (e.g. `contacts-hub-web`) → **Register app**.
4. Firebase shows a `firebaseConfig` object like:
   ```js
   const firebaseConfig = {
     apiKey: "AIzaSy...",
     authDomain: "crashfree-contacts.firebaseapp.com",
     projectId: "crashfree-contacts",
     storageBucket: "crashfree-contacts.appspot.com",
     messagingSenderId: "123456789",
     appId: "1:123456789:web:abcdef123456"
   };
   ```
5. Copy those 6 values.

## Step 5 — Paste the config into the dashboard
1. Open `contacts-hub.html` in a text editor.
2. Find this block near the top of the `<script type="module">` section:
   ```js
   const firebaseConfig = {
     apiKey: "YOUR_API_KEY",
     authDomain: "YOUR_PROJECT_ID.firebaseapp.com",
     projectId: "YOUR_PROJECT_ID",
     storageBucket: "YOUR_PROJECT_ID.appspot.com",
     messagingSenderId: "YOUR_SENDER_ID",
     appId: "YOUR_APP_ID"
   };
   ```
3. Replace the placeholder values with your real ones from Step 4.
4. Save the file and reload the page in your browser. The yellow "Not synced" banner should disappear, and the sidebar will show **"Synced live"** under your name.
5. On first load with an empty database, the app auto-seeds the 23 starting contacts. After that, every add/edit/delete/pin instantly syncs to everyone who has the page open.

## Step 6 (optional) — Publish a live link for the team
Right now the file only works when opened locally or from your preview server. To get a real URL the team can bookmark:

**Option A — Netlify Drop (no account, no CLI, 30 seconds)**
1. Go to https://app.netlify.com/drop
2. Drag the whole `DAsh` folder (or just `contacts-hub.html`) onto the page.
3. Netlify gives you an instant live URL (e.g. `random-name-123.netlify.app`).
4. Share that link with the team.
5. To keep the same URL long-term and be able to update it later, create a free Netlify account and "claim" the site after dropping it.

**Option B — Firebase Hosting (same project as your database)**
1. Install the CLI: `npm install -g firebase-tools`
2. Run `firebase login` (opens your browser to sign in).
3. In the `DAsh` folder run `firebase init hosting`, choose your `crashfree-contacts` project, set the public directory, and select `contacts-hub.html` as the entry point (or rename it to `index.html`).
4. Run `firebase deploy` — you'll get a URL like `crashfree-contacts.web.app`.

## Notes
- There's no login system yet — anyone with the link can view and edit. Fine for an internal team link that isn't shared publicly. If you later want to restrict who can edit, tell me and I'll add Firebase Authentication (Google sign-in restricted to `@crashfreeindia.org`).
- Seed data only runs once, automatically, the first time the `contacts` collection is empty — safe to leave in the code permanently.
