ACT Journal — AI System Design
How a solo-built AI journaling app does 14 AI task types across 3 providers for ~$0.09 per session.
The Product
An AI journaling app grounded in ACT (Acceptance & Commitment Therapy). Users define their values, journal daily, and receive AI reflections that track behavioral patterns over time.
AI Reflections
Streaming, multi-turn responses that reference values, history, and patterns.
Pattern Detection
Tracks behavioral shifts, recurring themes, emotions, and promises made.
Insight → Action
Suggests practices with daily tracking. Detects when you've tried them.
Therapeutic framework invisible to users. No jargon — the ACT scaffolding shapes the AI's behavior, never the surface of the app.
Architecture
A serverless stack: the frontend never touches AI providers directly — every call flows through an edge-function proxy that owns auth, keys, access control, and cost tracking.
Key Decisions
Server-side keys
API keys live on the server, never in the browser.
Runtime prompt loading
AI instructions in a text file — change behavior without changing code.
Three prompt sizes
Bigger prompt for important tasks, smaller for simple. Less context = less cost.
Instant UI
The app never waits for the database.
Working formulation
Compact user model generated once, reused in every AI call.
No backend server
Serverless functions only.
What the AI Does
14 specialized tasks, grouped by when they fire — at each entry, during each conversation, and across the whole journal over time.
Each Entry
- ReflectionStreaming response referencing values, history, patterns.
- Emotion mapping2–3 emotions from Plutchik's 8.
- Value taggingWhich values does this entry touch.
- Label + summaryShort title + bullets, batched.
Each Conversation
- 5-turn follow-upDeepens reflection, checks in on active practices.
- Move detectionToward or away from a value.
- Practice suggestionConcrete action with a cue trigger.
- Commitment extractionDetects "I'm going to…" and tracks it.
Over Time
- InsightsWeekly / monthly / all-time pattern analysis.
- About YouAn evolving portrait.
- Working FormulationCompact model that calibrates every AI call.
- Themes + digestsRecurring patterns + monthly narrative summaries.
Prompt Engineering
v1 → v6. Rewrote from imperative rules to values-driven guidance.
Telling the AI what not to do produced robotic output — stilted, defensive, hollow.
Describing how it should think — its worldview, beliefs, what it cares about — produced natural, calibrated responses.
Three prompt tiers
Reflections, conversations
Full personality + task rules + the user's values, history, and patterns.
Insights, About You, digests
Personality + task rules + all journal entries, no per-entry context.
Labels, tags, emotions
Minimal personality + output format only. Fast and cheap.
The prompt is a static file — edit prose, deploy instantly, no code changes.
Cost Optimization
Four levers
Prompt Caching
35KB system prompt cached 5 min; turns 2–5 hit ~90% cache rate → 10% of input cost.
Model Routing
Haiku for labels at 1/15th cost; Sonnet for analysis; Opus for user-facing prose.
Context Tiering
Three prompt sizes 15KB → 13KB → 10KB; mechanical tasks get minimal context.
Smart Guards
Short-entry skip (<10 words); metadata folded into the reflection pass; time-based insight caching.
Model Selection
The right model per task — paying for nuance only where the user can feel it.
| Tier | Model | Price / 1M tokens | Use cases |
|---|---|---|---|
| Mechanical | Haiku | $0.80 | Labels, sorting, batch cleanup (simple output, no nuance) |
| Default | Sonnet | $3.00 | Emotions, tags, insights, digests (quality at reasonable cost) |
| Interpretive | Opus | $5.00 | Reflections, conversations (user-facing prose; quality = experience) |
Typical session cost
Evaluation Pipeline
Reflection quality is graded, not guessed — synthetic ground truth in, an LLM judge on a weighted rubric, results on a dashboard.
The rubric
| Criterion | Weight | What it checks |
|---|---|---|
| Reflection Quality | 40% | Depth, emotional truth, avoids summary (1–5). |
| Move Classification | 30% | Toward vs away correctly identified. |
| Advice Check | 15% | No disguised advice, no silver-lining. |
| Question Quality | 10% | Deep and genuine, not solution-seeking. |
| Language Check | 5% | No clinical terms, no "I" opener. |
Data Quality Over Time
AI-generated data gets messy. The system that cleans it matters as much as the one that creates it.
Dedup pipeline
Fuzzy Matching
Detects near-duplicates even with different wording (≥50% word overlap).
Theme Dedup
Catches similar themes on creation; keeps the first name on merge.
Move Dedup
Checks overlapping behavioral patterns before creating new.
Practice Dedup
Double-gate: title AND description must match; works across values.
Design bias: false negatives over false positives. Better to miss a duplicate than wrongly merge two distinct patterns.
Closed-Loop System
Not just inference — user signal feeds back at every step, so each session calibrates the next.
Key mechanisms
Calibration Card
After each conversation; user confirms or rejects detected moves.
Practice Check-ins
AI probes active practices mid-conversation.
Auto-confirmation
Moves auto-confirm at 3+ supporting entries; user can override.
Attempt Detection
AI passively detects practice attempts in entries.
Usage Ledger
Per-task cost tracking · admin dashboard · global spend vs budget.
Production Rollout
Four layers of production safeguards are live and server-side; the rest is a clear-eyed map of what's next.
Built
Stripe payments · free/paid tiers · per-user spend caps · budget controls · usage tracking · admin dashboard.
Testing Gaps
Cheaper-model quality testing · expanded eval coverage · multi-provider edge cases · load testing.
Scale
AI-powered search for large journals · smarter caching per task type · faster prompt delivery · database scaling.
Compliance
Mental-health disclaimers · data-retention policy · HIPAA evaluation · terms + privacy (drafted).
Try it live.
Click "Try sample journal" to explore the whole system without signing up.