Skip to content

chinmay404/sunday

Repository files navigation

β˜€οΈ Sunday

An AI that actually knows you.
Autonomous personal assistant with persistent memory, proactive behavior, and zero filter.


Sunday is not a chatbot. It's not a tool. It's a person in your life β€” one that remembers everything, learns your preferences silently, tracks your habits, monitors your location, manages your calendar, and calls you out when you're bullshitting yourself.

Built with LangGraph as a multi-node stateful agent, Sunday runs across Telegram, WhatsApp, Web, and CLI with a shared brain. It has triple-layer memory (episodic + semantic + people graph), five background services running 24/7, and a personality system that makes it feel like talking to someone who actually gives a damn.


🧠 What Makes Sunday Different

Feature What It Means
Triple-layer memory Episodic memories (events with time decay), semantic knowledge graph (entity relationships), and a Neo4j people graph β€” all queried in parallel before every response
Silent knowledge capture Every conversation is mined for people, preferences, relationships, and facts. No "should I remember this?" β€” it just does
5 proactive background services Habit analysis, daily briefings, reminder scheduler, location observer, and Telegram bot β€” all running as daemon threads
Self-wakeup Sunday can schedule itself to check in on you at specific times. It decides when, not you
Strong persona Not a generic assistant. Opinionated, blunt, loyal. Matches your emotional state. Calls out procrastination. Gets excited when you're cooking
Cost-optimized dual-LLM Gemini for user-facing responses, Groq for all background processing (memory extraction, action analysis, summaries)
Cross-platform unified brain Same memory, same personality across CLI, Telegram, WhatsApp, and Web β€” persisted via PostgreSQL
Location awareness Tracks location with dwell detection, named places, arrival/departure events, and proactive contextual messages

πŸ— Architecture

User Message
     β”‚
     β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Context Gatheringβ”‚  ← Calendar, Todoist, Location, Habits,
β”‚   (parallel)     β”‚    Neo4j People, Semantic Graph, Episodic Memory
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Action Analyzer  β”‚  ← Extracts habits/actions from message (cheap LLM)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Agent        β”‚  ← Main LLM with 28 tools bound
β”‚  (Gemini/Groq)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
    β”Œβ”€β”€β”€β”€β”΄β”€β”€β”€β”€β”
    β–Ό         β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ Tools β”‚  β”‚ Memory Processor β”‚  ← Extracts people, preferences,
 β”‚ (28)  β”‚  β”‚  (post-response)  β”‚    relationships, events β†’ stores
 β””β”€β”€β”¬β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    in Postgres + Neo4j
    β”‚
    └──→ loops back to Agent

Background Services (always running)

Service What It Does
πŸ€– Telegram Bot Bidirectional chat, location tracking, user mapping
⏰ Reminder Scheduler Fires reminders and self-wakeups every 30s
πŸ“Š Habit Analyzer Detects inactivity, updates habit profiles, generates nudges
πŸŒ… Daily Briefing Morning summary β€” calendar, tasks, habits, weather
πŸ“ Location Observer Monitors arrivals/departures, dwell time, contextual prompts

πŸ’Ύ Memory System

Episodic Memory (PostgreSQL + pgvector)

Time-stamped event memories with 3072-dimensional embeddings. Hybrid retrieval scoring:

$$\text{score} = \alpha \cdot \text{similarity} + \beta \cdot \text{recency} + \gamma \cdot \text{importance}$$

Supports memory expiry, automatic decay cleanup, importance scoring, and tagging.

Semantic Knowledge Graph (PostgreSQL + pgvector)

Entity-relationship graph with embedding-based entity resolution:

  • Exact name match β†’ Semantic similarity (>0.9) β†’ Create new entity
  • Stores: Chinmay β†’ works_at β†’ Climate KIC, Chinmay β†’ prefers β†’ black coffee

People & Preferences Graph (Neo4j)

(:Person {name: 'Chinmay'}) -[:RELATES_TO {relation: 'mother'}]-> (:Person {name: 'Sunita'})
(:Person {name: 'Chinmay'}) -[:HAS_PREFERENCE {sentiment: 'negative'}]-> (:Preference {key: 'mushrooms'})

Automatic Extraction

The memory processor runs after every response using a cheap LLM with structured output to extract:

  • People β†’ Neo4j + semantic graph
  • Preferences β†’ Neo4j + semantic graph
  • Entity relationships β†’ semantic graph
  • Events β†’ episodic memory

No manual "remember this" needed. It captures everything silently.


πŸ”§ Tools (28)

Category Tools
πŸ” Search Web search (DuckDuckGo)
πŸ“… Calendar & Tasks Add calendar event, add todo item
⏰ Reminders Create, list, cancel reminders + self-wakeup
πŸ’¬ WhatsApp Send messages, lookup contacts, busy mode, pending queue
✈️ Telegram Send messages
πŸ“ Location Current status, save places, list places
πŸ“ Notion Create notes, append content, read pages, query databases, search
🧠 Memory Search memory, forget memory, read webpage
πŸ‘₯ People Add person, update person details, save preference, get person info

🌐 Integrations

Service How
Telegram Python long-polling bot with location tracking
WhatsApp Node.js (whatsapp-web.js) with headless Chromium
Google Calendar OAuth2 with headless/console support
Todoist REST API for task management
Notion Custom API client for notes and databases
Neo4j Aura Cloud graph database for people and preferences
DuckDuckGo Privacy-friendly web search

πŸ›  Tech Stack

Layer Technologies
Agent Framework LangGraph, LangChain
Main LLM Google Gemini 2.5 Flash (switchable)
Background LLM Groq (Llama 3.3 70B)
Embeddings Google gemini-embedding-001 (3072-dim)
Backend Python 3.12, FastAPI, Uvicorn
Frontend Next.js 16, React 19, TypeScript, Tailwind CSS 4, Framer Motion
Primary DB PostgreSQL with pgvector extension
Graph DB Neo4j Aura
Messaging Telegram Bot API, WhatsApp Web.js
Productivity Google Calendar API, Todoist API, Notion API

πŸš€ Getting Started

Prerequisites

  • Python 3.12+
  • PostgreSQL with pgvector extension
  • Node.js 18+ (for WhatsApp integration)
  • Neo4j instance (Aura free tier works)

1. Clone & Install

git clone https://github.com/yourusername/sunday.git
cd sunday
python -m venv env
source env/bin/activate
pip install -r requirement.txt

2. Configure Environment

cp .env.example .env

Required environment variables:

# LLM Providers
GOOGLE_API_KEY=your_gemini_key
GROQ_API_KEY=your_groq_key
MODEL_PROVIDER=google                    # or "groq"
GOOGLE_MODEL=models/gemini-2.5-flash

# Messaging
TELEGRAM_API_TOKEN=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_chat_id

# Databases
POSTGRES_HOST=127.0.0.1
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DBNAME=sunday
NEO4J_URI=neo4j+s://your-instance.databases.neo4j.io
NEO4J_USER=neo4j
NEO4J_PASS=your_neo4j_password

# Productivity
TODOIST_API_KEY=your_todoist_key
NOTION_API_KEY=your_notion_key

# Location
LOCATION_OBSERVER_ENABLE=true
LOCATION_CONTEXT_MODE=always

3. Set Up PostgreSQL

psql -c "CREATE DATABASE sunday;"
psql -d sunday -c "CREATE EXTENSION IF NOT EXISTS vector;"

4. Set Up WhatsApp (optional)

cd integrations/whatsapp
npm install
node login.js  # Scan QR code once

View full WhatsApp instructions

5. Run

# CLI mode (includes all background services)
python -m llm.main

# API server mode
uvicorn llm.api:app --host 0.0.0.0 --port 8000

# Frontend
cd frontend && npm install && npm run dev

πŸ“ Project Structure

sunday/
β”œβ”€β”€ llm/                          # Core AI system
β”‚   β”œβ”€β”€ main.py                   # CLI entry point + background services
β”‚   β”œβ”€β”€ api.py                    # FastAPI server
β”‚   β”œβ”€β”€ graph/
β”‚   β”‚   β”œβ”€β”€ graph.py              # LangGraph pipeline definition
β”‚   β”‚   β”œβ”€β”€ postgres_saver.py     # Custom checkpoint persistence
β”‚   β”‚   β”œβ”€β”€ states/               # State schema (ChatState)
β”‚   β”‚   β”œβ”€β”€ nodes/                # Graph nodes (context, agent, memory, action)
β”‚   β”‚   β”œβ”€β”€ tools/                # 28 tools across 10 categories
β”‚   β”‚   β”œβ”€β”€ memory/               # Episodic + Semantic memory systems
β”‚   β”‚   β”œβ”€β”€ habits/               # Action logging, habit synthesis, scheduler
β”‚   β”‚   └── model/                # LLM factory (Gemini / Groq)
β”‚   β”œβ”€β”€ services/                 # Neo4j, location, time manager
β”‚   β”œβ”€β”€ prompts/                  # Persona prompts (owner.md, guest.md)
β”‚   └── helpers/                  # Embeddings, utilities
β”œβ”€β”€ integrations/
β”‚   β”œβ”€β”€ telegram/                 # Telegram bot (Python)
β”‚   β”œβ”€β”€ whatsapp/                 # WhatsApp bot (Node.js)
β”‚   └── notion/                   # Notion API client
β”œβ”€β”€ frontend/                     # Next.js 16 web interface
β”œβ”€β”€ requirement.txt               # Python dependencies
└── .env                          # Configuration

🎭 Personality

Sunday has a 260-line persona prompt. It's not a polite assistant:

  • Opinionated β€” has strong views and will argue
  • Blunt β€” no sugarcoating, no corporate speak
  • Loyal β€” cares about you, not about being liked
  • Context-aware β€” adjusts tone to your state (tired β†’ calm, hyped β†’ match energy, spiraling β†’ ground)
  • Proactive β€” checks calendar before you ask, saves memories without being told, wakes itself up to check on you

It also has a guest mode β€” when someone else messages, Sunday becomes a professional gatekeeper.


🏷️ Topics

ai-assistant langgraph langchain personal-ai autonomous-agent memory-system knowledge-graph neo4j postgresql pgvector telegram-bot whatsapp-bot google-gemini groq fastapi nextjs react typescript python proactive-ai habit-tracking location-aware multi-platform conversational-ai vector-database embeddings notion-api google-calendar


πŸ“„ License

MIT


Sunday doesn't reset every conversation. It builds on what's already happening.