Overview
This endpoint analyzes the user’s diary data from the last 30 days to identify patterns, triggers, safe foods, and time-based correlations. Discoveries are sorted by confidence level and type.Endpoint
Authentication
This endpoint requires authentication via Bearer token.Response
Indicates if the request was successful
Array of discovery objects, sorted by confidence (high first) and type
Discovery Types
Trigger Foods
Foods marked as problematic 2+ times. Includes:- Food name
- Associated symptom types
- Total number of incidents
- Whether it’s a recent discovery (last 7 days)
- High: 5+ incidents
- Medium: 3-4 incidents
- Low: 2 incidents
Time Patterns
Identifies time periods when symptoms occur most frequently (requires 5+ symptom entries). Time Periods:- Morning: 06:00 - 12:00
- Afternoon: 12:00 - 18:00
- Evening: 18:00 - 22:00
- Night: 22:00 - 06:00
- Pattern shown only if >40% of symptoms occur in one period
- Minimum 3 occurrences required
- High: >60% of symptoms in one period
- Medium: 40-60% of symptoms in one period
Safe Foods
Foods consumed 5+ times without being marked as problematic. Shows top 3 most consumed safe foods. Confidence Levels:- High: Consumed 10+ times without issues
- Medium: Consumed 5-9 times without issues
Combination Patterns
Problematic food combinations (future feature - currently not implemented in the service).Example Request
Example Response
Understanding Patterns
Trigger Identification
Triggers are identified from the ProblematicFoods collection, which tracks foods users have manually marked as causing symptoms. The system aggregates:- Total incidents across all markings
- Unique symptom types experienced
- Most recent incident date
Time Pattern Analysis
The system buckets all symptom entries by hour of day into 4 periods, then calculates what percentage fall into each bucket. Only significant patterns (>40% concentration) are reported.Safe Food Detection
The system tracks food consumption frequency across all meal entries and cross-references with problematic food markings. Foods with high consumption but no negative marks are identified as safe.Error Responses
401 Unauthorized
Returned when the request is missing or has an invalid authentication token.Implementation Notes
- Analysis uses data from the last 30 days only
- Discoveries are sorted first by confidence (high > medium > low), then by type priority (trigger > combination > time_pattern > safe_food)
- New discoveries are those with
lastIncidentwithin the last 7 days (for triggers) - Time patterns and safe foods are not marked as new
- Minimum thresholds ensure patterns are statistically meaningful:
- Triggers: 2+ incidents
- Time patterns: 5+ symptoms with >40% in one period
- Safe foods: 5+ consumptions with no marks
- Food IDs are used internally but food names are displayed to users
- The system automatically handles edge cases (no data, insufficient data, etc.)