Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ This README provides a quick setup guide for the Omi backend. For a comprehensiv

2. You will need to have your own Google Cloud Project with Firebase enabled. If you've already set up Firebase for the Omi app, you're good to go. If not, please refer to the [Firebase Setup Guide](https://firebase.google.com/docs/projects/learn-more).
- **IMPORTANT:** Make sure you have the [`Cloud Resource Manager API`](https://console.cloud.google.com/apis/library/cloudresourcemanager.googleapis.com), [`Firebase Management API`](https://console.cloud.google.com/apis/library/firebase.googleapis.com), and [`Cloud Firestore API`](https://console.developers.google.com/apis/api/firestore.googleapis.com/overview) enabled in the [Google Cloud API Console](https://console.cloud.google.com/apis/dashboard) **before proceeding to the next steps**. Failure to enable these APIs will result in authentication errors.
- **Firestore Composite Indexes:** You must create composite indexes for API key queries. Go to [Firebase Console](https://console.firebase.google.com/) → Firestore Database → Indexes, and create the following composite indexes:
| Collection | Fields |
|------------|--------|
| `dev_api_keys` | `user_id` (Ascending) + `created_at` (Descending) |
| `mcp_api_keys` | `user_id` (Ascending) + `created_at` (Descending) |

Without these indexes, the Developer Settings page will show "Failed to load API keys: Internal Server Error".
Comment on lines +14 to +20
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Thank you for documenting this crucial setup step. To make the process more robust and less error-prone for new developers, I recommend automating the creation of these Firestore indexes. Instead of manual steps, you can define the indexes in a firestore.indexes.json file and have developers deploy them with a single command.

This involves:

  1. Creating a firestore.indexes.json file in the backend/ directory.
  2. Updating firebase.json to point to this file.
  3. Replacing the manual instructions in the README with a command to deploy the indexes.

Here is the content for firestore.indexes.json:

{
  "indexes": [
    {
      "collectionGroup": "dev_api_keys",
      "queryScope": "COLLECTION",
      "fields": [
        { "fieldPath": "user_id", "order": "ASCENDING" },
        { "fieldPath": "created_at", "order": "DESCENDING" }
      ]
    },
    {
      "collectionGroup": "mcp_api_keys",
      "queryScope": "COLLECTION",
      "fields": [
        { "fieldPath": "user_id", "order": "ASCENDING" },
        { "fieldPath": "created_at", "order": "DESCENDING" }
      ]
    }
  ]
}

And in firebase.json:

{
  "firestore": {
    "indexes": "firestore.indexes.json"
  }
}

The suggested change below updates the README accordingly.

Suggested change
- **Firestore Composite Indexes:** You must create composite indexes for API key queries. Go to [Firebase Console](https://console.firebase.google.com/) → Firestore Database → Indexes, and create the following composite indexes:
| Collection | Fields |
|------------|--------|
| `dev_api_keys` | `user_id` (Ascending) + `created_at` (Descending) |
| `mcp_api_keys` | `user_id` (Ascending) + `created_at` (Descending) |
Without these indexes, the Developer Settings page will show "Failed to load API keys: Internal Server Error".
- **Firestore Composite Indexes:** This project uses Firestore composite indexes for querying API keys. To deploy them, run the following command from the `backend` directory:
```bash
firebase deploy --only firestore:indexes
```
This command uses the definitions in `firestore.indexes.json`. Without these indexes, the Developer Settings page will show "Failed to load API keys: Internal Server Error".


3. Run the following commands one by one to authenticate with Google Cloud:
```bash
Expand Down