mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-06 04:37:46 +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>
96 lines
3.4 KiB
Markdown
96 lines
3.4 KiB
Markdown
# 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)
|
|
|
|
1. Start simple and add complexity only when needed
|
|
2. Focus on core functionality first
|
|
3. Use built-in tools before adding external services
|
|
4. Document decisions and their rationale
|
|
5. Privacy/local-first by default
|
|
6. SSOT/DRY/SoC across modules
|
|
7. Accessibility and testability are non-negotiable
|
|
|
|
## Initial Deployment Checklist
|
|
|
|
- [ ] Core routes tested
|
|
- [ ] Environment variables configured in `/opt/orangecat/app/.env` on the box
|
|
- [ ] Domain setup verified (Caddy reverse proxy)
|
|
- [ ] SSL certificates confirmed (Caddy auto-TLS)
|
|
- [ ] `/api/health` returns OK after deploy
|
|
|
|
## Monitoring on the Box
|
|
|
|
The self-hosted app runs behind Caddy on Hetzner. Observe it with:
|
|
|
|
1. **App logs** — the systemd/process logs for the running Next.js standalone server
|
|
2. **Caddy logs** — request/error logs at the reverse-proxy layer
|
|
3. **Health check** — `curl https://orangecat.ch/api/health`
|
|
|
|
## When to Add Additional Tools
|
|
|
|
Only add error tracking and advanced monitoring when:
|
|
|
|
1. You have actual users experiencing issues
|
|
2. The basic logs show problems
|
|
3. 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
|
|
|
|
1. Use environment variables for sensitive data; never commit secrets
|
|
2. Enable HTTPS and HSTS
|
|
3. Set appropriate security headers (CSP, COOP/COEP where needed)
|
|
4. Regular dependency updates and scans (SCA)
|
|
5. Encrypt user API keys at rest (AES-256-GCM); consider client-only encryption when feasible
|
|
6. No logging of sensitive content (chat text, PII)
|
|
|
|
### Environment Hygiene
|
|
|
|
- `.env.local` must not be committed. Use `.env.example` as SSOT for keys and add placeholders only.
|
|
- If an `.env.local` was tracked historically, scrub contents and remove from git history; rely on local, untracked copies going forward.
|
|
|
|
## Performance
|
|
|
|
1. Optimize images
|
|
2. Use proper caching
|
|
3. Minimize JavaScript bundles
|
|
4. Implement lazy loading
|
|
5. Prefer streaming responses for incremental UX (AI outputs)
|
|
|
|
## Maintenance
|
|
|
|
1. Regular dependency updates
|
|
2. Monitor for deprecated features
|
|
3. Keep documentation current
|
|
4. Regular security audits
|
|
5. Maintain ADRs for significant decisions
|
|
|
|
## AI/Voice Features (Applied Best Practices)
|
|
|
|
1. Private by default: do not persist private chat content server-side
|
|
2. Local-first: support local model runtimes; browser-to-localhost paths only
|
|
3. Key handling: encrypt keys at rest; avoid storing unless required; provide client-only mode where practical
|
|
4. Rate limiting: per-user where possible; never rely solely on IP in authenticated contexts
|
|
5. A11y: clear mic state, aria-labels, visible focus; keyboard and mobile-friendly
|
|
6. Testing: mock SpeechRecognition; integration tests for prefill flows; E2E happy paths
|
|
7. Feature flags: guard non-critical voices features for gradual rollout
|
|
|
|
## When to Scale
|
|
|
|
Add more sophisticated tools only when:
|
|
|
|
1. You have actual scaling needs
|
|
2. Basic tools are insufficient
|
|
3. You have the resources to maintain them
|
|
4. The benefits outweigh the costs
|