Skip to content
/ ATRI Public template
forked from MIKUSCAT/ATRI

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

License

Notifications You must be signed in to change notification settings

nsjsv/ATRI

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

57 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿค– ATRI - Emotionally Evolving AI Companion

Your personal AI who remembers, reflects, and grows alongside you

Android Cloudflare AI License


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


ATRI

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
Emotions change instantly ๐ŸŽญ PAD 3D emotion model + natural decay, emotions have inertia
One-size-fits-all responses ๐Ÿ’• Intimacy system affects speaking style, relationships grow
May fabricate memories ๐Ÿ” Tool registration mechanism, actively verifies when needed

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     ๐Ÿ“ฑ Android App (Kotlin)                      โ”‚
โ”‚              Jetpack Compose โ€ข Room โ€ข DataStore                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ HTTPS + Token Auth
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚               โ˜๏ธ Cloudflare Worker (TypeScript)                  โ”‚
โ”‚    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”        โ”‚
โ”‚    โ”‚   D1    โ”‚    โ”‚   R2    โ”‚    โ”‚     Vectorize       โ”‚        โ”‚
โ”‚    โ”‚Database โ”‚    โ”‚ Storage โ”‚    โ”‚   Vector Database   โ”‚        โ”‚
โ”‚    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ OpenAI-Compatible API
                           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   ๐Ÿค– AI Model Service (Swappable)                โ”‚
โ”‚        OpenAI โ€ข Claude โ€ข Gemini โ€ข DeepSeek โ€ข Local Models        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿš€ Quick Start

๐Ÿ“‹ Prerequisites

Requirement Description
๐Ÿ’ป Computer (Windows / macOS / Linux)
โ˜๏ธ Cloudflare account (free)
๐Ÿ”‘ OpenAI API Key or compatible API
๐Ÿ“ฆ Node.js 18+
๐Ÿ Python 3.8+

1๏ธโƒฃ Deploy the Backend

๐ŸชŸ Option A: Windows One-Click Deploy (Recommended for beginners)
  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, SiliconFlow recommended)
    • Other optional secrets (can skip)
  3. The script will automatically create resources and deploy
  4. Copy the Worker URL when done
๐ŸŽ Option B: macOS / Linux Manual Deploy
# 1. Clone the project
git clone https://github.com/your-username/ATRI.git
cd ATRI

# 2. Install dependencies
cd worker && npm install

# 3. Login to Cloudflare
npx wrangler login

# 4. Create D1 database
npx wrangler d1 create atri_diary
# Copy the database_id from output and paste into worker/wrangler.toml

# 5. Initialize database tables
npx wrangler d1 execute atri_diary --file=db/schema.sql

# 6. Create R2 bucket
npx wrangler r2 bucket create atri-media

# 7. Create Vectorize index
npx wrangler vectorize create atri-memories --dimensions=1024 --metric=cosine

# 8. Set secrets
npx wrangler secret put OPENAI_API_KEY

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

After successful deployment, you'll see the Worker URL:

โœจ https://atri-worker.your-subdomain.workers.dev

๐Ÿ” Configure Secrets

Secret Description Required
OPENAI_API_KEY Chat model API key โœ…
EMBEDDINGS_API_KEY Embeddings API key for vector memory (SiliconFlow recommended) โœ…
APP_TOKEN Client access token to protect API Recommended

2๏ธโƒฃ Install the Android App

๐Ÿ“ฅ Download APK from Releases

Build a signed release APK (recommended)
  1. Go to ATRI/
  2. Copy keystore.properties.example -> keystore.properties (do not commit it)
  3. Generate a keystore (Windows example):
    • keytool -genkeypair -v -keystore keystore\\atri-release.jks -alias atri -keyalg RSA -keysize 2048 -validity 10000
  4. Fill passwords in ATRI/keystore.properties
  5. Build:
    • cd ATRI && .\\gradlew.bat :app:assembleRelease

Output: ATRI/app/build/outputs/apk/release/app-release.apk

3๏ธโƒฃ Initial Setup

Step Action
1 Welcome Screen: Set your nickname and avatar
2 Settings (tap โš™๏ธ icon): Enter Worker URL and App Token
3 Select Model: Choose a model based on your API
4 Start Chatting โœจ

โš ๏ธ Troubleshooting

โ“ Deploy script says "node not found"

Install Node.js 18+: https://nodejs.org/

โ“ Deploy script says "Python not found"

Install Python 3.8+: https://www.python.org/downloads/

โ“ wrangler login keeps spinning

Check your network connection. You may need a VPN in some regions.

โ“ Chat not responding
  1. Verify Worker URL is correct
  2. Check if OPENAI_API_KEY is valid
  3. Check Worker logs in Cloudflare dashboard
โ“ Diary not generating

Diaries are generated daily at 23:59 Beijing time. There must be conversation records for that day. You can also manually trigger regeneration on the diary page.

โ“ How to use other AI services?

Any OpenAI-compatible API works:

  1. Edit OPENAI_API_URL in worker/wrangler.toml
  2. Optional: Configure separate DIARY_API_URL / DIARY_MODEL (diary generation can use a different model)
  3. Embeddings (vector memory): by default it's https://api.siliconflow.cn/v1 + BAAI/bge-m3
    • Set EMBEDDINGS_API_KEY (SiliconFlow API key)
    • Optional: override EMBEDDINGS_API_URL / EMBEDDINGS_MODEL
  4. Redeploy: cd worker && npx wrangler deploy

โœจ Key Features

๐ŸŽญ

In-Character
Authentic personality
defined in prompts.json

๐Ÿ’ฌ

Context Memory
Today's conversations
inform responses

๐Ÿ“–

Auto Diary
Nightly reflections
from her perspective

๐Ÿง 

Long-term Memory
Vector-stored memories
awakened when needed

๐Ÿ–ผ๏ธ

Rich Media
Send images or docs
she understands them

๐Ÿ”ฌ Technical Highlights

Feature Description
PAD Emotion Model 3D emotion coordinates (Pleasure/Arousal/Dominance) + natural decay
Intimacy System Relationship temperature affects reply style, fades without maintenance
Tool Registration Model actively verifies memories, doesn't fabricate
Split Architecture Chat and diary can use different upstreams independently
Signed Access Control Path-based signatures solve model dropping query params

๐Ÿ–ผ๏ธ UI Preview


Welcome
Set nickname and avatar

Chat
Immersive chat experience

Sidebar
Status and quick actions

Diary
View ATRI's diary entries

Settings
Configure backend and model

๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ ATRI/                    # ๐Ÿ“ฑ Android App
โ”‚   โ”œโ”€โ”€ app/src/main/
โ”‚   โ”‚   โ”œโ”€โ”€ java/me/atri/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ data/        # Data layer (API, DB, Repository)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ di/          # Dependency Injection (Hilt)
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/          # UI layer (Compose)
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ utils/       # Utilities
โ”‚   โ”‚   โ””โ”€โ”€ res/             # Resources
โ”‚   โ””โ”€โ”€ build.gradle.kts
โ”‚
โ”œโ”€โ”€ worker/                  # โ˜๏ธ Cloudflare Worker
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ routes/          # API routes
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # Core services
โ”‚   โ”‚   โ”œโ”€โ”€ jobs/            # Scheduled jobs
โ”‚   โ”‚   โ””โ”€โ”€ utils/           # Utility functions
โ”‚   โ”œโ”€โ”€ db/schema.sql        # Database schema
โ”‚   โ””โ”€โ”€ wrangler.toml        # Worker config
โ”‚
โ”œโ”€โ”€ shared/                  # ๐Ÿ“ Shared Config
โ”‚   โ””โ”€โ”€ prompts.json         # Personality and prompts
โ”‚
โ””โ”€โ”€ scripts/                 # ๐Ÿ”ง Deployment Scripts
    โ”œโ”€โ”€ deploy_cf.bat        # Windows one-click deploy
    โ””โ”€โ”€ sync_shared.py       # Sync prompts

๐Ÿ“š Learn More

Document Content
๐Ÿ“˜ Tech Architecture Blueprint Design philosophy, data flow, API contracts, extension guide
๐Ÿ“ Personality Definition ATRI's personality, diary generation, memory system prompts
๐Ÿ—„๏ธ Database Schema D1 database table definitions

๐Ÿค Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

Before contributing code, we recommend reading the Tech Architecture Blueprint to understand the system design.


๐Ÿ“„ License

This project is licensed under the PolyForm Noncommercial License 1.0.0.

In short:

  • โœ… Personal learning, research, non-commercial use
  • โŒ Commercial use requires separate authorization


If this project helps you, consider giving it a โญ


Built with โค๏ธ 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

No packages published

Languages

  • Kotlin 66.2%
  • TypeScript 31.3%
  • Batchfile 2.3%
  • Python 0.2%