stephengpope / no-code-architects-toolkit

The No-Code Architects Toolkit eliminates costly monthly API subscriptions by replacing them with a FREE API that you can deploy on low cost servers.
https://skool.com/no-code-architects
MIT License
138 stars 66 forks source link

Original Logo Symbol

No-Code Architects Toolkit

The No-Code Architects Toolkit is a robust media processing API built with Flask, providing services like audio conversion, video combination, transcription, captioning, and Google Drive upload integration. This toolkit is designed for easy deployment via Docker and Google Cloud Platform (GCP) and allows effortless media manipulation.


Features


Prerequisites


Environment Variables

The following environment variables are necessary for the application to function as intended:


Docker Build and Run

  1. Build the Docker Image:

    docker build -t media-processing-api .
  2. Run the Docker Container:

    docker run -d -p 8080:8080 \
     -e API_KEY=your_api_key \
     -e GCP_SA_CREDENTIALS='{"your":"service_account_json"}' \
     -e GDRIVE_USER=your_gdrive_user@example.com \
     -e GCP_BUCKET_NAME=your_gcs_bucket_name \
     media-processing-api

API Documentation

The following API endpoints are available. Detailed documentation for each endpoint is in the docs folder:

  1. Transcribe Media v1 - Transcribes media audio.
  2. FFmpeg Compose v1 - Custom media composition using FFmpeg.
  3. Authenticate - Verifies API key for access.
  4. Media to MP3 - Converts media files to MP3.
  5. Transcribe Media - Transcribes media audio.
  6. Image to Video - Converts images into a video.
  7. Caption Video - Adds captions to videos.
  8. Combine Videos - Merges multiple videos.
  9. Audio Mixing - Mixes audio into video files.
  10. Google Drive Upload - Uploads files to Google Drive.
  11. Extract Keyframes - Extracts video keyframes.

Refer to each linked file for comprehensive examples, request/response structures, and usage notes.


Deploying on Google Cloud Platform (GCP)

Prerequisites

  1. Google Cloud Project Setup:

    • Log in to Google Cloud Console and create a new project.
    • Enable required APIs:
      • Cloud Storage API
      • Cloud Storage JSON API
      • Cloud Run Admin API

    Creating a New Project in Google Cloud Console Figure 1: Initiating a new project in Google Cloud Console.

  2. Enable Required APIs and Services:

    • Navigate to APIs & Services:
      • Click on Menu (☰) > APIs & Services > Library.

    Enabling Cloud Storage APIs Figure 2: Enabling Cloud Storage APIs in the Google Cloud Console.

    Enabling Cloud Run Admin API Figure 3: Enabling the Cloud Run Admin API.

  3. Service Account Setup:

    • Navigate to Service Accounts:
      • Go to Menu (☰) > IAM & Admin > Service Accounts.

    Accessing IAM & Admin Service Accounts Figure 4: Accessing IAM & Admin Service Accounts.

    • Create a New Service Account:
      • Click + CREATE SERVICE ACCOUNT.
      • Name your service account (e.g., nca-toolkit-sa).
      • Click Create and Continue.

    Creating Service Account Figure 5: Creating a new service account.

    • Assign Roles to the Service Account:
      • Storage Admin:
      • Start typing "Storage Admin" and select it.
      • Viewer:
      • Add another role and select Viewer.
      • Click Continue, then Done.

    Assigning Roles Figure 6: Assigning Storage Admin and Viewer roles.

    • Generate and Download a JSON Key File:
      • Click on your newly created service account.
      • Go to the Keys tab.
      • Click ADD KEY > Create new key.
      • Select JSON as the key type.
      • Click Create.
      • A JSON key file will be downloaded to your computer. Keep this file secure.

    Generating JSON Key Figure 7: Generating and downloading the JSON key file.

    Note: If you encounter the error "Key creation is not allowed on this service account" when attempting to create and download the key, this is due to an organization policy constraint iam.disableServiceAccountKeyCreation enforced in your organization. To resolve this issue, you can either create the service account using a personal Gmail account or follow the steps below to allow key creation for your project.

    Allow Service Account Key Creation for Your Project

    • Assign the Organization Policy Administrator Role:

      1. Sign in to the Google Cloud Console.
      2. From the project selector, select your main organization.
      3. Navigate to IAM & Admin > IAM.
      4. Click + GRANT ACCESS.
      5. In the New principals field, enter your email address.
      6. In Select a role, search for and select Organization Policy Administrator.
      7. Click Save.
    • Manage Organization Policy for Your Project:

      1. From the project selector, select your project (e.g., nca-toolkit-deployment).
      2. Navigate to IAM & Admin > Organization policies.
      3. In the Filter field, enter Disable service account key creation.
      4. Select the Disable service account key creation constraint from the results.
      5. Click Edit to modify the policy.
      6. Choose Customize to override the inherited policy.
      7. Add a rule with Enforcement set to Off.
      8. Click Save to apply the changes.
    • Retry Key Creation:

      • Return to IAM & Admin > Service Accounts.
      • Select your service account.
      • Go to the Keys tab.
      • Click ADD KEY > Create new key.
      • Select JSON as the key type and click Create.
      • The key should now be generated and downloaded successfully.

      If the issue persists after following these steps, please consult your organization's administrator or refer to the Google Cloud documentation on managing service account keys.

    Handling Key Creation Error Figure 8: Handling the key creation error.

  4. Configure Google Drive Upload Settings

    To enable Google Drive integration, follow these steps to set up domain-wide delegation:

    1. Navigate to Service Accounts:

      • In the Google Cloud Console, go to IAM & Admin > Service Accounts.
    2. Select Your Service Account:

      • Click on the service account you created earlier (e.g., nca-toolkit-sa).
    3. Copy the Unique ID:

      • In the service account details, copy the Unique ID.
    4. Create a Second JSON Key File:

      • Click the Keys tab.
      • Click ADD KEY > Create new key > JSON > CREATE.
      • This will download a second JSON key file to your computer.
    5. Extract the Client ID:

      • Open the downloaded JSON key file in a text editor.
      • Locate and copy the client_id value.
    6. Access Google Workspace Admin Console:

    7. Navigate to API Controls:

      • In the Admin console, go to Security > Access and data control > API controls.
    8. Manage Domain-Wide Delegation:

      • Click on Manage Domain Wide Delegation.
    9. Add a New Delegation:

      • Click Add new.
      • In Client ID, paste the client_id you copied earlier.
      • In OAuth Scopes, enter:
        https://www.googleapis.com/auth/drive
      • Click Authorize.

        Important: Ensure that the service account has the necessary permissions to access and manage Google Drive on behalf of users in your domain.

  5. Create a Cloud Storage Bucket

    • Navigate to Cloud Storage:

      • Go to Menu (☰) > Cloud Storage > Buckets.
    • Create a New Bucket:

      • Click + CREATE BUCKET.
      • Enter a unique name for your bucket (e.g., nca-toolkit-bucket-<your-unique-id>).
      • Click Continue through the default settings until Choose how to control access to objects.
      • Access Control:
      • Select Uniform.
      • Public Access Prevention:
      • Turn Off the "Enforce public access prevention" toggle to allow public access.
      • Click Create.

    Creating Cloud Storage Bucket Figure 10: Creating a new Cloud Storage bucket.

    • Set Bucket Permissions:
      • After the bucket is created, go to the Permissions tab.
      • Click + GRANT ACCESS.
      • New Principals:
      • Enter allUsers.
      • Role:
      • Select Storage Object Viewer.
      • Click Save.
      • Acknowledge the warning about granting public access.

    Granting Bucket Permissions Figure 11: Granting allUsers the Storage Object Viewer role.


Full Deployment on Google Cloud Run

Follow these detailed steps to deploy the No-Code Architects Toolkit on Google Cloud Run.

Step-by-Step Deployment

1. Set Up Your Google Cloud Project

2. Enable Required APIs and Services

3. Create a Service Account

4. Configure Google Drive Upload Settings

Refer to the Configure Google Drive Upload Settings section above.

5. Create a Cloud Storage Bucket

Refer to the Create a Cloud Storage Bucket section above.

6. Deploy the Cloud Run Service

7. Test the Deployment


Testing the Application

Authenticate Endpoint

Transcribe Media

Accessing Transcribed Files


Monitoring and Cleanup

Monitoring

Cleanup

To avoid unnecessary costs:


License

This project is licensed under the MIT License.