Skip to content

MIKUSCAT/ATRI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

111 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ATRI

โœจ ATRI - Emotionally Evolving AI Companion โœจ

๐Ÿ’• Your personal AI who remembers, reflects, and grows alongside you ๐Ÿ’•


Android Backend AI License


Stars Forks Issues


๐ŸŒ Language: English | ็ฎ€ไฝ“ไธญๆ–‡


"An AI companion that remembers, grows, and maintains emotional continuity"


๐Ÿš€ Quick Start โ€ข โœจ Features โ€ข ๐Ÿ“ธ Screenshots โ€ข ๐Ÿ“š Documentation



๐Ÿ’ญ What is ATRI?

ATRI is an Android app + cloud backend AI companion project. Unlike ordinary chatbots, she has:



๐Ÿ“ฑ ATRI on Your Phone

Chat with her anytime, anywhere
Send images and documents



๐Ÿ“” Nightly Diary

She records what happened today
Written from her perspective



๐Ÿง  Long-term Memory

Diaries become "memories"
Recalled in future conversations



๐ŸŽฏ What Makes It Different?

๐Ÿค– Traditional Chatbots ๐Ÿ’– ATRI's Approach
Every conversation starts fresh Remembers everything important via diary + vector memory + real-time facts
Emotions change instantly Status capsule system + intimacy decay, moods have inertia
One-size-fits-all responses Intimacy system affects speaking style, relationships grow
May fabricate memories Tool registration mechanism with 8 tools, actively verifies via search/diary/web


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     ๐Ÿ“ฑ Android App (Kotlin)                     โ”‚
โ”‚              Jetpack Compose โ€ข Room โ€ข DataStore                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ ๐Ÿ” HTTPS + Token Auth
                           โ–ผ
               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
               โ”‚  โ˜๏ธ Cloudflare Workers โ”‚  โ† Recommended
               โ”‚  D1 + R2 + Vectorize  โ”‚
               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚  (VPS/Docker also supported,
                           โ”‚   see server/README.md)
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              ๐Ÿค– AI Model Service (Native Multi-Format)          โ”‚
โ”‚     OpenAI โ€ข Claude โ€ข Gemini โ€ข DeepSeek โ€ข Local Models          โ”‚
โ”‚     (OpenAI / Anthropic / Gemini API format auto-adapt)         โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜


๐Ÿš€ Quick Start

๐Ÿ“ฆ Choose Your Backend

Option Best For Features
โ˜๏ธ Cloudflare Workers (Recommended) Beginners, low cost Serverless, free tier, simple setup
๐Ÿ–ฅ๏ธ VPS / Docker Advanced users Web admin panel, PostgreSQL, compat API, more control


๐Ÿ”ง Backend Deployment

โ˜๏ธ Option A: Cloudflare Workers (Recommended)

๐ŸชŸ Windows One-Click Deploy

  1. Double-click scripts/deploy_cf.bat
  2. Follow the prompts to enter:
    • Worker name (press Enter for default)
    • D1 database name (press Enter for default)
    • R2 bucket name (press Enter for default)
    • Vectorize index name (press Enter for default)
    • OPENAI_API_KEY (required)
    • EMBEDDINGS_API_KEY (required for vector memory)
  3. The script will automatically create resources and deploy
  4. Copy the Worker URL when done

๐ŸŽ macOS / ๐Ÿง Linux / Manual Deploy

# 1. Clone and install
git clone https://github.com/MIKUSCAT/ATRI.git
cd ATRI/worker && npm install

# 2. Login to Cloudflare
npx wrangler login

# 3. Create resources
npx wrangler d1 create atri_diary
npx wrangler r2 bucket create atri-media
npx wrangler vectorize create atri-memories --dimensions=1024 --metric=cosine

# 4. Update wrangler.toml with your account_id and database_id from step 3

# 5. Run database migrations
npx wrangler d1 execute atri_diary --file=db/schema.sql
npx wrangler d1 execute atri_diary --file=migrations/0004_add_fact_memories.sql
npx wrangler d1 execute atri_diary --file=migrations/0005_add_conversation_tombstones.sql
npx wrangler d1 execute atri_diary --file=migrations/0006_add_reply_to.sql
npx wrangler d1 execute atri_diary --file=migrations/0007_add_proactive_tables.sql
npx wrangler d1 execute atri_diary --file=migrations/0008_add_runtime_settings_tables.sql

# 6. Set secrets
npx wrangler secret put OPENAI_API_KEY
npx wrangler secret put EMBEDDINGS_API_KEY
npx wrangler secret put APP_TOKEN
# Optional: npx wrangler secret put TAVILY_API_KEY
# Optional: npx wrangler secret put DIARY_API_KEY

# 7. Sync shared prompts and deploy
cd .. && python3 scripts/sync_shared.py
cd worker && npx wrangler deploy

๐Ÿ“ Note: The Android client uses the same API paths on both backends, so switching is just changing the base URL.


๐Ÿ–ฅ๏ธ Option B: VPS / Docker (Advanced)

cd server
cp .env.example .env
# Edit .env with your configuration
docker-compose up -d

๐Ÿ“– See server/README.md for detailed VPS deployment guide (Docker, 1Panel, Baota).



๐Ÿ“ฒ Install the Android App

Step Action
1๏ธโƒฃ Download APK from Releases
2๏ธโƒฃ Install and open the app
3๏ธโƒฃ Set your nickname on the welcome screen
4๏ธโƒฃ Go to Settings (โš™๏ธ) and configure: API URL, App Token, Model


โœจ Key Features


๐ŸŽญ

In-Character
Authentic personality
defined in prompts.json



๐Ÿ’ฌ

Context Memory
Today + yesterday's chats
inform responses



๐Ÿ““

Auto Diary
Nightly reflections
from her perspective



๐Ÿง 

Long-term Memory
Vector-stored memories
+ real-time facts



๐Ÿ–ผ๏ธ

Rich Media
Send images or docs
she understands them



๐Ÿ”ฌ Technical Highlights

Feature Description
๐ŸŽจ Status Capsule Dynamic mood status with label text + color, model-driven updates via set_status tool
๐Ÿ’• Intimacy System Relationship temperature affects reply style, fades without maintenance
๐Ÿ”ง 8 Registered Tools search_memory read_diary read_conversation web_search set_status update_intimacy remember_fact forget_fact
๐Ÿ“ฌ Proactive Messages ATRI can initiate conversations on her own; supports Email / WeChat Work notifications
๐ŸŒ Native Multi-Format Natively supports OpenAI, Anthropic (Claude), and Gemini API formats
๐Ÿ”€ Split Architecture Chat and diary can use different upstreams independently
๐ŸŒ Web Admin Panel Runtime config, prompt editing, encrypted secrets management (VPS only)
๐Ÿ”Œ Compat API OpenAI / Anthropic / Gemini compatible endpoints for third-party clients (VPS only)


๐Ÿ–ผ๏ธ UI Preview


๐Ÿ‘‹ Welcome

๐Ÿ’ฌ Chat

๐Ÿ“‹ Sidebar

๐Ÿ“” Diary

โš™๏ธ Settings


๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ ๐Ÿ“ฑ ATRI/                 # Android App (Kotlin / Jetpack Compose)
โ”‚   โ”œโ”€โ”€ app/src/main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/me/atri/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ data/        # Data layer (API, DB, Repository, DataStore)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ di/          # Dependency Injection (Koin)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/          # UI layer (Compose screens & components)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils/       # Utilities
โ”‚   โ”‚   โ””โ”€โ”€ res/             # Resources
โ”‚   โ””โ”€โ”€ build.gradle.kts
โ”‚
โ”œโ”€โ”€ โ˜๏ธ worker/               # Cloudflare Worker Backend
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ routes/          # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # Core services
โ”‚   โ”‚   โ””โ”€โ”€ utils/           # Utility functions
โ”‚   โ”œโ”€โ”€ db/schema.sql        # Database schema
โ”‚   โ””โ”€โ”€ wrangler.toml        # Worker config
โ”‚
โ”œโ”€โ”€ ๐Ÿ–ฅ๏ธ server/               # VPS Backend (Fastify + PostgreSQL + pgvector)
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ routes/          # API routes (chat, diary, conversation, media, admin, admin-ui, models, compat)
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # Core services (agent, LLM, memory, diary, profile, runtime-settings)
โ”‚   โ”‚   โ”œโ”€โ”€ jobs/            # Scheduled jobs (diary-cron, diary-scheduler, memory-rebuild)
โ”‚   โ”‚   โ”œโ”€โ”€ runtime/         # Environment & types
โ”‚   โ”‚   โ”œโ”€โ”€ admin/           # Admin log buffer
โ”‚   โ”‚   โ”œโ”€โ”€ config/          # Default prompts
โ”‚   โ”‚   โ”œโ”€โ”€ utils/           # Utilities (auth, media-signature, attachments, sanitize)
โ”‚   โ”‚   โ””โ”€โ”€ scripts/         # Build & import scripts
โ”‚   โ”œโ”€โ”€ admin-ui/            # Web admin panel (static assets)
โ”‚   โ”œโ”€โ”€ docker-compose.yml
โ”‚   โ”œโ”€โ”€ Dockerfile
โ”‚   โ””โ”€โ”€ zeabur.yaml          # Zeabur deployment config
โ”‚
โ”œโ”€โ”€ ๐Ÿ”— shared/               # Shared Config
โ”‚   โ””โ”€โ”€ prompts.json         # Personality and prompts
โ”‚
โ””โ”€โ”€ ๐Ÿ“œ scripts/              # Deployment Scripts
    โ”œโ”€โ”€ deploy_cf.bat        # Windows CF deploy
    โ””โ”€โ”€ sync_shared.py       # Sync prompts


๐Ÿ“š Learn More

๐Ÿ“„ Document ๐Ÿ“ Content
๐Ÿ›๏ธ Tech Architecture Blueprint Design philosophy, data flow, API contracts
๐Ÿš€ VPS Deployment Guide Docker, 1Panel, Baota deployment
๐ŸŽญ Personality Definition ATRI's personality and prompts


๐Ÿค Contributing

Contributions are welcome!

Feel free to open issues or submit pull requests.


Contributors



๐Ÿ“„ License

This project is licensed under the PolyForm Noncommercial License 1.0.0.

  • โœ… Personal learning, research, non-commercial use allowed
  • โš ๏ธ Commercial use requires separate authorization



โญ Star History

Star History Chart




๐ŸŒŸ If this project helps you, consider giving it a Star ๐ŸŒŸ


๐Ÿ’– Built with love for those who believe AI can be more than just a tool ๐Ÿ’–