A Rust-based system that estimates neurobiological primitives (dopamine, serotonin, norepinephrine, adenosine, cortisol, glucose, circadian phase) from activity data using research-based computational models.
Takes activity data (sleep, exercise, meals, caffeine, stress, etc.) and computes biological state estimates based on neuroscience research. Instead of hardcoded impacts, it derives effects from event properties using peer-reviewed formulas.
# With your own data file
cargo run --bin cli -- /path/to/your_data.json
# With mock data
cargo run --bin cli -- mock_data.json
# Use a preset profile
cargo run --bin cli -- --profile chronically_sleep_deprivedcargo run --bin serverThen open http://localhost:8080 in your browser.
Pre-built profiles for testing:
healthy- Well-rested, regular exercise, good nutritionsleep_deprived- Multiple nights of poor sleepshift_worker- Night shifts with circadian disruptionathlete- Intense exercise and optimized schedulehigh_stress- Poor sleep, high stress, irregular meals
Input is JSON with events that have properties (not hardcoded impacts):
{
"user_id": "user_123",
"events": [
{
"event_id": "evt_1",
"event_type": "sleep",
"timestamp": "2025-01-15T23:00:00Z",
"end_timestamp": "2025-01-16T07:00:00Z",
"properties": {
"duration_hours": 8.0,
"quality": "good",
"efficiency": 0.92
}
},
{
"event_id": "evt_2",
"event_type": "caffeine",
"timestamp": "2025-01-16T08:00:00Z",
"properties": {
"dose_mg": 100
}
},
{
"event_id": "evt_3",
"event_type": "exercise",
"timestamp": "2025-01-16T17:00:00Z",
"properties": {
"type": "cardio",
"intensity": "moderate",
"duration_minutes": 30
}
}
]
}sleep- Duration, quality, efficiencycaffeine- Dose in mgexercise- Type, intensity, durationmeal- Macros (protein/carbs/fats %), glycemic indexlight- Intensity in lux, wavelengthstress- Severity, controllability, social evaluationsocial- Type (positive/negative), qualityscreen- Duration, content type, blue lightnap- Durationinterruption- Frequency
The system produces:
- Current state estimates for all 7 primitives
- Contributing events with computed impacts
- Detected patterns (sleep deprivation, withdrawal, synergies)
- Sleep drive analysis (homeostatic + circadian)
- Natural language interpretation
For natural language interpretation via OpenAI:
export OPENAI_API_KEY="your-key-here"The system works without an API key; interpretation just won't be available.
src/
├── lib.rs # Core estimation engine
├── chat.rs # Natural language interpretation
├── profiles.rs # Pre-built test profiles
├── bin/
│ ├── cli.rs # Command-line interface
│ └── server.rs # Web server demo
static/
├── index.html # Web interface
└── chat.js # Frontend JS
# Development
cargo build
# Optimized release
cargo build --release
./target/release/serverMIT