Engineering BlueprintArchitectureSecurityReliabilityFastAPIExpoOpen SourceSpeakOnTerraform

Bootstrapping SpeakOn: Local-First Architecture, Open-Source Security & Zero-Cost CI

How we bootstrapped SpeakOn's Phase 0 foundation across Apache-2.0 public repositories, loopback Private Network Access middleware, gitleaks/Terraform…

Célio Vieira644 words4 min read

Key Takeaways (TL;DR)

Summary
  • Why Local-First Open Source Demands Strict Phase 0 Governance — Building a voice AI language tutor (STT -> LLM -> TTS) and Mandarin Studio completely free and open-source…
  • Architecture: Loopback Web, Paired LAN Mobile, Zero Web Backend — SpeakOn splits responsibilities cleanly across three surfaces without ever duplicating state or violating…
  • Security: Private Network Access, Zero-Leak Gates, and License Hygiene — Shipping public repositories from an active multi-product workstation surfaces subtle security and…
  • Reliability: Diagnostics, Dependency Pinning, and OpenAPI Contracts — Reliable local AI tooling starts with fast environment verification and repeatable builds:

Why Local-First Open Source Demands Strict Phase 0 Governance#

Building a voice AI language tutor (STT -> LLM -> TTS) and Mandarin Studio completely free and open-source introduces an engineering paradox: the final product must run effortlessly on a developer's single desktop GPU, while its public repositories (speakon-services and speakon-mobile) must maintain strict zero-leak hygiene, OSI license compliance, and deterministic CI from commit one.

In Phase 0, before writing a single speech inference model or UI screen, we established the Shared Aldeon Foundation (CHILD_BOOTSTRAP_STANDARD.md and SERVICE_BLUEPRINT.md) and bootstrapped both public Apache-2.0 repositories alongside automated governance.

Architecture: Loopback Web, Paired LAN Mobile, Zero Web Backend#

SpeakOn splits responsibilities cleanly across three surfaces without ever duplicating state or violating Aldeon's zero-backend rule inside aldeon/app:

  1. Consolidated Web Portal (aldeon/app/src/routes/speakon/): Served over HTTPS on Vercel, it keeps zero database connections or backend routes. Browser clients communicate strictly with http://127.0.0.1:8000 (exempt from mixed-content blocking) rather than arbitrary LAN IPv4 addresses.
  2. Local Desktop FastAPI Orchestrator (Celio1878/speakon-services): Binds 127.0.0.1:8000 by default, isolating heavy AI dependencies (faster-whisper, kokoro, silero-vad, PyTorch cu128) in an optional [project.optional-dependencies].ai extra. That keeps base installations lightweight and lets GitHub Actions run full lint, mypy --strict, pytest, and OpenAPI drift checks in ~20 seconds on CPU runners.
  3. Expo Prebuild Native Mobile Client (Celio1878/speakon-mobile): Configured with strict TypeScript ("strict": true), 64-bit Android ABIs (arm64-v8a, x86_64), and throttled Gradle workers (workers.max=4) to prevent Linux OOM daemon crashes during local native builds, while validating both Android and iOS expo prebuild trees in CI.

Security: Private Network Access, Zero-Leak Gates, and License Hygiene#

Shipping public repositories from an active multi-product workstation surfaces subtle security and licensing pitfalls that we caught and automated immediately in Phase 0:

  • Chrome Private Network Access (PNA) + Starlette 1.10+: When an HTTPS page calls http://127.0.0.1:8000, Chromium issues a CORS preflight with Access-Control-Request-Private-Network: true. Starlette 1.10.0 rejects this by default with 400 Disallowed CORS private-network unless allow_private_network=True is enabled—and still emits the PNA header on failed origin checks if left unwrapped. We combined CORSMiddleware(allow_private_network=True) with an outer PrivateNetworkAccessMiddleware that enforces our explicit origin allowlist before returning Access-Control-Allow-Private-Network: true.
  • Pre-Publish Secret Scanning & Privacy Checks: Before running gh repo create --public, both repositories passed gitleaks detect (backed by a SHA-256-verified binary in CI instead of licensed third-party actions) and filesystem privacy scans ensuring no personal paths, emails, .env files, or keystores appear in source defaults.
  • License Guardrails: Because piper-tts >= 1.3 (piper1-gpl) is GPL-3.0, SpeakOn explicitly rejects it in favor of the archived MIT standalone piper 2023.11.14-2 binary verified by SHA-256 (scripts/check_models.py) alongside Kokoro-82M (Apache-2.0) and rhasspy/piper-voices (MIT).
  • Terraform Repository Governance: infra/terraform/ imports both GitHub repositories and enforces branch protection on main and develop (requiring ci and gitleaks status checks), vulnerability alerts, and secret push protection.

Reliability: Diagnostics, Dependency Pinning, and OpenAPI Contracts#

Reliable local AI tooling starts with fast environment verification and repeatable builds:

  • speakon doctor Diagnostics & Proxy Bypass: uv run speakon doctor validates uv, bun, docker, terraform, gh, eas, gddy, gitleaks, espeak-ng, CUDA GPU availability, HF_HOME writability, and host Ollama model tags via /api/tags without triggering unwanted pulls. Crucially, testing uncovered that host HTTP_PROXY environment variables hijack loopback httpx calls to 127.0.0.1:11434 (400 Direct IP access is not allowed), so all local Ollama clients explicitly set trust_env=False.
  • FastAPI + OpenTelemetry Pinning: Unbounded fastapi>=0.115.0 pulled 0.165.1 alongside opentelemetry-api 1.46.0, breaking TestClient with a TypeError in native telemetry logger initialization. Pinning fastapi>=0.115.0,<0.135.0 in pyproject.toml and uv.lock eliminated the failure cleanly.
  • Deterministic OpenAPI Drift Checks: scripts/export_openapi.py --check runs in CI to guarantee openapi.json never drifts out of sync before TypeScript clients are generated for web and mobile.

Next Up#

With Phase 0's public repositories, CI pipelines, and Terraform governance live and green, Phase 1 will implement the modular app/stt, app/llm, app/tts, and app/vad local AI pipeline and benchmark RTX 3070 memory and turn latency.

Célio Vieira

Célio Vieira

Founder & Architect

Engineering applied AI systems, distributed cloud platforms, and the Aldeon umbrella venture ecosystem.

Related Technical Dispatches

View all 90