A private, self-hosted AI assistant with persistent memory, voice interaction, and agentic capabilities β accessible as a PWA from any device, including instant launch via the iPhone Action Button.
| Category | Capabilities |
|---|---|
| ποΈ Voice Interface | Real-time Speech-to-Text via Faster Whisper (GPU-accelerated), natural TTS responses |
| π§ Persistent Memory | Long-term memory with ChromaDB vector embeddings β your companion remembers everything |
| π¬ Conversational AI | Powered by OpenRouter with support for multiple LLM backends (GPT-4o, Claude, Llama, etc.) |
| π§ Agentic Tools | Code execution sandbox, web research, email integration, and extensible tool system |
| π± PWA | Installable Progressive Web App with offline support and iPhone Action Button integration |
| π³ Fully Dockerized | One-command deployment with GPU passthrough β zero host pollution |
βββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend β
β React / Vite -> PWA -> Web Audio API β
βββββββββββββββββββββββββββββββββββββββββββββββββ€
β Backend β
β FastAPI -> Faster Whisper -> ChromaDB β
β SQLite -> OpenRouter SDK -> TTS Engine β
βββββββββββββββββββββββββββββββββββββββββββββββββ€
β Infrastructure β
β Docker Compose -> NVIDIA Container Toolkit β
βββββββββββββββββββββββββββββββββββββββββββββββββ
| Requirement | Version | Notes |
|---|---|---|
| Docker Desktop | 24.0+ | or Docker Engine on Linux |
| NVIDIA Container Toolkit | Latest | Required for GPU-accelerated STT |
| NVIDIA GPU | 6 GB+ VRAM | For Whisper large-v3; smaller models need less |
| Git | 2.0+ | For cloning the repository |
Note
GPU is required for local Whisper STT. If you don't have an NVIDIA GPU, you can switch STT_MODE to api in your .env to use a cloud-based STT provider instead.
# 1. Clone the repository
git clone https://github.com/your-username/AI_Companion.git
cd AI_Companion
# 2. Create your environment file
cp .env.example .env
# 3. Edit .env with your API keys
# At minimum, set OPENROUTER_API_KEY
nano .env # or use your preferred editor
# 4. Build and launch
docker compose up --build
# 5. Open the app
# Frontend: http://localhost:3000
# Backend: http://localhost:8000/docs (Swagger UI)Tip
Use docker compose up --build -d to run in detached mode. View logs with docker compose logs -f.
The backend exposes a RESTful API at http://localhost:8000. Full interactive documentation is available at /docs (Swagger UI) and /redoc (ReDoc).
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/chat |
Send a text message and receive an AI response |
POST |
/api/voice/transcribe |
Upload audio for Speech-to-Text transcription |
POST |
/api/voice/synthesize |
Convert text to speech audio |
GET |
/api/memory/search |
Search long-term memory by semantic query |
POST |
/api/memory/add |
Manually add an entry to long-term memory |
GET |
/api/conversations |
List all conversation sessions |
GET |
/api/conversations/{id} |
Retrieve a specific conversation history |
DELETE |
/api/conversations/{id} |
Delete a conversation session |
POST |
/api/tools/execute |
Execute code in the sandboxed environment |
POST |
/api/tools/research |
Perform web research on a topic |
GET |
/api/health |
Health check and system status |
- Navigate to
http://localhost:3000 - Click the install icon in the address bar
- Click Install
- Open Safari and navigate to
https://your-host:3000 - Tap Share β Add to Home Screen
- (Optional) Set up the Action Button for instant voice access β see the iOS Action Button Setup Guide
- Navigate to
https://your-host:3000 - Tap the "Add to Home Screen" banner, or Menu β Install App
- Auth Rate Limiting: The backend enforces sliding-window rate limiting on
/api/auth/login(5 attempts/min) and/api/auth/refresh(20 attempts/min) returning HTTP 429 withRetry-Afterheaders to protect against brute-force attacks and token replay. - Offline Fallback Experience: Built-in responsive
offline.htmlfallback with live connection health diagnostics and automatic reconnect polling when internet connectivity drops. - Rich App Manifest: Enhanced PWA manifest with application shortcuts (Start Voice Chat, 3D Avatars), categories, and maskable icons for desktop and mobile install dialogs.
Run the test suites across backend and frontend inside the dev container:
# Backend pytest suite (auth, rate limiting, and security invariants)
cd backend && .venv/bin/python -m pytest
# Frontend test suite (API client, token refresh coalescing, and PWA manifest)
cd frontend && npm testAI_Companion/
βββ backend/ # FastAPI backend service
β βββ Dockerfile
β βββ requirements.txt
β βββ main.py # Application entry point
β βββ api/ # Route handlers
β β βββ chat.py
β β βββ voice.py
β β βββ memory.py
β β βββ tools.py
β βββ core/ # Business logic
β β βββ llm.py # OpenRouter LLM integration
β β βββ stt.py # Faster Whisper STT engine
β β βββ tts.py # Text-to-Speech engine
β β βββ memory.py # ChromaDB vector memory
β β βββ sandbox.py # Code execution sandbox
β βββ models/ # Pydantic schemas
βββ frontend/ # React PWA frontend
β βββ Dockerfile
β βββ package.json
β βββ vite.config.js
β βββ public/
β β βββ manifest.json # PWA manifest
β βββ src/
β βββ App.jsx
β βββ components/ # UI components
β βββ services/ # API client modules
βββ data/ # Persistent data (git-ignored)
β βββ companion.db # SQLite database
β βββ chromadb/ # Vector embeddings
βββ sandbox/ # Code execution workspace (git-ignored)
βββ docs/ # Documentation
β βββ ios-action-button-setup.md
βββ docker-compose.yml # Container orchestration
βββ .env # Environment variables (git-ignored)
βββ .env.example # Environment template (safe to commit)
βββ .gitignore
βββ LICENSE
βββ README.md
- Docker infrastructure with GPU passthrough
- FastAPI backend with health checks
- Faster Whisper STT integration
- OpenRouter LLM chat pipeline
- SQLite conversation persistence
- React PWA frontend with voice recording
- ChromaDB long-term vector memory
- Semantic memory search and recall
- Agentic tool system (code execution, web research)
- TTS voice response pipeline
- Conversation context management
- iPhone Action Button integration & auto-record
- Email sending capability
- Multi-modal input (images, documents)
- Custom personality and system prompts
- Scheduled tasks and reminders
- Plugin architecture for community tools
Contributions are welcome! Please open an issue or submit a pull request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ and a healthy distrust of cloud-only AI
## Authentication setupBefore exposing this instance, follow Authentication and trusted accounts. The development ports bind to localhost. Registration and demo login are disabled by default; create the first trusted account locally, then disable registration. All operational API requests require a Bearer token. The frontend handles token attachment, refresh, and sign-out.