Cloudflare Deployment
Relevant source files
The following files were used as context for generating this wiki page:
Cloudflare Deployment represents the core production infrastructure for SecretForge AI, leveraging an edge-native architecture to provide global low-latency secret management and AI processing. The deployment primarily centers on Cloudflare Workers, which act as the host for the API, AI Agents, and stateful storage components.
This infrastructure is designed to provide high availability and security, utilizing Cloudflare's specialized storage solutions like D1 for relational data, KV for secret storage, and Vectorize for semantic search of API documentation. The deployment workflow is automated via the wrangler CLI and integrated launch scripts to ensure consistent environment setups.
Sources: README.md:21-26, README.md:143-155, WARP.md:46-47
Architecture Overview
The deployment architecture utilizes a multi-layered approach within the Cloudflare ecosystem. At the entry point, the Cloudflare API (built with Hono and Workers) handles incoming requests from the CLI, Web Dashboard, and MCP Server. This layer interacts with stateful AI Agents and a suite of edge-native storage services.
Infrastructure Components
| Component | Technology | Description |
|---|---|---|
| API Runtime | Cloudflare Workers | Serverless execution environment for the Hono-based API. |
| Relational DB | Cloudflare D1 | SQLite-compatible database for managing schemas and metadata. |
| Secret Vault | Cloudflare KV | Distributed Key-Value store used for encrypted secret persistence. |
| Search Index | Cloudflare Vectorize | Vector database for semantic search of API documentation (1536 dimensions). |
| Stateful AI | Cloudflare Agents | AI runtime for managing stateful interactions and embedded SQLite. |
Sources: README.md:36-62, README.md:168-177, scripts/launch.sh:427-430
Data Flow Diagram
The following diagram illustrates how various clients interact with the Cloudflare infrastructure to process secrets and AI requests.
Sources: README.md:36-62
Deployment Workflow
Deploying to Cloudflare involves a sequence of resource provisioning followed by the application code deployment. The process utilizes the wrangler CLI to manage resources and environment configurations.
1. Resource Provisioning
Before the API can be deployed, the necessary storage namespaces and indexes must be created. This ensures the environment bindings in wrangler.toml have valid targets.
# Database creation
wrangler d1 create secretforge-db
# Secret storage creation
wrangler kv:namespace create SECRETS_VAULT
# Search index creation
wrangler vectorize create api-docs-index --dimensions=1536 --metric=cosine
Sources: NEXT_STEPS.md:28-31, README.md:143-155
2. Schema Initialization
The D1 database requires schema application to support the SecretForge metadata structure.
Sources: README.md:151-152
wrangler d1 execute secretforge-db --file=packages/api/schema.sql
3. API Deployment
The API package is deployed using a dedicated script that navigates to the package directory and executes the wrangler deployment command.
Sources: scripts/launch.sh:417-420, CONTRIBUTING.md:133-136
#!/bin/bash
cd packages/api
wrangler deploy
Configuration and Bindings
Deployment is governed by the packages/api/wrangler.toml file, which defines the environment variables and resource bindings necessary for the Worker to interact with Cloudflare services.
Binding Types
The application relies on several binding types to maintain state and provide AI functionality:
- D1_DATABASE: Connects the Worker to the
secretforge-dbfor relational storage. - KV_NAMESPACE: Connects to
SECRETS_VAULTfor distributed key-value access. - VECTORIZE_INDEX: Provides access to the
api-docs-indexfor RAG-based documentation search. - AI: Enables access to Cloudflare's built-in AI models for agentic workflows.
Sources: WARP.md:76-78, README.md:143-155, packages/mcp-server/src/index.ts:251-270
Continuous Integration (CI/CD)
The project implements automated deployment via GitHub Actions. On every push to the main branch, the deploy.yml workflow triggers the deployment of the API to Cloudflare Workers.
Sources: AUTOMATION_SUMMARY.md:33-36, AUTOMATION_SUMMARY.md:102-105
Sources: AUTOMATION_SUMMARY.md:92-105
Conclusion
The Cloudflare Deployment provides a highly scalable and distributed foundation for SecretForge AI. By utilizing the full suite of Cloudflare edge services—including Workers, D1, KV, and Vectorize—the system achieves sub-50ms global latency while maintaining a secure, zero-trust architecture for secret management. The automated deployment scripts and GitHub Actions integration ensure that the infrastructure remains consistent and easily maintainable across environments.
Sources: README.md:24-26, LAUNCH_PLAN.md:111-113, scripts/launch.sh:370-372