mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-04 04:17:17 +01:00
Production is fully self-hosted on the Hetzner box (bitbaum, behind Caddy) with self-hosted Supabase. This scrubs the remaining Vercel footprint: Code (src/ now has zero Vercel references): - security page: "Hosted on Vercel" → self-hosted infrastructure - FleetCrown URL fleetcrown.vercel.app → fleetcrown.orangecat.ch (entity registry + external-publish allowlist; the dead vercel.app subdomain was also a re-registration risk in an allowlist) - webhook-secret error + cron/env comments point at the box, not Vercel - corrected stale "Vercel kills the function on response" comments (false on a persistent server) to accurate await-before-respond reasoning Security/config: - supabase/config.toml: dropped dead *.vercel.app auth redirect URLs - @vercel/mcp-adapter dependency removed (unused) Artifacts removed: - scripts/auth/vercel-login.js, scripts/preview-url.sh, scripts/dev/merge-env.js, scripts/monitoring/deployment-monitor.js, scripts/db/setup-env.js, mcp-servers/vercel-openapi.json, .vercel/ - setup_vercel_secrets MCP tool in mcp-servers/github-server.js - .gitignore Vercel section; env scripts stripped of vercel-login/token Docs + .claude rules/commands rewritten to the self-host deploy flow (scripts/deploy-selfhost.sh / .github/workflows/cd.yml; env at /opt/orangecat/app/.env). Historical/archive records left intact. Verified: tsc 0 errors, SELF_HOST=1 build green, cron unit tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.4 KiB
3.4 KiB
Best Practices
This guide captures practical applications of our core engineering principles across development, deployment, and operations. See also: ../standards/engineering_principles.md
Note (2026-06): Production is self-hosted on Hetzner ("bitbaum", behind Caddy). For deployment see
docs/operations/deployment/DEPLOYMENT_PROCESS.md.
Core Principles (Applied)
- Start simple and add complexity only when needed
- Focus on core functionality first
- Use built-in tools before adding external services
- Document decisions and their rationale
- Privacy/local-first by default
- SSOT/DRY/SoC across modules
- Accessibility and testability are non-negotiable
Initial Deployment Checklist
- Core routes tested
- Environment variables configured in
/opt/orangecat/app/.envon the box - Domain setup verified (Caddy reverse proxy)
- SSL certificates confirmed (Caddy auto-TLS)
/api/healthreturns OK after deploy
Monitoring on the Box
The self-hosted app runs behind Caddy on Hetzner. Observe it with:
- App logs — the systemd/process logs for the running Next.js standalone server
- Caddy logs — request/error logs at the reverse-proxy layer
- Health check —
curl https://orangecat.ch/api/health
When to Add Additional Tools
Only add error tracking and advanced monitoring when:
- You have actual users experiencing issues
- The basic logs show problems
- You need more detailed insights than process/Caddy logs provide
Documentation
- Keep deployment documentation up to date
- Document any issues and their solutions
- Maintain a changelog
- Update environment variables documentation
Security
- Use environment variables for sensitive data; never commit secrets
- Enable HTTPS and HSTS
- Set appropriate security headers (CSP, COOP/COEP where needed)
- Regular dependency updates and scans (SCA)
- Encrypt user API keys at rest (AES-256-GCM); consider client-only encryption when feasible
- No logging of sensitive content (chat text, PII)
Environment Hygiene
.env.localmust not be committed. Use.env.exampleas SSOT for keys and add placeholders only.- If an
.env.localwas tracked historically, scrub contents and remove from git history; rely on local, untracked copies going forward.
Performance
- Optimize images
- Use proper caching
- Minimize JavaScript bundles
- Implement lazy loading
- Prefer streaming responses for incremental UX (AI outputs)
Maintenance
- Regular dependency updates
- Monitor for deprecated features
- Keep documentation current
- Regular security audits
- Maintain ADRs for significant decisions
AI/Voice Features (Applied Best Practices)
- Private by default: do not persist private chat content server-side
- Local-first: support local model runtimes; browser-to-localhost paths only
- Key handling: encrypt keys at rest; avoid storing unless required; provide client-only mode where practical
- Rate limiting: per-user where possible; never rely solely on IP in authenticated contexts
- A11y: clear mic state, aria-labels, visible focus; keyboard and mobile-friendly
- Testing: mock SpeechRecognition; integration tests for prefill flows; E2E happy paths
- Feature flags: guard non-critical voices features for gradual rollout
When to Scale
Add more sophisticated tools only when:
- You have actual scaling needs
- Basic tools are insufficient
- You have the resources to maintain them
- The benefits outweigh the costs