Introduction
Zen Nurture’s API is built on Convex, a backend-as-a-service platform that provides real-time data synchronization, serverless functions, and built-in authentication. The API follows a type-safe, function-based architecture that makes it easy to interact with your baby tracking data.Architecture
The Zen Nurture API is organized around key resources:- Families - Multi-caregiver family groups
- Baby Profiles - Individual baby records with timezone and measurement preferences
- Events - All tracked activities (feeds, diapers, sleep, growth, etc.)
- Caregivers - People who care for a baby
- Reminders - Configurable reminder rules
- Milestones - Developmental milestone tracking
- Photos - Media attachments for events
- Weekly Digests - Auto-generated weekly summaries
Event Types
Zen Nurture supports comprehensive event tracking:FEED_BOTTLE- Bottle feeding (formula or expressed milk)FEED_BREAST- Breastfeeding sessionsPUMP- Pumping sessionsDIAPER- Diaper changes (wet, dirty, mixed, dry)SLEEP- Sleep sessions with start/end timesGROWTH- Weight, height, head circumference measurementsMED_DOSE- Medication dosesVACCINE_DOSE- Vaccination recordsNOTE- General notes and observations
API Patterns
Convex uses queries for reading data and mutations for writing data. All functions are type-safe and support real-time subscriptions.Queries
Queries are read-only operations that can be subscribed to for real-time updates:Mutations
Mutations modify data and return after completion:Client Setup
Zen Nurture uses the Convex React client with Better Auth integration for authentication.Resource Schema
All resources follow Convex’s schema definition:convex/schema.ts
Real-Time Subscriptions
One of Convex’s key features is automatic real-time updates. Any component usinguseQuery will automatically re-render when the underlying data changes:
Error Handling
All mutations throw errors that can be caught:"Unauthenticated"- User is not logged in"Not authorized"- User doesn’t have access to the resource"Baby not found"- Invalid baby profile ID"Not a member of this family"- User is not part of the family
Next Steps
Authentication
Learn about Better Auth integration and protected routes
Events API
Track feeding, diaper changes, sleep, and more
Baby Profiles
Create and manage baby profiles
Families
Multi-caregiver family management
