Files
botsmann/docs/SSOT.md
T
g-butandClaude Opus 4.5 1c7abeebac docs(claude): add global standards reference and update date
- 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>
2026-01-23 15:22:36 +01:00

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 via lib/api/index.ts)
  • Use: import { jsonSuccess, jsonError, jsonValidationError, HTTP_STATUS } from '@/lib/api'
  • Zod helpers: validateBody, formatZodErrors, hasValidationError, handleError in lib/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_STATUS comes from lib/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): createClientComponentClient via lib/auth.tsx
  • Server (service role): getServiceClient() in lib/supabase.ts (server-only)
  • Check configured: isSupabaseConfigured() in lib/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, type for 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. .gitignore already 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)

  1. React/Next
  2. Third-party libs
  3. Local components
  4. Local utilities (lib/*)
  5. Types (types/*)
  6. Styles

Commit Discipline

  • Conventional commits: type(scope): description
  • Pre-commit: npm run lint && npm run format:check && npm run build