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
- Convert Media to MP3: Convert various media files to MP3 format.
- Combine Multiple Videos: Merge multiple videos into one seamless file.
- Transcribe Media: Transcribe audio directly from media files.
- Add Captions to Videos: Insert captions to videos using SRT or ASS files.
- Upload Files to Google Drive: Securely upload files to a Google Drive folder.
- Audio Mixing: Integrate audio files with video for a fully synced experience.
- Keyframe Extraction: Extract keyframes from video files for thumbnails or previews.
Prerequisites
- Google Cloud Platform (GCP) Account: For using Google Cloud Storage and Google Drive.
- Docker: For running the application locally or in any containerized environment.
- Google Cloud SDK: For managing GCP resources, downloadable from Google Cloud SDK.
Environment Variables
The following environment variables are necessary for the application to function as intended:
API_KEY
: A secure API key for authenticating requests.
GCP_SA_CREDENTIALS
: Service account credentials in JSON format for Google Cloud Platform access.
GDRIVE_USER
: The Google Drive user email associated with the service.
GCP_BUCKET_NAME
: The name of the Google Cloud Storage bucket used for storage.
GDRIVE_FOLDER_ID
: The Google Drive folder ID where files will be uploaded.
Docker Build and Run
-
Build the Docker Image:
docker build -t media-processing-api .
-
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:
- Transcribe Media v1 - Transcribes media audio.
- FFmpeg Compose v1 - Custom media composition using FFmpeg.
- Authenticate - Verifies API key for access.
- Media to MP3 - Converts media files to MP3.
- Transcribe Media - Transcribes media audio.
- Image to Video - Converts images into a video.
- Caption Video - Adds captions to videos.
- Combine Videos - Merges multiple videos.
- Audio Mixing - Mixes audio into video files.
- Google Drive Upload - Uploads files to Google Drive.
- 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
-
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
Figure 1: Initiating a new project in Google Cloud Console.
-
Enable Required APIs and Services:
- Navigate to APIs & Services:
- Click on Menu (☰) > APIs & Services > Library.
Figure 2: Enabling Cloud Storage APIs in the Google Cloud Console.
Figure 3: Enabling the Cloud Run Admin API.
-
Service Account Setup:
- Navigate to Service Accounts:
- Go to Menu (☰) > 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.
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.
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.
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:
- Sign in to the Google Cloud Console.
- From the project selector, select your main organization.
- Navigate to IAM & Admin > IAM.
- Click + GRANT ACCESS.
- In the New principals field, enter your email address.
- In Select a role, search for and select Organization Policy Administrator.
- Click Save.
-
Manage Organization Policy for Your Project:
- From the project selector, select your project (e.g.,
nca-toolkit-deployment
).
- Navigate to IAM & Admin > Organization policies.
- In the Filter field, enter
Disable service account key creation
.
- Select the Disable service account key creation constraint from the results.
- Click Edit to modify the policy.
- Choose Customize to override the inherited policy.
- Add a rule with Enforcement set to Off.
- 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.
Figure 8: Handling the key creation error.
-
Configure Google Drive Upload Settings
To enable Google Drive integration, follow these steps to set up domain-wide delegation:
-
Navigate to Service Accounts:
- In the Google Cloud Console, go to IAM & Admin > Service Accounts.
-
Select Your Service Account:
- Click on the service account you created earlier (e.g.,
nca-toolkit-sa
).
-
Copy the Unique ID:
- In the service account details, copy the Unique ID.
-
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.
-
Extract the Client ID:
- Open the downloaded JSON key file in a text editor.
- Locate and copy the
client_id
value.
-
Access Google Workspace Admin Console:
-
Navigate to API Controls:
- In the Admin console, go to Security > Access and data control > API controls.
-
Manage Domain-Wide Delegation:
- Click on Manage Domain Wide Delegation.
-
Add a New Delegation:
-
Create a 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.
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
- Create a New Project:
- Go to Google Cloud Console.
- Click on the project selector at the top and select New Project.
- Name your project (e.g.,
nca-toolkit-deployment
) and select your organization if applicable.
- Click Create.
- Once the project is created, select it from the project selector.
2. Enable Required APIs and Services
- Navigate to APIs & Services:
- Click on Menu (☰) > APIs & Services > Library.
- Enable the Following APIs:
- Cloud Storage API:
- Search for "Cloud Storage".
- Enable both Cloud Storage and Cloud Storage JSON API.
- Cloud Run API:
- Search for "Cloud Run".
- Enable Cloud Run Admin API.
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
-
Navigate to Cloud Run:
- Go to Menu (☰) > Cloud Run.
-
Create a New Service:
- Click + CREATE SERVICE.
- Service Settings:
- Container Image URL:
- Enter
stephengpope/no-code-architects-toolkit:v1.0.1
.
- Service Name:
- Use the default or specify a name.
- Region:
- Select your preferred region.
- Click Next to configure the service.
Figure 13: Deploying a new service on Cloud Run.
-
Configure Authentication and Permissions:
- Authentication:
- Select Allow unauthenticated invocations.
-
Set CPU and Memory Allocation:
- Click Show advanced settings.
- Under CPU Allocation and Pricing:
- Select CPU is always allocated.
- Memory:
- Set to 16 GiB for faster processing (adjust based on your needs).
- CPU:
- Set the Minimum number of CPUs to 4.
-
Set Environment Variables:
- Under Variables & Secrets > Environment variables, add the following:
API_KEY
:
- Set to a secure value (e.g.,
test123
for testing).
GCP_BUCKET_NAME
:
- Enter the name of your Cloud Storage bucket.
GCP_SA_CREDENTIALS
:
- Paste the entire JSON content from your service account key file.
GDRIVE_USER
:
- Enter the Google Drive user email associated with the service.
GDRIVE_FOLDER_ID
:
- Enter the Google Drive folder ID where files will be uploaded.
-
Additional Settings:
- Request Timeout:
- Leave at default (300 seconds) or adjust as needed.
- Maximum Concurrent Requests:
- Set to 1 for initial testing.
- Execution Environment:
- Select Second Generation.
-
Deploy the Service:
- Review all settings.
- Click Create.
- Wait for the deployment to complete.
Figure 14: Completing the deployment and verifying the green check mark.
7. Test the Deployment
-
Retrieve the Service URL:
- After deployment, your service URL will be displayed (e.g.,
https://<service-name>-<hash>-<region>.a.run.app
).
-
Test Using Postman or Similar Tool:
Figure 15: Using Postman to test the API endpoints.
- Verify the Response:
- A successful response should indicate that the media is being processed.
Figure 16: Receiving a successful response in Postman.
-
Test the Output:
- Check your Cloud Storage bucket for the output files.
- Ensure that the files are accessible and properly processed.
Figure 17: Replacing localhost with the actual service URL in Postman.
Note: If you encounter permissions issues accessing the files, revisit the bucket permissions in step 5.
Testing the Application
Authenticate Endpoint
Transcribe Media
-
Test the /transcribe-media
Endpoint:
curl -X POST https://<your-service-url>/transcribe-media \
-H "X-API-Key: test123" \
-H "Content-Type: application/json" \
-d '{"media_url": "https://your-media-url.com/video.mp4"}'
-
Expected Response:
- A message indicating that transcription has started.
Accessing Transcribed Files
- Retrieve the Output:
- The transcribed files will be stored in your Cloud Storage bucket.
- Access the files via the Cloud Console or directly using the file URL.
Monitoring and Cleanup
Monitoring
- Cloud Logging:
- Access logs via Menu (☰) > Logging > Logs Explorer.
- Filter logs by resource type Cloud Run Revision.
- Cloud Run Metrics:
- Monitor CPU and memory usage under Cloud Run > Your Service > Metrics.
Cleanup
To avoid unnecessary costs:
- Delete the Cloud Run Service:
- In Cloud Run, select your service and click Delete.
- Delete the Cloud Storage Bucket:
- In Cloud Storage, select your bucket and click Delete.
- Remove Service Account Keys:
- Go to IAM & Admin > Service Accounts.
- Select your service account, go to the Keys tab, and delete the key.
- Delete the Project (if no longer needed):
- In the project selector, click Manage all projects.
- Select your project and click Delete.
License
This project is licensed under the MIT License.