Skip to content

rlin27/MOSAIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

56 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฉ MOSAIC โ€” My Own Stories and Ideas Compilation

English ็ฎ€ไฝ“ไธญๆ–‡

Python License Version Ollama Status

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

About

MOSAIC is a personal side project built for three reasons:

  1. Personal use โ€” a private, always-local diary tool that actually fits into daily life
  2. Easy to self-host โ€” clone, configure, and run in minutes on any machine with Ollama
  3. 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.

Features

  • ๐Ÿ“ 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 Demo

Telegram is not only for capture: you can log entries, trigger diary/ideas/mood generation, query records, and chat with MOSAIC directly from mobile.

MOSAIC Telegram Demo

Web Frontend

The web UI is for structured review, writing, and reflection.

MOSAIC Web Demo

  • ๐Ÿ“ 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 Interaction Rules

  • ๐Ÿ—“๏ธ 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.

Data Locality & Privacy

MOSAIC local data demo

  • ๐Ÿ” 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.

Quick Start

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 MOSAIC

2. Install dependencies

pip install uv
uv sync

3. Pull models (or replace with any Ollama-supported model)

ollama pull qwen2.5:7b
ollama pull shaw/dmeta-embedding-zh

4. Set up environment

cp .env.example .env
# Add your TELEGRAM_TOKEN to .env

5. Start Ollama

ollama serve

6. Start the web server (frontend + API)

uvicorn api.server:app --reload --host 127.0.0.1 --port 8000

Open http://127.0.0.1:8000 in your browser.

7. (Optional) Start Telegram Bot

python -m bot.telegram_bot

Then open Telegram, find your bot, and send /start.

Frontend Usage

  • Open http://127.0.0.1:8000 to 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.

Architecture

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

Skill System

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 execution
  • scripts/ โ€” 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:

  1. Intent routing: main_agent.py reads all SKILL.md descriptions and routes to the appropriate skill
  2. Execution: Python code calls the selected skill's script, which uses SKILL.md as the LLM prompt

This design improves reliability with smaller local models (7B parameters).

Acknowledgements

Built with the assistance of Claude (Anthropic) and Cursor (Anysphere).

About

๐ŸงฉMOSAIC is a privacy-first local journaling companion that turns fragmented daily inputs into coherent diary entries, idea lists, emotional insights, and periodic reflections, while also supporting everyday conversation, fully offline and with no API key required.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors