feat: add core application stack — hardware, scheduling, API, and UI#118
feat: add core application stack — hardware, scheduling, API, and UI#118
Conversation
- Remove Prisma dependencies and generated files - Add Drizzle ORM with better-sqlite3 - Create comprehensive schema with 11 tables: * Device settings & configuration * Side settings & tap gestures * Temperature/power/alarm schedules * Device state (runtime) * Biometrics (sleep, vitals, movement) * System health monitoring - Configure SQLite with WAL mode for concurrency - Add migration runner with auto-seeding - Update package.json scripts for Drizzle workflow
- Create type-safe hardware client for pod communication - Implement Unix socket communication with dac.sock - Add sequential command queue to prevent race conditions - Build message stream parser with delimiter support - Create response parser for device status and gestures - Support all hardware commands: * Temperature control (per side) * Alarm management (vibration, patterns) * Power control * Priming sequences * Device status polling - Add proper error handling with custom error types - Support Pod 3/4/5 version detection - Temperature conversion utilities (°F ↔ level) - Full TypeScript type safety throughout
- Device router: real-time pod control * Get device status from hardware * Set temperature per side * Power on/off control * Alarm management (set, clear) * Pod priming * Auto-sync with database - Settings router: configuration management * Device settings (timezone, temp unit, daily reboot/priming) * Side settings (names, away mode) * Tap gesture configuration (CRUD) - Schedules router: automation management * Temperature schedules (CRUD per day/side) * Power schedules (on/off times) * Alarm schedules (vibration, patterns, duration) * Query by day and side - Biometrics router: health data queries * Sleep records with date filtering * Vitals data (heart rate, HRV, breathing) * Movement tracking * Vitals summary statistics All routers feature: - Full Zod validation - Type-safe database operations - Proper error handling - Hardware client lifecycle management
- Core scheduler with timezone support * Cron-based scheduling via node-schedule * Event-driven architecture * Graceful shutdown handling * Job lifecycle management (schedule, execute, cancel) - Job manager for pod automation * Temperature schedules (per side/day) * Power schedules (on/off automation) * Alarm schedules (wake-up automation) * Daily priming sequences * Daily system reboots * Auto-reload on database changes * Timezone-aware execution - Type-safe job handling * Job types enum (temperature, power, alarm, etc.) * Execution results tracking * Metadata support per job * Event emitter for monitoring - Database integration * Loads schedules from Drizzle DB * Respects enabled/disabled flags * Supports dynamic schedule updates - Hardware integration * Uses hardware client for execution * Proper connection lifecycle * Error handling and retry logic All jobs execute in pod's configured timezone with proper error handling and logging.
- Pod Control page (/control) * Real-time temperature control per side * Power on/off controls * Temperature adjustment (+/-1°, +/-5°) * Device status display (water level, priming, version) * Auto-refresh every 5 seconds * tRPC integration - Settings page (/settings) * Device settings (timezone, temp unit, daily reboot/priming) * Side configuration (names, away mode) * Instant updates via tRPC mutations - Schedules page (/schedules) * View temperature schedules per side * View alarm schedules * Delete schedules * Side selector toggle - Home page (/) * Navigation cards to all sections * Clean dashboard layout - Components: * TemperatureControl: reusable temp control widget * Navigation: responsive nav with mobile bottom bar * Uses lucide-react icons - Layout: * Global navigation header * Mobile-responsive bottom navigation * Consistent container layout All pages use tRPC for type-safe API calls with optimistic updates and automatic refetching.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (9)
📒 Files selected for processing (36)
📝 WalkthroughWalkthroughImplements a complete smart pod control application with Drizzle ORM backend, hardware abstraction layer, job scheduling system, tRPC API routers, and React UI pages. Replaces Prisma with Drizzle, adds device communication protocols, automated scheduling, and frontend interfaces for temperature control, settings, and schedule management. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as React UI
participant tRPC as tRPC Router
participant HW as Hardware Client
participant DB as Drizzle Database
participant Socket as Pod Socket
UI->>tRPC: device.setTemperature(side, temp)
tRPC->>HW: createHardwareClient().connect()
HW->>Socket: Connect to Unix socket
Socket-->>HW: Connected
HW->>Socket: Send SET_LEVEL command
Socket-->>HW: Response OK
tRPC->>DB: Update deviceState (targetTemp, isPowered)
DB-->>tRPC: Success
tRPC-->>UI: Temperature set
HW->>Socket: Disconnect
UI->>tRPC: schedules.createTemperatureSchedule(...)
tRPC->>DB: Insert into temperatureSchedules
DB-->>tRPC: Record inserted
tRPC-->>UI: Schedule created
Note over DB: Scheduler loads schedule on startup/reload
sequenceDiagram
participant Scheduler as Scheduler
participant JobMgr as JobManager
participant DB as Drizzle DB
participant HW as Hardware Client
participant Device as Pod Device
Scheduler->>JobMgr: loadSchedules()
JobMgr->>DB: Query temperatureSchedules (side, dayOfWeek)
DB-->>JobMgr: Schedule records
JobMgr->>Scheduler: scheduleJob(id, cron, handler)
Scheduler->>Scheduler: Setup cron job with node-schedule
Note over Scheduler: Cron time reached
Scheduler->>Scheduler: executeJob(id, handler)
Scheduler->>JobMgr: handler() execution
JobMgr->>HW: createHardwareClient()
HW->>Device: setTemperature(side, temp)
Device-->>HW: Success
JobMgr-->>Scheduler: JobExecutionResult { success }
Scheduler->>Scheduler: Emit jobExecuted event
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related issues
Possibly related PRs
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Foundational implementation of the SleepyPod core stack, built on top of the existing project scaffolding.
dac.sockUnix socket — sequential command queue, response parser, Pod 3/4/5 support, temperature conversion utilitiesnode-schedule-backed job manager for temperature, power, alarm, prime, and reboot jobs; timezone-aware, database-driven, auto-reloads on config changes/control), settings (/settings), and schedule management (/schedules); mobile-responsive navigation; tRPC-integrated with 5s auto-refreshTest plan
pnpm tscpasses with no errorspnpm lintpassespnpm db:migrateruns without errors on a fresh DB/controlpage renders and reflects live hardware status when pod is connected/settingspage saves timezone and side name changes correctly/schedulespage lists and deletes schedules correctlyPOWER_ON/POWER_OFF/TEMPERATURE/ALARMjobs execute against hardware🤖 Generated with Claude Code
Summary by CodeRabbit
Release Notes