mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-04 11:38:13 +01:00
- Add @~/.claude/CLAUDE.md import for global engineering standards - Update Last Updated date to 2026-01-23 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.4 KiB
2.4 KiB
SSOT: Single Source of Truth (Botsmann)
This document is the authoritative SSOT map for where things live and how to use them. Follow this to avoid duplication and drift.
API Responses & Validation
- Source:
lib/api/responses.ts(exported vialib/api/index.ts) - Use:
import { jsonSuccess, jsonError, jsonValidationError, HTTP_STATUS } from '@/lib/api' - Zod helpers:
validateBody,formatZodErrors,hasValidationError,handleErrorinlib/api/responses.ts - Why: Ensures consistent payloads, status codes, and error handling across all routes.
Auth Helpers (Server)
- Source:
lib/api-utils.ts - Use:
import { verifyUser, requireAuth } from '@/lib/api-utils' - Notes:
HTTP_STATUScomes fromlib/api(responses) to keep SSOT for status codes.
Domain Constants
- Source:
lib/constants.ts - Includes:
DOMAIN_ERRORS,API_CONFIG,SYSTEM_PROMPTS, validation constants, model providers. - Use domain errors/messages from here; do not hardcode in routes or components.
Supabase Client
- Client (browser):
createClientComponentClientvialib/auth.tsx - Server (service role):
getServiceClient()inlib/supabase.ts(server-only) - Check configured:
isSupabaseConfigured()inlib/supabase.ts
Bot Configurations
- Source:
data/bots.ts - Use: Import to render navigation, content sections, and metadata for each bot.
Types
- Source:
types/ - Rule: Prefer interfaces for objects,
typefor unions/intersections.
Shared UI Components
- Source:
components/shared/*(e.g.,BotPageTemplate,BotSection) - Rule: Reuse for consistent IA/UX; keep components presentational; move logic to hooks.
Hooks
- Source:
lib/hooks/* - Rule: Encapsulate stateful or effectful logic; keep pure utilities in
lib/.
Environment Variables
- SSOT:
.env.local(not committed) built from.env.example - Never commit: any
.env*files..gitignorealready ignores them. - Rotate immediately if a secret leaks (Supabase service role, anon key, Groq, AWS, etc.).
Testing
- Unit/integration:
jest,@testing-library/*→tests/__tests__/ - E2E:
playwright→npm run test:e2e
Import Order (SSOT)
- React/Next
- Third-party libs
- Local components
- Local utilities (
lib/*) - Types (
types/*) - Styles
Commit Discipline
- Conventional commits:
type(scope): description - Pre-commit:
npm run lint && npm run format:check && npm run build