A privacy-first local diary agent that collects your fragmented daily inputs via Telegram, and turns them into diary entries, idea lists, mood insights, and conversations โ fully offline, no API key required.
Features โข Quick Start โข Architecture โข Contributing โข Acknowledgements
MOSAIC is a personal side project built for three reasons:
- Personal use โ a private, always-local diary tool that actually fits into daily life
- Easy to self-host โ clone, configure, and run in minutes on any machine with Ollama
- Learning by building โ a hands-on exploration of core Agent components: Memory, RAG, Tools, Skills, Planning, and multi-turn conversation
If you are learning about LLM Agents or want a lightweight journaling tool that runs entirely on your own hardware, MOSAIC might be a good starting point.
- ๐ Frictionless logging โ send any text to the Telegram Bot and it is saved instantly
- ๐ฅ๏ธ Desktop/Web UI included โ built-in browser frontend for input, write, browse, and chat
- ๐ฒ Telegram mobile workflow โ capture fragments, trigger generation, query history, and chat directly in Telegram
- ๐ Diary generation โ daily diary entries assembled from your story records
- ๐ก Ideas & TODOs โ structured idea lists with actionable TODOs and thoughts
- ๐ Mood insights โ emotional trend analysis over any time window
- ๐ฌ Conversational AI โ chat with MOSAIC about your records, with multi-turn memory and planning
- ๐ Fully local โ runs entirely on your machine via Ollama, no data leaves your device
- ๐ฐ No token costs โ no API key required, no usage fees, works completely offline
- ๐ง Model-agnostic โ swap the LLM or embedding model to any Ollama-supported model
Telegram is not only for capture: you can log entries, trigger diary/ideas/mood generation, query records, and chat with MOSAIC directly from mobile.
The web UI is for structured review, writing, and reflection.
- ๐ Input: capture quick daily fragments and save by date.
- โ๏ธ Write: edit manual markdown content for diary, ideas, and mood.
- ๐ฌ Chat: reflect with RAG-assisted conversation over your own records.
- ๐ Diary: browse generated and manual diary history by calendar.
- ๐ก Ideas: review structured idea notes and TODO-style outputs.
- ๐ Mood: inspect emotional trends and day-level mood details.
- ๐ Time Reel: read-only timeline table for raw entry browsing.
- ๐๏ธ Calendar icons = data exists: when a day shows icons, that day already has corresponding records/files.
- ๐ Click day to inspect board: clicking a calendar date loads that date's data board on the right side.
- โก Input/Write writes immediately: in Input and Write, selecting a date and submitting writes data to the backend/database immediately.
- ๐งญ Write supports type selection: in Write, you can choose which non-fragment type to save (diary / ideas / mood).
- ๐งฉ Manual vs LLM output are visually separated: calendar views use different icons to distinguish user-written non-fragment records vs LLM-generated non-fragment records.
- ๐ All user data stays local: SQLite database, vector store, generated markdown, and manual files are all stored on your own machine.
- ๐ Privacy-first by design: no cloud API dependency, no automatic external upload, and you keep full control of your data files.
โ ๏ธ Note: Response speed depends on your hardware and the model you choose. MOSAIC is tested on a mid-range CPU laptop with Qwen2.5:7B. Currently supports text input only.
Prerequisites
- Python 3.11+
- Ollama installed and running
- A Telegram Bot token (via @BotFather)
1. Clone the repo
git clone https://github.com/your-username/MOSAIC.git
cd MOSAIC2. Install dependencies
pip install uv
uv sync3. Pull models (or replace with any Ollama-supported model)
ollama pull qwen2.5:7b
ollama pull shaw/dmeta-embedding-zh4. Set up environment
cp .env.example .env
# Add your TELEGRAM_TOKEN to .env5. Start Ollama
ollama serve6. Start the web server (frontend + API)
uvicorn api.server:app --reload --host 127.0.0.1 --port 8000Open http://127.0.0.1:8000 in your browser.
7. (Optional) Start Telegram Bot
python -m bot.telegram_botThen open Telegram, find your bot, and send /start.
- Open
http://127.0.0.1:8000to access the built-in frontend. - Use Input / Write to create or edit daily records.
- Use Diary / Ideas / Mood / Time Reel to browse generated and raw history.
- Use Chat for RAG-assisted reflection over your records.
MOSAIC/
โโโ api/
โ โโโ server.py # FastAPI app (serves API + frontend static files)
โ โโโ routes/
โ โโโ entries.py # Entries by date/month + read-only browse table
โ โโโ write.py # Manual markdown read/write endpoints
โ โโโ generate.py # Trigger diary/ideas/mood generation
โ โโโ diaries.py # Diary history/detail endpoints
โ โโโ mood.py # Mood calendar/detail/file endpoints
โ โโโ chat.py # Chat API + conversation reset
โ
โโโ bot/
โ โโโ telegram_bot.py # Telegram Bot: message handling and command routing
โ
โโโ core/
โ โโโ database.py # SQLite schema and CRUD helpers
โ โโโ llm.py # LLMClient via Ollama
โ โโโ processor.py # Background pending-entry analyzer
โ โโโ rag.py # ChromaDB vector retrieval
โ โโโ tools.py # Utility tools for agent/runtime
โ โโโ state.py # Multi-turn conversation state
โ โโโ planner.py # Multi-step intent planning
โ โโโ agents/ # Main/Diary/Ideas/Mood/Chat agents
โ
โโโ frontend/
โ โโโ index.html # Web UI layout
โ โโโ app.js # Alpine.js state, tabs, loading logic
โ โโโ style.css # Pixel theme + EN/CN typography
โ
โโโ prompts/
โ โโโ analyze_prompt.py
โ โโโ planning_prompt.py
โ โโโ routing_prompt.py
โ
โโโ skills/
โ โโโ diary/ # SKILL.md + scripts/generate.py
โ โโโ ideas/ # SKILL.md + scripts/generate.py
โ โโโ mood/ # SKILL.md + scripts/generate.py
โ
โโโ scripts/
โ โโโ seed_english_data.py # Seed English sample data
โ โโโ curate_march_data.py # Curate March sample density/mix
โ
โโโ tests/ # Unit tests
โโโ img/ # README demo GIF assets
โโโ data/ # Runtime data (gitignored: db, vectors, generated/manual markdown)
โโโ .env # Environment variables (TELEGRAM_TOKEN, etc.)
โโโ pyproject.toml
โโโ README.md
MOSAIC's skill system is inspired by Anthropic's Agent Skills specification, but adapted for local LLM constraints.
Each skill consists of:
SKILL.mdโ a Markdown instruction file with a structured frontmatter (name,description) that the agent uses for intent routing, and a prompt body that guides the LLM during executionscripts/โ Python execution logic that orchestrates tool calls, database queries, and LLM generation
Unlike the official specification where the LLM directly triggers scripts, MOSAIC uses a two-stage approach:
- Intent routing:
main_agent.pyreads allSKILL.mddescriptions and routes to the appropriate skill - Execution: Python code calls the selected skill's script, which uses
SKILL.mdas the LLM prompt
This design improves reliability with smaller local models (7B parameters).
Built with the assistance of Claude (Anthropic) and Cursor (Anysphere).


