Skip to content

nsjsv/ATRI

 
 

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 │   OR    │   🖥️ VPS / Zeabur Server      │
│  D1 + R2 + Vectorize  │         │  Fastify + PostgreSQL/pgvector│
└───────────────────────┘         └───────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────────────┐
│              🤖 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 Beginners, low cost Serverless, free tier, simple setup
🖥️ VPS / Zeabur Advanced users Web admin panel, PostgreSQL, compat API, more control


🔧 Backend Deployment

✅ Option A: Zeabur One-Click Deploy (Recommended)

Deploy on Zeabur


  1. Click the button above

  2. Fill in only 2 variables:

    • DOMAIN - Public domain bound to the API service (must match the publicly exposed domain)
    • PASSWORD - Your password (used for admin login and client auth)

    💡 PASSWORD can be a strong password (special characters like @ : / # ? are safe)

    ⚠️ Important: DOMAIN must match the actual public domain, otherwise the admin panel may fail with CORS / bad_origin

  3. Wait for deployment to complete

  4. Visit your domain to access the admin panel

  5. Configure upstream API (OpenAI/Claude/Gemini) in the admin panel

📝 Note: The Android client and web frontend use the same public API paths on both backends (Cloudflare Workers and VPS/Zeabur), so switching backends is just changing the base URL.


☁️ Option B: Cloudflare Workers

🪟 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 database_id from step 3

# 5. Initialize and deploy
npx wrangler d1 execute atri_diary --file=db/schema.sql
npx wrangler secret put OPENAI_API_KEY
cd .. && python3 scripts/sync_shared.py
cd worker && npx wrangler deploy

🐳 Option C: Docker Compose (Self-hosted VPS)

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

📖 See server/README.md for detailed VPS deployment guide.



📲 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
🌐 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 (VPS) Runtime config, prompt editing, encrypted secrets management
🔌 Compat API (VPS) OpenAI / Anthropic / Gemini compatible endpoints for third-party clients


🖼️ 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, Zeabur, 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 💖


About

ATRI - Emotionally Evolving AI Companion (Android + Cloudflare Worker)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 52.8%
  • Kotlin 34.2%
  • JavaScript 5.8%
  • HTML 2.8%
  • CSS 1.9%
  • Shell 1.2%
  • Other 1.3%