This is a monorepo for the Cloudflare Workers-based AI service that CheckMate users.
graph TD
Client[Client] --> API[api-entrypoint]
API --> Agent[agent-service]
API --> Embedder[embedder-service]
API --> TrivialFilter[trivialfilter-service]
Agent --> Search[search-service]
Agent --> Screenshot[screenshot-backup-service]
Agent --> URLScan[urlscan-service]
subgraph "Service Bindings"
API
Agent
Embedder
TrivialFilter
Search
Screenshot
URLScan
end
The diagram above illustrates how our Cloudflare Workers connect to each other through service bindings:
- api-entrypoint: The main entry point that clients interact with
- agent-service: Handles AI agent orchestration and processing, as well as tool implementation. Note, search, screenshot, and urlscan tools are implemented as separate services but called within agent service.
- screenshot-service: Captures and processes website screenshots
- screenshot-backup-service: Captures and processes website screenshots, but calls the checkmate-screenshots GCP cloud function to do so instead of doing it natively in Cloudflare workers
- search-service: Implementation of google search tool
- urlscan-service: Analyzes URLs for malicious content
- embedder-service: Embeds URLs into a 384-dim vector using BGE
- trivialfilter-service: Determines if submissions are worth checking
Each worker can directly communicate with others through Cloudflare Workers service bindings, allowing for efficient microservice architecture without additional network hops.
- Install pnpm globally (if not already installed):
npm install -g pnpm- Clone the repository:
git clone https://github.com/your-username/checkmate-ai-monorepo.git
cd checkmate-ai-monorepo- Install dependencies:
pnpm install-
Set up environment variables:
- Copy
.dev.vars.exampleto.dev.varsin each worker directory - Fill in the required environment variables in each
.dev.varsfile
- Copy
- To run a specific worker:
pnpm run dev:<worker-name>- To run all workers simultaneously:
pnpm run devThis will start all workers concurrently based on the pipeline configuration in turbo.json. You can access them at:
- api-entrypoint: http://127.0.0.1:8787
- agent-service: http://127.0.0.1:8788
- screenshot-service: http://127.0.0.1:8789
- search-service: http://127.0.0.1:8790
- urlscan-service: http://127.0.0.1:8791
- screenshot-backup-service: http://127.0.0.1:8792
- embedder-service: http://127.0.0.1:8793
- trivialfilter-service: http://127.0.0.1:8794
Set the following environment secrets in GitHub:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_ID
Cloudflare API token can be created using the Edit Worker template.
Refer to deploy_worker.yml to set all other worker-specific secrets in GitHub.
Deploy independent workers first, followed by workers that depend on other workers, as service binding requires the dependent worker to exist beforehand.
Triggered on PRs to staging or main:
mainbranch:wrangler deploy --env productionstagingbranch:wrangler deploy --env staging
- Changes in a specific worker folder trigger deployment for that worker only.
- Changes in a shared folder trigger deployment for all workers.
Note: Workflow YAML must be merged into default branch before manual execution.
- Worker deleted with no changes to trigger automation.
- Deployment drift between GitHub Actions and local
wrangler deploy.
- Go to Actions > Deploy CF Worker.
- Click Run workflow.
- Choose Force all deployment or input a specific worker name.
CF Workers must be deployed first before triggering CF Secrets deployment.
- Go to Actions > Deploy CF Secrets.
- Click Run workflow.
- Choose Force all deployment or input a specific worker name.
Trigger 'Deploy Portkey to CF Worker' workflow
- Ensure that
TELEGRAM_BOT_TOKENis configured in GitHub Secrets for the "local" environment. - Ask the developer to retrieve their chat ID from Telegram.
- Go to Actions > Share Local Env workflow > Run workflow, and enter the developer’s chat ID.
- Generate an app password from https://myaccount.google.com/.
- Store the app password in
GMAIL_APP_PASSWORDin GitHub Secrets for the "local" environment. - Store the Gmail address in
GMAIL_USERin GitHub Secrets for the "local" environment. - Go to Actions > Share Local Env workflow, click Run workflow, and enter the developer's email.