Back to Projects

XiaoxingAI

xiaoxingai

A multi-user Gmail automation platform that turns inbox activity into structured AI analysis, Telegram notifications, and controllable reply workflows.

Role: Solo Developer

Highlights

PythonFastAPIReactTypeScriptViteTailwind CSSPostgreSQLRedisllama.cppOpenAI API
  • Built a multi-user Gmail automation platform with per-user OAuth, isolated workers, AI analysis, and Telegram delivery.
  • Designed a two-stage email pipeline for classification and summarisation, then rendered deterministic Telegram notifications from validated AI output.
  • Implemented reply-draft and outgoing email workflows with Telegram confirmation buttons, encrypted draft storage, TTL control, and action audit logs.
  • Added a configurable tool system with Router LLM dispatch and keyword fallback, so user commands can call safe backend tools predictably.
  • Created a React and TypeScript admin dashboard for worker status, Gmail settings, prompt editing, user management, debug logs, and bilingual EN/ZH UI.

Problem

Email is noisy, time-sensitive, and difficult to manage when every message requires manual reading, prioritisation, and follow-up.

Most AI email tools hide their decision flow, making it hard to understand why a message was summarised, ignored, or turned into an action.

A personal automation system needs user isolation, retry-safe background workers, visible logs, and clear boundaries around LLM output before it can be trusted.

Approach

I designed XiaoxingAI as an inspectable automation pipeline rather than a black-box chatbot: Gmail ingestion, AI analysis, persistence, notification, and optional reply workflows are separated into clear layers.

I kept each user’s Gmail credentials, settings, worker state, Telegram bot binding, prompts, and processed email records isolated at the application and database level.

I combined local llama.cpp inference with OpenAI-compatible APIs, Redis caching, structured output validation, and fallback paths to balance cost, latency, and reliability.

Result

Delivered a working AI email automation system that can process real Gmail messages with user-scoped settings, persistent records, and Telegram notifications.

Turned inbox processing into an observable workflow with configurable prompts, worker controls, logs, and structured database records.

Created a practical foundation for personal assistant workflows where LLM reasoning is bounded by deterministic storage, delivery, confirmation, and audit layers.

Implementation

Gmail automation pipeline

  • Implemented per-user Gmail polling workers with configurable query, poll interval, priority filter, and mark-as-read behaviour
  • Built a two-stage AI flow for email classification and summarisation before converting results into predictable Telegram messages
  • Added deduplication around processed email records so repeated polling does not create duplicate notifications

Telegram and outgoing workflows

  • Integrated Telegram delivery for email notifications, worker feedback, and user-facing automation results
  • Built outgoing reply draft workflows with confirmation and cancellation buttons through Telegram callback actions
  • Stored outgoing draft bodies with encryption, expiry windows, status tracking, and action logs for traceability

User isolation and backend architecture

  • Structured the FastAPI backend around resource-specific routes, service layers, Pydantic schemas, and repository-style SQL modules
  • Used PostgreSQL for users, bots, prompts, OAuth tokens, email records, outgoing drafts, worker stats, and logs
  • Used Redis for short-lived state such as LLM cache, deduplication, message tracking, and JWT token versioning

LLM routing and tool system

  • Built a unified LLM client that supports local llama.cpp servers and OpenAI-compatible API models behind one interface
  • Added retries, error handling, response caching, and JSON extraction paths to reduce failures from inconsistent model output
  • Implemented a tool registry with Router LLM dispatch and keyword fallback for safe backend actions such as fetching emails or reading local records

Frontend and observability

  • Developed a React, Vite, and TypeScript dashboard with pages for Gmail, Settings, Prompts, Users, Debug, and System health
  • Added WebSocket status updates and structured logs so worker behaviour and failures can be inspected while the system is running
  • Implemented EN/ZH i18n and a light minimal interface for managing prompts, user configuration, worker controls, and runtime visibility

Lessons

  • Reliable AI automation depends more on state management, retries, observability, and fallback paths than on the model alone.
  • Separating AI reasoning from deterministic rendering makes notifications and workflow actions easier to validate and debug.
  • Per-user isolation should be designed early because Gmail OAuth, Telegram bots, prompts, workers, and logs all become harder to separate later.
  • For personal automation, a visible and controllable workflow is more trustworthy than a fully autonomous black box.