Production-ready architecture patterns for TwinMind meeting AI integrations with layered architecture (API -> Service -> TwinMind -> Integration -> Infrastructure), singleton client wrapper, service orchestration, error boundaries, and health checks.
Organize into layers: src/twinmind/ (client, config, types, errors, handlers), src/services/meeting/ (transcription, summary, actions, cache), src/integrations/ (calendar, slack, linear, email), src/api/ (routes, middleware), src/jobs/ (sync, cleanup, reports), src/utils/ (audio, logging, metrics), plus tests/, config/, and docs/.
Build a singleton TwinMindService with Axios, caching via TranscriptCache, metrics via MetricsCollector, and request/response interceptors for logging and error tracking.
Create MeetingService that orchestrates transcription, summary generation, action item extraction, speaker identification, and Slack notification. Run summary + action items in parallel for performance.
Implement TwinMindError with error codes (AUTH_FAILED, RATE_LIMITED, SERVER_ERROR), retryable flag, and factory method fromApiError() for consistent error handling.
Build checkHealth() that validates TwinMind API connectivity, cache availability, and database status. Return overall status (healthy/degraded/unhealthy) with per-check latency.
Create environment-specific JSON config files with loadConfig() that merges environment variables with file-based defaults for API URL, timeout, retries, cache TTL, and feature flags.
See detailed implementation for complete client wrapper, service layer, error boundary, health check, and config management code.
| Issue | Cause | Solution |
|---|---|---|
| Circular dependencies | Wrong layering | Separate concerns by layer |
| Config not loading | Wrong paths | Verify config file locations |
| Type errors | Missing types | Add TwinMind type definitions |
| Test isolation | Shared state | Use dependency injection |
Basic usage: Apply twinmind reference architecture to a standard project setup with default configuration options.
Advanced scenario: Customize twinmind reference architecture for production environments with multiple constraints and team-specific requirements.
For multi-environment setup, see twinmind-multi-env-setup.