rdev/ai-lookup/services/dns-cloudflare.md
jordan c59d348040 chore: prepare for composable monorepo template implementation
This commit captures the current state before implementing the composable
monorepo template system. Key changes included:

Infrastructure:
- Add CockroachDB provisioner adapter for database provisioning
- Add Redis provisioner adapter for cache provisioning
- Add build events system with PostgreSQL storage
- Add WebSocket endpoint for real-time build progress

Code agent improvements:
- Fix Claude Code adapter to use default allowed tools instead of dangerously-skip-permissions
- Add context-aware stream closing for cancellation support
- Improve parser tests for edge cases

Build system:
- Add build event constants and metrics
- Remove deprecated git_operations.go (replaced by pod_git_operations.go)
- Add rollback logic for multi-step provisioning operations

Documentation:
- Add composable-monorepo feature documentation
- Add DNS/Cloudflare service documentation
- Update deployment and troubleshooting guides

Cookbooks:
- Add fullstack-app cookbook
- Refactor landing-test with shared library

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 11:39:28 -07:00

2.2 KiB

DNS Management (Cloudflare)

Last Updated: 2026-01 Confidence: High

Summary

DNS for threesix.ai domains is managed via Cloudflare API. Projects get auto-generated subdomains on creation, and users can add custom subdomains or external domain aliases. The Cloudflare adapter implements the DNSProvider port interface.

Key Facts:

  • Auto-provisioned subdomains: {random}.threesix.ai created on project creation
  • Custom subdomains: User-chosen {name}.threesix.ai auto-configured via API
  • External aliases: User manages DNS, rdev only configures ingress
  • Credentials: CLOUDFLARE_API_TOKEN, CLOUDFLARE_ZONE_ID in .secrets → loaded to PostgreSQL

Credential Keys: internal/domain/credential.go:23-24

Domain Types

Type Example Auto-DNS
primary_auto k7m2x9p4.threesix.ai Yes
primary_custom my-app.threesix.ai Yes
alias www.myapp.com No

Architecture

Port Interface: internal/port/dns_provider.go

CreateRecord, UpdateRecord, UpsertRecord, DeleteRecord
DeleteRecordByName, GetRecord, ListRecords, FindRecord

Adapter: internal/adapter/cloudflare/client.go

  • Uses Cloudflare API v4 with Bearer token auth
  • 3-attempt retry on UpsertRecord for race conditions
  • Auto-normalizes subdomain names

Service: internal/service/project_infra_domains.go

  • AddDomain, RemoveDomain, ListDomains, GetPrimaryDomain
  • Coordinates between Cloudflare, database, and K8s ingress

Handler: internal/handlers/infrastructure_domains.go

  • REST endpoints: GET/POST/DELETE /projects/{id}/domains

Database Schema

Table: project_domains

  • project_id UUID → cascade delete
  • domain VARCHAR(255) UNIQUE
  • type CHECK (primary_auto|primary_custom|alias)
  • dns_record_id VARCHAR(64) - Cloudflare record ID for cleanup
  • verified BOOLEAN

API Endpoints

GET    /projects/{id}/domains           - List all domains
POST   /projects/{id}/domains           - Add domain
DELETE /projects/{id}/domains/{domain}  - Remove domain