Skip to content

Add optional server frontend pipeline - #330

Open
0xShug0 wants to merge 3 commits into
mainfrom
server-frontend-module
Open

Add optional server frontend pipeline#330
0xShug0 wants to merge 3 commits into
mainfrom
server-frontend-module

Conversation

@0xShug0

@0xShug0 0xShug0 commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Resolves #313
Resolves #392: Adds opt-in frontend-scoped HTTPS support

Summary

  • add an opt-in in-process server frontend pipeline with pre/post module hooks
  • add explicit module contracts for request and response envelope states
  • add audio_decode for MP3/FLAC ASR input via miniaudio
  • add mp3_encode for response_format=mp3 TTS output via libmp3lame
  • add https as a frontend capability, not a pre/post module, using the existing vendored cpp-httplib TLS stack
  • keep frontend dependencies opt-in; the default server build does not include codec/TLS frontend dependencies
  • split frontend docs into an overview plus module-specific docs, including Windows/Linux LAME setup for mp3_encode

High-Level Design

The core server keeps its stable HTTP API shape: WAV/text in and WAV/text out. Optional frontend modules run in-process around that core handler. Pre-processing modules adapt client requests before core routing, and post-processing modules adapt core responses before returning to the client.

https is separate from the pre/post module contract. It is a frontend-owned listener capability that terminates TLS in-process and forwards the request envelope to the same core handler. The existing plain HTTP transport is unchanged.

At configure time, users select only the frontend capabilities/modules they need:

cmake -S . -B build/debug \
  -DCMAKE_BUILD_TYPE=Debug \
  -DAUDIOCPP_BUILD_SERVER_FRONTENDS=ON \
  '-DAUDIOCPP_SERVER_FRONTEND_MODULES=audio_decode;mp3_encode;https'

Docs

  • app/server/frontends/README.md: frontend overview, supported frontend table, pipeline, and contracts
  • app/server/frontends/docs/audio_decode.md: MP3/FLAC ASR input module
  • app/server/frontends/docs/mp3_encode.md: MP3 TTS output module and LAME install/configuration notes
  • app/server/frontends/docs/https.md: HTTPS frontend listener capability
  • app/server/frontends/docs/adding_modules.md: developer guide for adding new frontend modules

Validation

Case Request / command shape Response / behavior
Default build, no frontend AUDIOCPP_BUILD_SERVER_FRONTENDS=OFF, build audiocpp_server Build passed
HTTPS flags on non-HTTPS build --https-cert-file ... --https-key-file ... Exit 1: HTTPS frontend support is not available in this build; configure with -DAUDIOCPP_BUILD_SERVER_FRONTENDS=ON -DAUDIOCPP_SERVER_FRONTEND_MODULES=https
HTTPS frontend build AUDIOCPP_BUILD_NATIVE_MODEL_MANAGER=OFF, AUDIOCPP_BUILD_SERVER_FRONTENDS=ON, AUDIOCPP_SERVER_FRONTEND_MODULES=https Build passed; HTTPS uses frontend-selected audiocpp_cpp_httplib without native model manager
CLI missing key pair --https-cert-file cert.pem only Exit 1: --https-cert-file and --https-key-file must be set together
Bad cert/key files cert/key paths do not exist Exit 1: could not initialize HTTPS frontend server from certificate/key files
HTTPS /health GET https://127.0.0.1:18443/health 200 OK, {"status":"ok","backend":"cpu","models":0,"ui":true,"ui_management":false}
HTTPS UI root GET https://127.0.0.1:18443/ 200 OK, Content-Type: text/html; charset=utf-8, embedded UI returned
HTTPS models list GET https://127.0.0.1:18443/v1/models 200 OK, {"object":"list","data":[]}
Plain HTTP to HTTPS port GET http://127.0.0.1:18443/health Fails before handler routing; curl exit 52, Empty reply from server
Config relative cert/key https_cert_file: "cert.pem", https_key_file: "key.pem" in config directory GET /health over HTTPS returned 200 OK; config-relative path resolution works
Config model list Same config with one lazy dummy model GET /v1/models returned one unloaded model entry
Config missing key pair https_cert_file without https_key_file Exit 1: server https_cert_file and https_key_file must be set together
HTTPS oversized request body max_request_body_bytes: 8, POST body larger than 8 bytes 413 Payload Too Large before core routing
HTTPS-capable binary without TLS flags GET http://127.0.0.1:18080/health 200 OK, normal HTTP path still works
HTTPS request to plain HTTP port GET https://127.0.0.1:18080/health Fails before handler routing; curl exit 28, connection timed out
mp3_encode dependency lookup without LAME Configure with AUDIOCPP_SERVER_FRONTEND_MODULES=mp3_encode and no LAME install Fails with cross-platform message naming lame/lame.h, libmp3lame, conda, and AUDIOCPP_LAME_ROOT
HTTPS configure after LAME lookup change Configure with AUDIOCPP_SERVER_FRONTEND_MODULES=https Configure passed; unrelated frontend capability not affected
Frontend docs split Checked doc links and Markdown paths Links point to module-specific docs

Also checked:

  • git diff --check
  • no changes to app/server/http.cpp or app/server/http.h
  • no server process left running after validation

@keturn

keturn commented Sep 2, 2026

Copy link
Copy Markdown

Confirmed that running with --https-cert-file and --https-key-file works as intended for #392.

That is, once I enabled the right build options. .devops/ and scripts/ need updating if this is to be included in builds by default.

@0xShug0

0xShug0 commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

if this is to be included in builds by default.

Thanks for testing! The frontend may go into the default build. Check the discussions here #313

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants