-
Notifications
You must be signed in to change notification settings - Fork 25
Better init system #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5ba367d
88dd825
5491d66
61fa5ef
e6de82e
2646c93
a26729c
e595f3e
0612587
4667ceb
3d5d9a2
7649948
489932c
641e304
e783d01
cb5920d
165d2f1
8904def
33f5c17
16d30e0
7ce256b
87c9931
4c9d552
4de7ec0
ec53ca3
dffcc2d
8a02f65
d25d6c6
69d5524
939c2a1
6a442d3
ffce264
d3f53f1
f9ef977
f710193
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| ### 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~118-~118: There might be a mistake here. (QB_NEW_EN) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| ## 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 | ||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||
| 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 |
There was a problem hiding this comment.
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:
Run to confirm actual exposed ports in compose files:
Also applies to: 70-74
🏁 Script executed:
Length of output: 95
🏁 Script executed:
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:
📝 Committable suggestion
🤖 Prompt for AI Agents