Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5ba367d
wow giga commit
AnkushMalaker Aug 30, 2025
88dd825
whoops
AnkushMalaker Aug 30, 2025
5491d66
python trial
AnkushMalaker Aug 30, 2025
61fa5ef
updated init
AnkushMalaker Sep 1, 2025
e6de82e
perms
AnkushMalaker Sep 1, 2025
2646c93
better init
AnkushMalaker Sep 1, 2025
a26729c
hehe
AnkushMalaker Sep 1, 2025
e595f3e
hellz yea
AnkushMalaker Sep 1, 2025
0612587
fix
AnkushMalaker Sep 1, 2025
4667ceb
another 1
AnkushMalaker Sep 1, 2025
3d5d9a2
services
AnkushMalaker Sep 1, 2025
7649948
uh whaaa
AnkushMalaker Sep 1, 2025
489932c
huh losing it now
AnkushMalaker Sep 1, 2025
641e304
fix
AnkushMalaker Sep 1, 2025
e783d01
fix
AnkushMalaker Sep 1, 2025
cb5920d
tiny fix
AnkushMalaker Sep 1, 2025
165d2f1
fix: fix type error in services.py
AnkushMalaker Sep 1, 2025
8904def
fix services script
AnkushMalaker Sep 1, 2025
33f5c17
update
AnkushMalaker Sep 1, 2025
16d30e0
ugh
AnkushMalaker Sep 1, 2025
7ce256b
fix
AnkushMalaker Sep 1, 2025
87c9931
ssl gen
AnkushMalaker Sep 1, 2025
4c9d552
how many times can I do this before the universe stops me, before som…
AnkushMalaker Sep 1, 2025
4de7ec0
hm
AnkushMalaker Sep 1, 2025
ec53ca3
template
AnkushMalaker Sep 1, 2025
dffcc2d
the universe doesnt care?
AnkushMalaker Sep 2, 2025
8a02f65
ignore .env backupds
AnkushMalaker Sep 2, 2025
d25d6c6
fix test
AnkushMalaker Sep 2, 2025
69d5524
Update backends/advanced/init.py
AnkushMalaker Sep 5, 2025
939c2a1
refactor based on coderabbit suggestions
AnkushMalaker Sep 5, 2025
6a442d3
More fixes based on suggestions, add backup for .env files properly
AnkushMalaker Sep 5, 2025
ffce264
fix
AnkushMalaker Sep 5, 2025
d3f53f1
Update Docs/init-system.md
AnkushMalaker Sep 5, 2025
f9ef977
Update Docs/init-system.md
AnkushMalaker Sep 5, 2025
f710193
lastfixes
AnkushMalaker Sep 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ backends/advanced-backend/data/speaker_model_cache/
*.bin
*.sqlite3
*checkpoints

extras/openmemory-mcp/data/*
.env.backup.*
9 changes: 7 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,9 @@ The sophisticated in-house memory implementation with full control and customiza
- Individual fact storage (no JSON blobs)
- Smart deduplication algorithms
- Intelligent memory updates (ADD/UPDATE/DELETE decisions)
- Direct Qdrant vector storage
- **Semantic search** with relevance threshold filtering
- **Memory count API** with total count tracking from native Qdrant
- Direct Qdrant vector storage with accurate similarity scoring
- Custom memory prompts and processing
- No external dependencies

Expand Down Expand Up @@ -518,10 +520,12 @@ Thin client that delegates all memory processing to external OpenMemory MCP serv
| **Processing** | Custom LLM extraction | Delegates to OpenMemory |
| **Deduplication** | Custom algorithms | OpenMemory handles |
| **Vector Storage** | Direct Qdrant | OpenMemory handles |
| **Search Features** | Semantic search with threshold filtering | Semantic search with relevance scoring |
| **Memory Count** | Native Qdrant count API | Varies by OpenMemory support |
| **Dependencies** | Qdrant + MongoDB | External OpenMemory server |
| **Customization** | Full control | Limited to OpenMemory features |
| **Cross-client** | Friend-Lite only | Works with Claude Desktop, Cursor, etc |
| **Web UI** | Friend-Lite WebUI | OpenMemory UI + Friend-Lite WebUI |
| **Web UI** | Friend-Lite WebUI with advanced search | OpenMemory UI + Friend-Lite WebUI |
| **Memory Format** | Individual facts | OpenMemory format |
| **Setup Complexity** | Medium | High (external server required) |

Expand Down Expand Up @@ -640,6 +644,7 @@ Project includes `.cursor/rules/always-plan-first.mdc` requiring understanding b
### Memory & Conversation Debugging
- **GET /api/admin/memories**: All memories across all users with debug stats (Admin only)
- **GET /api/memories/unfiltered**: User's memories without filtering
- **GET /api/memories/search**: Semantic memory search with relevance scoring
- **GET /api/conversations**: User's conversations with transcripts
- **GET /api/conversations/{audio_uuid}**: Specific conversation details

Expand Down
207 changes: 207 additions & 0 deletions Docs/init-system.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Friend-Lite Initialization System

## Overview

Friend-Lite uses a unified initialization system with clean separation of concerns:

- **Configuration** (`init.py`) - Set up service configurations, API keys, and .env files
- **Service Management** (`services.py`) - Start, stop, and manage running services

The root orchestrator handles service selection and delegates configuration to individual service scripts. In general, setup scripts only configure and do not start services automatically. Exceptions: `extras/asr-services` and `extras/openmemory-mcp` are startup scripts. This prevents unnecessary resource usage and gives you control over when services actually run.

## Architecture

### Root Orchestrator
- **Location**: `/init.py`
- **Purpose**: Service selection and delegation only
- **Does NOT**: Handle service-specific configuration or duplicate setup logic

### Service Scripts
- **Backend**: `backends/advanced/init.py` - Complete Python-based interactive setup
- **Speaker Recognition**: `extras/speaker-recognition/setup.sh` - Simple bash setup
- **ASR Services**: `extras/asr-services/setup.sh` - Service startup script
- **OpenMemory MCP**: `extras/openmemory-mcp/setup.sh` - External server startup

## Usage

### Orchestrated Setup (Recommended)
Set up multiple services together with automatic URL coordination:

```bash
# From project root
uv run --with-requirements setup-requirements.txt python init.py
```

The orchestrator will:
1. Show service status and availability
2. Let you select which services to configure
3. Automatically pass service URLs between services
4. Display next steps for starting services

### Individual Service Setup
Each service can be configured independently:

```bash
# Advanced Backend only
cd backends/advanced
uv run --with-requirements setup-requirements.txt python init.py

# Speaker Recognition only
cd extras/speaker-recognition
./setup.sh

# ASR Services only
cd extras/asr-services
./setup.sh

# OpenMemory MCP only
cd extras/openmemory-mcp
./setup.sh
```

## Service Details

### Advanced Backend
- **Interactive setup** for authentication, LLM, transcription, and memory providers
- **Accepts arguments**: `--speaker-service-url`, `--parakeet-asr-url`
- **Generates**: Complete `.env` file with all required configuration
- **Default ports**: Backend (8000), WebUI (5173)

Comment on lines +68 to +69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Port collision: both Backend WebUI and Speaker Recognition WebUI set to 5173.

Running both concurrently on the host will fail. Either change one default (e.g., Speaker WebUI → 5174) or add a note explaining how to override.

Suggested doc tweak:

- **Default ports**: Backend (8000), WebUI (5173)
+ **Default ports**: Backend (8000), WebUI (5173)  
+ Note: If Speaker Recognition WebUI is also running, change one UI port to avoid a host-port conflict.

- **WebUI port**: 5173
+ **WebUI port**: 5174 (changeable)

Run to confirm actual exposed ports in compose files:

Also applies to: 70-74


🏁 Script executed:

#!/bin/bash
rg -nC2 -g '!**/node_modules/**' -P 'ports:\s*\n(?:\s*-.*\n)*|["'\'']5173["'\'']' --type=yaml

Length of output: 95


🏁 Script executed:

#!/bin/bash
# Search for any references to port 5173
rg -n "5173" --color=never

# Search for 'ports:' entries in all YAML files
rg -n "ports:" -g "*.yml" -g "*.yaml" --color=never

# Search for environment variable defining port in .env files
rg -n "VITE_PORT" -g ".env*" --color=never

# Search for 'port' keyword in Vite config files
rg -n "port" -g "vite.config.*" --color=never

Length of output: 11501


Clarify and document port override to avoid WebUI collision
In Docs/init-system.md (lines 68–74), add a note that the Speaker Recognition WebUI also defaults to port 5173 and must be overridden to avoid a host‐port conflict. Suggested diff:

- **Default ports**: Backend (8000), WebUI (5173)
+ **Default ports**: Backend (8000), WebUI (5173)  
+ ⚠️ If you’re running Speaker Recognition WebUI on the same host, override one of the UI ports (e.g. set REACT_UI_PORT or WEBUI_PORT to 5174) to prevent collision.

- **WebUI port**: 5173
+ **WebUI port**: 5173 (changeable via ENV var; e.g., REACT_UI_PORT)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- **Default ports**: Backend (8000), WebUI (5173)
- **Default ports**: Backend (8000), WebUI (5173)
⚠️ If you’re running Speaker Recognition WebUI on the same host, override one of the UI ports (e.g. set REACT_UI_PORT or WEBUI_PORT to 5174) to prevent collision.
- **WebUI port**: 5173 (changeable via ENV var; e.g., REACT_UI_PORT)
🤖 Prompt for AI Agents
In Docs/init-system.md around lines 68 to 69, the docs list default ports but
don’t mention that the Speaker Recognition WebUI also defaults to 5173, which
can cause a host-port conflict; update the section to explicitly note this
collision and add a short instruction that users must override the Speaker
Recognition WebUI port (or the WebUI backend port) when both are run on the same
host, giving an example of where to change the port and a brief pointer to the
config or env var to set.

### Speaker Recognition
- **Prompts for**: Hugging Face token, compute mode (cpu/gpu)
- **Service port**: 8085
- **WebUI port**: 5173
- **Requires**: HF_TOKEN for pyannote models

### ASR Services
- **Starts**: Parakeet ASR service via Docker Compose
- **Service port**: 8767
- **Purpose**: Offline speech-to-text processing
- **No configuration required**

### OpenMemory MCP
- **Starts**: External OpenMemory MCP server
- **Service port**: 8765
- **WebUI**: Available at http://localhost:8765
- **Purpose**: Cross-client memory compatibility

## Automatic URL Coordination

When using the orchestrated setup, service URLs are automatically configured:

| Service Selected | Backend Gets Configured With |
|----------------------|-------------------------------------------------------------------|
| Speaker Recognition | `SPEAKER_SERVICE_URL=http://host.docker.internal:8085` |
| ASR Services | `PARAKEET_ASR_URL=http://host.docker.internal:8767` |

This eliminates the need to manually configure service URLs when running services on the same machine.
Note (Linux): If `host.docker.internal` is unavailable, add `extra_hosts: - "host.docker.internal:host-gateway"` to the relevant services in `docker-compose.yml`.

## Key Benefits

✅ **No Unnecessary Building** - Services are only started when you explicitly request them
✅ **Resource Efficient** - Parakeet ASR won't start if you're using cloud transcription
✅ **Clean Separation** - Configuration vs service management are separate concerns
✅ **Unified Control** - Single command to start/stop all services
✅ **Selective Starting** - Choose which services to run based on your current needs

## Service URLs

### Default Service Endpoints
- **Backend API**: http://localhost:8000
- **Backend WebUI**: http://localhost:5173
- **Speaker Recognition**: http://localhost:8085
- **Speaker Recognition WebUI**: http://localhost:5173
- **Parakeet ASR**: http://localhost:8767
- **OpenMemory MCP**: http://localhost:8765

### Container-to-Container Communication
Services use `host.docker.internal` for inter-container communication:
- `http://host.docker.internal:8085` - Speaker Recognition
- `http://host.docker.internal:8767` - Parakeet ASR
- `http://host.docker.internal:8765` - OpenMemory MCP

Comment on lines +118 to +123
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Clarify when to use host.docker.internal vs service DNS names.

For containers on the same Compose network, prefer service names (DNS) over host.docker.internal, which targets the host, not peer containers.

Proposed wording:

-Services use `host.docker.internal` for inter-container communication:
+When services run in the same Docker Compose project, use service DNS names (e.g., `http://speaker-service:8085`).  
+Use `host.docker.internal` only when a container must call a service running on the host OS:

And adapt the bullets accordingly (add examples with service names).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Container-to-Container Communication
Services use `host.docker.internal` for inter-container communication:
- `http://host.docker.internal:8085` - Speaker Recognition
- `http://host.docker.internal:8767` - Parakeet ASR
- `http://host.docker.internal:8765` - OpenMemory MCP
### Container-to-Container Communication
When services run in the same Docker Compose project, use service DNS names (e.g., `http://speaker-service:8085`).
Use `host.docker.internal` only when a container must call a service running on the host OS:
- `http://host.docker.internal:8085` - Speaker Recognition
- `http://host.docker.internal:8767` - Parakeet ASR
- `http://host.docker.internal:8765` - OpenMemory MCP
🧰 Tools
🪛 LanguageTool

[grammar] ~118-~118: There might be a mistake here.
Context: ...### Container-to-Container Communication Services use host.docker.internal for ...

(QB_NEW_EN)

🤖 Prompt for AI Agents
In Docs/init-system.md around lines 118 to 123, the guidance currently
recommends using host.docker.internal for inter-container communication but that
confuses host vs peer container addressing; update the text to clarify that
containers on the same Docker Compose network should use service DNS names
(e.g., http://speaker-recognition:8085, http://parakeet-asr:8767,
http://openmemory-mcp:8765) and reserve host.docker.internal for accessing
services running on the host machine from inside containers; modify the three
bullets to show both the preferred service-name examples and note the
host.docker.internal case where appropriate.

## Service Management

Friend-Lite now separates **configuration** from **service lifecycle management**:

### Unified Service Management
Use the `services.py` script for all service operations:

```bash
# Start all configured services
uv run --with-requirements setup-requirements.txt python services.py start --all --build

# Start specific services
uv run --with-requirements setup-requirements.txt python services.py start backend speaker-recognition

# Check service status
uv run --with-requirements setup-requirements.txt python services.py status

# Stop all services
uv run --with-requirements setup-requirements.txt python services.py stop --all

# Stop specific services
uv run --with-requirements setup-requirements.txt python services.py stop asr-services openmemory-mcp
```

### Manual Service Management
You can also manage services individually:

```bash
# Advanced Backend
cd backends/advanced && docker compose up --build -d

# Speaker Recognition
cd extras/speaker-recognition && docker compose up --build -d

# ASR Services (only if using offline transcription)
cd extras/asr-services && docker compose up --build -d

# OpenMemory MCP (only if using openmemory_mcp provider)
cd extras/openmemory-mcp && docker compose up --build -d
```

## Configuration Files

### Generated Files
- `backends/advanced/.env` - Backend configuration with all services
- `extras/speaker-recognition/.env` - Speaker service configuration
- All services backup existing `.env` files automatically

### Required Dependencies
- **Root**: `setup-requirements.txt` (rich>=13.0.0)
- **Backend**: `setup-requirements.txt` (rich>=13.0.0, pyyaml>=6.0.0)
- **Extras**: No additional setup dependencies required

## Troubleshooting

### Common Issues
- **Port conflicts**: Check if services are already running on default ports
- **Permission errors**: Ensure scripts are executable (`chmod +x setup.sh`)
- **Missing dependencies**: Install uv and ensure setup-requirements.txt dependencies available
- **Service startup failures**: Check Docker is running and has sufficient resources

### Service Health Checks
```bash
# Backend health
curl http://localhost:8000/health

# Speaker Recognition health
curl http://localhost:8085/health

# ASR service health
curl http://localhost:8767/health
```

### Logs and Debugging
```bash
# View service logs
docker compose logs [service-name]

# Backend logs
cd backends/advanced && docker compose logs friend-backend

# Speaker Recognition logs
cd extras/speaker-recognition && docker compose logs speaker-service
```
138 changes: 138 additions & 0 deletions Docs/ports-and-access.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Friend-Lite Port Configuration & User Journey

## User Journey: Git Clone to Running Services

### 1. Clone & Setup
```bash
git clone <repo>
cd friend-lite

# Configure all services
uv run --with-requirements setup-requirements.txt python init.py

# Start all configured services
uv run --with-requirements setup-requirements.txt python services.py start --all --build
```

### 2. Service Access Points

## HTTP Mode (Default - No SSL Required)

| Service | API Port | Web UI Port | Access URL |
|---------|----------|-------------|------------|
| **Advanced Backend** | 8000 | 5173 | http://localhost:8000 (API)<br>http://localhost:5173 (Dashboard) |
| **Speaker Recognition** | 8085 | 5174 | http://localhost:8085 (API)<br>http://localhost:5174 (WebUI) |
| **Parakeet ASR** | 8767 | - | http://localhost:8767 (API) |
| **OpenMemory MCP** | 8765 | 8765 | http://localhost:8765 (API + WebUI) |

**🌐 Main Dashboard**: http://localhost:5173
**🎤 Speaker Recognition**: http://localhost:5174
**❌ No microphone access** - browsers require HTTPS for microphone

---

## HTTPS Mode (For Microphone Access)

| Service | HTTP Port | HTTPS Port | Access URL | Microphone Access |
|---------|-----------|------------|------------|-------------------|
| **Advanced Backend** | 80→443 | 443 | https://localhost/ (Main)<br>https://localhost/api/ (API) | ✅ Yes |
| **Speaker Recognition** | 8081→8444 | 8444 | https://localhost:8444/ (Main)<br>https://localhost:8444/api/ (API) | ✅ Yes |

**🌐 Main Dashboard**: https://localhost/ (Advanced Backend with SSL)
**🎤 Speaker Recognition**: https://localhost:8444/ (Speaker Recognition with SSL)
**✅ Full microphone access** - both services secured with SSL

### Port Details (HTTPS Mode)
- **Advanced Backend nginx**: Ports 80 (HTTP redirect) + 443 (HTTPS)
- **Speaker Recognition nginx**: Ports 8081 (HTTP redirect) + 8444 (HTTPS)
- **No port conflicts** - different port ranges for each service

---

## Why Two Modes?

### HTTP Mode (Default)
✅ **Simple setup** - No SSL certificates needed
✅ **Development friendly** - Quick start for testing
❌ **No microphone access** - Browsers require HTTPS for microphone

### HTTPS Mode (Advanced)
✅ **Microphone access** - Browsers allow mic access over HTTPS
✅ **Production ready** - Secure for real deployments
❌ **Complex setup** - Requires SSL certificate generation

---

## Configuration Files

### Speaker Recognition Modes

The speaker recognition service supports both modes via configuration:

**HTTP Mode (.env)**:
```bash
REACT_UI_PORT=5174
REACT_UI_HTTPS=false
```

**HTTPS Mode (.env)**:
```bash
REACT_UI_PORT=5175 # Internal HTTPS port
REACT_UI_HTTPS=true
# nginx provides external access on ports 8081 (HTTP) and 8444 (HTTPS)
```

---

## Service Management Commands

```bash
# Check what's running
uv run --with-requirements setup-requirements.txt python services.py status

# Start all services
uv run --with-requirements setup-requirements.txt python services.py start --all --build

# Start only specific services
uv run --with-requirements setup-requirements.txt python services.py start backend speaker-recognition

# Stop all services
uv run --with-requirements setup-requirements.txt python services.py stop --all
```

---

## Microphone Access Requirements

For **speaker recognition** and **live audio features** to work:

1. **Local development**: Use HTTP mode, access via `http://localhost:5174`
- Some browsers allow localhost microphone access over HTTP

2. **Production/Remote access**: Use HTTPS mode, access via `https://localhost:8444`
- All browsers require HTTPS for microphone access over network

3. **Mixed setup**: Keep backend on HTTP, only enable HTTPS for speaker recognition when needed

---

## Port Conflict Resolution

If you encounter port conflicts:

1. **Check running services**: `uv run --with-requirements setup-requirements.txt python services.py status`
2. **Stop conflicting services**: `uv run --with-requirements setup-requirements.txt python services.py stop --all`
3. **Change ports in .env files** if needed
4. **Restart services**: `uv run --with-requirements setup-requirements.txt python services.py start --all`

---

## Summary: Default User Experience

After `git clone` and running init + services:

🌐 **Main Application**: http://localhost:5173
🎤 **Speaker Recognition**: http://localhost:5174 (HTTP) or https://localhost:8444 (HTTPS)
🔧 **Backend API**: http://localhost:8000
📝 **ASR Service**: http://localhost:8767
🧠 **Memory Service**: http://localhost:8765
Loading