2.7 KiB
2.7 KiB
Repository Guidelines
Project Structure & Modules
- Gateway (
gateway/): FastAPI entrypoint inmain.py, routes underapi/(health.py,openai_speech.py,voices.py), shared helpers incore/, voice registry invoices/and runtime port inport.txt. - Worker (
worker/): Queue consumer incore/queue_worker.py, XTTS2 synthesis inengine/xtts2_loader.py, audio export inengine/audio_export.py, voice assets invoices/. - Tooling:
Makefiledrives Docker workflow,docker-compose.ymlwires gateway/worker/redis, helper scripts inscripts/(find_port.py,selftest.py).
Build, Test, and Run
make build– build gateway + worker images.make up– start stack with auto port selection (writesgateway/port.txt).make status/make logs– check containers and follow logs.make selftest– end-to-end smoke test against the running stack (health + sample synthesis).- Local debug (no Docker): install deps with
pip install -r gateway/requirements.gateway.txtandpip install -r worker/requirements.worker.txt, thenpython gateway/main.pyandpython worker/main.py; start Redis viadocker run -p 6379:6379 redis:7.
Coding Style & Naming
- Python, prefer PEP8 with 4-space indents and snake_case names for modules, functions, and vars; keep route names aligned with OpenAI-compatible paths (
/v1/audio/speech,/v1/voices/register). - Keep modules small and focused (API logic in
gateway/api, queue/Redis helpers incore). - Favor explicit config via env vars (
REDIS_HOST,GATEWAY_PORT); avoid hardcoded ports besides the 8000–8100 scan range.
Testing Guidelines
- Primary check is the smoke test: run
make selftestafter changes that touch API, queue, or audio paths. - For new logic, add lightweight unit tests (e.g., under
gateway/tests/orworker/tests/) namedtest_<feature>.py; prefer pytest-style asserts. - When adding audio or queue code, include sanity checks (e.g., validate
mimeand byte length) to avoid silent failures.
Commit & Pull Request Practices
- Commits: short, imperative subjects (e.g.,
add queue timeout guard,tune xtts export). Group related changes; avoid mixing refactors with feature work. - Pull Requests: describe intent, list test commands executed (e.g.,
make selftest), mention affected endpoints or worker behaviors, and link issues when available. Provide screenshots or audio sample paths only if UX or output format changes.
Security & Operations Notes
- Do not commit voice assets beyond small samples; keep secrets out of the repo and prefer env vars or Docker secrets.
- Gateway listens on the selected local port only; expose externally via reverse proxy/HTTPS in production. Keep worker services internal and behind the queue.