# API Documentation Maintenance Guide

This document describes the procedure for updating the API documentation and our backend's technical specification after major changes are made on the Base44 platform.

Following this process is **essential** to ensure that our custom backend on GCP remains synchronized with the frontend's features.

## When to Follow This Procedure

You should follow this guide after each significant development cycle on the Base44 platform, especially after:
- Adding new entities or data fields.
- Modifying existing business logic.
- Integrating major new features into the user interface.

---

## Update Procedure

### Step 1: Obtain Updated Documentation from Base44

1.  **Open the `docs/08-reference-base44-prompts.md` file**.
2.  Copy the content of the **"Main Prompt"**.
3.  Paste this prompt into the Base44 AI chat to request the latest documentation.
4.  **Verification:** The AI should return the full content of the `base44-api-export.md` file. If it only returns a summary, use the following simple prompt to request the full content:
    ```text
    Thank you for the summary. Please provide the entire, updated content of the API documentation file now.
    ```

### Step 2: Update the Local Documentation File (with Gemini CLI)

To ensure clean and consistent formatting, it is recommended to use the Gemini CLI for this step.

1.  **Copy the raw content** provided by the Base44 AI.
2.  **Provide this content to the Gemini CLI** with a simple prompt, for example:
    > "Here is the new Base44 API documentation. Can you reformat this content and update the `docs/07-reference-base44-api-export.md` file?"
3.  **Let the Gemini CLI** handle the file creation or update. It will ensure that tables, code blocks, and headers are correctly formatted.

### Step 3: Update the GCP API Specification (with Gemini CLI)

This is the most critical step. Instead of a tedious manual comparison, we will rely on the AI to synchronize our migration plan.

1.  **Ensure Step 2 is complete** and that `docs/07-reference-base44-api-export.md` is up-to-date.
2.  **Ask the Gemini CLI** to update the specification for you. Use a clear prompt, for example:
    > "Now that `docs/07-reference-base44-api-export.md` is updated, can you analyze the changes and comprehensively update the `docs/03-backend-api-specification.md` file to match?"
3.  **Let the Gemini CLI** perform the comparative analysis and apply the necessary changes (adding fields, entities, integrations, etc.) to the specification file.

### Step 4: Validate and Commit the Changes

1.  Give the changes in `03-backend-api-specification.md` a final review to ensure they are consistent.
2.  Commit the updated files to Git with a clear and descriptive message.
    ```bash
    git add docs/
    git commit -m "docs: Update API documentation and specification from Base44 export"
    ```

---