📓

AI Diary

An intelligent voice & photo journaling system — record your day on iPhone or snap a photo, let AI transcribe, analyze, and remember it for you. All data stays home on a Raspberry Pi.

FastAPI Python 3.12+ SQLite FTS5 OpenRouter Vision Models Text-to-Speech Apple Health Google Health API Home Assistant Raspberry Pi Open WebUI Telegram Bot
View on GitHub
100% Local Storage
12 AI-Powered Features
FTS5 Full-Text Search
🇸🇪 Swedish Language
Overview

What it does

AI Diary turns your voice into a searchable, queryable personal archive. Record an audio note on your iPhone (while on the local network) or send a voice message to the Telegram bot when you're out and about, and within moments the entry is transcribed, analyzed for mood, events, people, and topics — then stored locally where you can chat with it in natural language.

The project integrates with Open WebUI as a Pipe function so your diary lives right next to your other AI tools. A Telegram bot adds a second interface — send voice notes, text queries, or even photos straight from the Telegram app. Snap a picture and a vision model writes a Swedish description, attaching the image to the day's entry. Monthly and yearly summaries are generated automatically, and a hierarchical retrieval system ensures the chat interface fetches only the granularity it needs — keeping token costs low and answers accurate.

AI Diary Telegram bot conversation showing diary query and response in Swedish
🔒

Privacy-first by design. All diary data lives on your local network. Only processed text is sent to an AI model for analysis — raw audio never leaves your home. For the same reason, the iPhone Shortcut only talks to the API over the local network, while Telegram is the remote channel — used to log voice notes, photos, and queries whenever you're away from home.

Pipeline

How an entry is processed

From voice or photo to searchable memory — all running automatically in the background.

🎙️

iPhone Shortcut → Audio Upload

An iPhone Shortcut records m4a audio and POSTs it to the FastAPI endpoint. The HTTP response is instant — heavy processing happens in a background task.

✍️

Transcription via OpenRouter

Audio is sent to OpenRouter by default, or to any OpenAI-compatible transcription server — Speaches/faster-whisper-server, whisper.cpp, LocalAI, LM Studio, Groq or OpenAI — configured through environment variables. The result is clean Swedish-language text.

📷

Photo & Vision Analysis

Send a photo via Telegram and a vision model writes a Swedish description, attaching the image to the day's entry. The description is stored locally so the raw image is only sent to the model once.

🧠

LLM Analysis

A language model extracts a summary, mood indicators, events, mentioned people, topics, and action items from the transcription.

📅

Daily Entry Merge

Multiple recordings from the same day are automatically merged into a single cohesive daily entry.

🗄️

SQLite FTS5 Storage

Transcription, structured analysis, and rolled-up summaries are stored with full-text indexing across all fields for fast retrieval.

❤️

Health Data — Apple Health, Fitbit & Home Assistant

A daily health row is built from up to three sources: an iPhone Shortcut posting an Apple Health snapshot straight to the API, the same JSON dropped into the Telegram bot as a text message, or — new — a nightly cron job that pulls resting heart rate, sleep, and total calories directly from a Google Fitbit device via the Google Health API, no phone required. A nightly sync can alternatively read sensors from Home Assistant over MCP. Field names are normalised against a list of common aliases, and every path upserts the same row per date.

💬

Chat & Reports via Open WebUI

A Pipe function exposes the diary in Open WebUI. Query intent classification decides whether to fetch quick summaries or full transcriptions before responding — and any photos tied to the referenced dates are returned alongside the answer.

🎧

Dagboksradion — Audio Summaries

On request, an LLM writes a TTS-friendly Swedish script for a day, month, year, or year-to-date. OpenRouter renders it to MP3 and both script and audio are cached, so the spoken summary is delivered as a playable file in chat or Telegram.

✈️

Telegram Bot Interface

The remote access layer, built on the same pipeline. Send voice notes, text messages, or photos via Telegram to record entries or query the diary from anywhere — no VPN or port forwarding needed — with conversation history kept per chat for context-aware replies. The iPhone Shortcut, by contrast, is restricted to the local network by design: it's the fastest way to log an entry at home, and keeping it local avoids exposing that upload endpoint to the internet.

Audio

Dagboksradion — audio summaries

Turn your diary into a podcast. Dagboksradion generates a radio-style spoken summary for a single day, a month, a full year, or the year so far. A language model writes a TTS-friendly script in Swedish, OpenRouter renders it to an MP3, and both the script and audio are cached so repeat requests are instant.

The host's personality is selectable via a style parameter (or the AUDIO_SUMMARY_STYLE setting): default is a warm, personal host, factual is a neutral fact-only recap, and roasting is sarcastic and joking while staying grounded in your real entries. Voice, model, format and speed are configurable too.

It's triggerable straight from a conversation — no menus, no buttons. Ask in Open WebUI ("Ge mig en ljudsammanfattning för idag", "Gör en podcast av juni") or message the Telegram bot in natural language or with a slash command like /summary 2026. The bot replies with a playable audio file titled for the period it covers.

Telegram chat where the user asks for a podcast of their year and Dagboksradion replies with a generated audio file titled 'året 2026 fram till den 13 juni'
New

Health data — automatic sync from Fitbit or Home Assistant

Alongside the original iPhone Shortcut — a daily Apple Health snapshot posted directly to the API or dropped into the Telegram bot as JSON — a nightly cron job now pulls the day's metrics straight from a Google Fitbit device via the Google Health API. Steps, distance, active energy, and flights climbed keep flowing from Apple Health as before, and the Fitbit sync adds resting heart rate, sleep duration, and total calories on top — no phone needs to be involved at all.

The Google Health API is Google's OAuth 2.0 successor to the retiring Fitbit Web API. For a single-user Raspberry Pi project, it stays in OAuth testing mode against the owner's own Google account instead of going through a full security review — a refresh token minted once via the OAuth 2.0 Playground is silently exchanged for hourly access tokens. The catch: testing-mode refresh tokens expire after about a week, so when the nightly sync hits an expired token it sends a Telegram alert asking for a fresh one rather than failing quietly. Re-authorization is now much smoother: a daily --check job sends a Telegram re-auth link, the /healthauth command re-authorizes from anywhere, and missing days are backfilled automatically afterwards. Each metric is fetched independently, too, so one bad response just skips that field instead of losing the whole day's sync. Everything lands through the same upsert-by-date logic as the Apple Health path — one row per day, whichever source last reported — with a short Swedish Telegram confirmation summarising what was saved or updated: steg, kilometer, kcal, vilopuls, and sömn.

Prefer not to use Google? Set the sync provider to Home Assistant and the nightly job reads steps, distance, resting heart rate and sleep from your sensors over MCP instead. A few details are handled for you: a night of sleep is attributed to the evening it started (so the nightly run also patches yesterday's row), resting heart rate is estimated from a low percentile of intraday samples, and backfills are available with --date or --from/--to for the Google provider.

Features

Key capabilities

  • Voice Capture via iPhone Shortcuts — Upload m4a recordings directly from your phone. Background processing keeps the API response instant.
  • Smart Transcription — Converts audio to text using configurable models through the OpenRouter API, with Swedish language support.
  • Photo Journaling with Vision AI — Send photos through Telegram and a vision model writes a Swedish description, attaching the image to that day's entry. Photos are served from a dedicated endpoint and surface in chat answers — inline base64 for web clients, server URLs for Telegram.
  • Intelligent Analysis — LLM-powered extraction of summaries, mood indicators, events, people mentions, topics, and action items.
  • Unified Daily Entries — Multiple recordings from the same day are automatically merged into a single cohesive entry.
  • Full-Text Search — SQLite FTS5 indexes transcriptions, summaries, topics, and mentioned individuals for fast, flexible querying.
  • Contextual Chat Interface — Natural language Q&A that classifies query intent and fetches either summaries or full transcriptions depending on what the question needs.
  • Temporal Summaries — Automatically generates and stores condensed monthly and yearly overviews for long-term reflection.
  • Health Tracking — Apple Health & Fitbit — An iPhone Shortcut sends a daily Apple Health snapshot (steps, distance, active energy, flights climbed) via API call or Telegram JSON message; field names are normalised against common aliases. A nightly cron job now adds a fully automatic sync from a Google Fitbit device via the Google Health API (OAuth2), pulling resting heart rate, sleep duration, and total calories with no phone involved. All sources upsert the same per-date row, and a Swedish confirmation is sent to Telegram either way.
  • Dagboksradion — Audio Summaries — Podcast/radio-style spoken summaries for a day, month, full year, or year-to-date. An LLM writes a TTS-friendly Swedish script, OpenRouter renders it to MP3, and both script and audio are cached. Trigger it conversationally in Open WebUI or via natural language / /summary <period> in Telegram.
  • Telegram Bot — Remote Access — Record voice notes, send photos, or ask questions directly in Telegram from anywhere, not just at home. The bot processes audio through the same transcription pipeline and keeps per-chat conversation history for context-aware, natural language responses. Access is restricted to an allowlist of user IDs. The iPhone Shortcut, by comparison, only works on the local network — a deliberate security tradeoff that keeps the upload endpoint off the public internet.
  • Monthly & Yearly Reports — Generated reports with mood trends, recurring topics and a narrative overview, available through the API and chat.
  • Flexible Transcription Backends — Use OpenRouter or point the app at any OpenAI-compatible server (Speaches, whisper.cpp, LocalAI, LM Studio, Groq, OpenAI) for fully local or alternative transcription.
  • Home Assistant Health Sync — An alternative to Google Health: nightly sensor readings pulled over MCP into the same per-day health row.
  • Token Protection & Easy Re-auth — Optional API_TOKEN auth (header, Bearer or query token), plus a Telegram /healthauth command and daily token check that keep the Google OAuth connection alive.
  • Privacy-First Design — All diary data lives locally on the Raspberry Pi. Only processed text is sent to the AI model — raw audio never leaves your home network.
Stack

Technologies used

⚡
FastAPI
Async Python backend with background tasks
🗄️
SQLite + FTS5
Local storage with full-text search
🤖
OpenRouter API
Transcription & language models
📷
Vision Model
Swedish photo descriptions
🎧
Text-to-Speech
Cached Swedish audio summaries (MP3)
🍓
Raspberry Pi
Always-on home server
📱
iPhone Shortcuts
Voice capture & upload automation
❤️
Apple Health
Daily steps, distance & energy logging
⌚
Google Health API
Automated nightly Fitbit sync via OAuth2
🏠
Home Assistant (MCP)
Sensor-based health sync alternative
🌐
Open WebUI Pipe
Chat interface integration
✈️
Telegram Bot API
Voice & text diary access