|
| 1 | +# MiniFlow Engineering (Swift + Smallest) |
| 2 | + |
| 3 | +This repository is intentionally structured around a single runtime path: |
| 4 | + |
| 5 | +- `MiniflowApp/` - native macOS app (Swift/SwiftUI) |
| 6 | +- `miniflow-engine/` - local Python engine (FastAPI) |
| 7 | +- `miniflow-auth/` - OAuth proxy (Vercel, optional for integrations) |
| 8 | + |
| 9 | +Legacy web/Tauri artifacts have been removed from the root to avoid split build paths. |
| 10 | + |
| 11 | +## System Architecture |
| 12 | + |
| 13 | +```text |
| 14 | +MiniflowApp (Swift) <-> miniflow-engine (FastAPI on localhost:8765) |
| 15 | + | |
| 16 | + +-> Smallest AI Waves (speech-to-text) |
| 17 | + +-> OpenAI (agent/tool orchestration) |
| 18 | + +-> OAuth-backed connectors (Slack, GitHub, etc.) |
| 19 | +``` |
| 20 | + |
| 21 | +## Speech and Command Flow |
| 22 | + |
| 23 | +1. Swift captures microphone audio. |
| 24 | +2. Swift posts base64 PCM chunks to engine commands (`start_listening`, `send_audio_chunk`, `stop_listening`). |
| 25 | +3. Engine streams audio to Smallest AI Waves over WebSocket. |
| 26 | +4. Engine emits transcript events over `ws://127.0.0.1:8765/ws`. |
| 27 | +5. Swift receives final transcript and invokes `execute_command`. |
| 28 | +6. Engine runs local tools and connector tools, then emits action results. |
| 29 | + |
| 30 | +## API Key Contract |
| 31 | + |
| 32 | +The engine key contract is: |
| 33 | + |
| 34 | +- `openai` |
| 35 | +- `smallest` |
| 36 | + |
| 37 | +`has_api_keys` returns: |
| 38 | + |
| 39 | +```json |
| 40 | +{ |
| 41 | + "openai": "string|null", |
| 42 | + "smallest": "string|null" |
| 43 | +} |
| 44 | +``` |
| 45 | + |
| 46 | +## Build and Packaging |
| 47 | + |
| 48 | +Primary build path: |
| 49 | + |
| 50 | +1. `./build_backend.sh` - bundles Python engine |
| 51 | +2. `./build_all.sh` - builds Swift app, embeds engine, creates DMG |
| 52 | + |
| 53 | +DMG-only packaging (for an already built app): |
| 54 | + |
| 55 | +- `APP_PATH=build/MiniFlow.app ./build_dmg.sh` |
| 56 | + |
| 57 | +## Source of Truth |
| 58 | + |
| 59 | +If docs conflict with code, treat these as canonical: |
| 60 | + |
| 61 | +- Runtime and UI behavior: `MiniflowApp/` |
| 62 | +- Engine API/events: `miniflow-engine/main.py` |
| 63 | +- STT provider behavior: `miniflow-engine/audio.py` |
| 64 | +- API key storage contract: `miniflow-engine/config.py` |
0 commit comments