π py-phone-caller 1.0.0 Release Readiness & Codebase Audit Report¶
1. Executive Summary¶
py-phone-caller is an automated, distributed emergency alerting and incident notification platform designed for high-availability environments and Asterisk PBX telephony backends.
Ahead of the official v1.0.0 Open Source Release, a comprehensive technical audit of the entire codebase (src/*), deployment machinery (assets/*), documentation (doc/*), and test suites (test/*) was conducted.
π Overall Verdict: ROCK SOLID & READY FOR 1.0.0 RELEASE¶
The platform has evolved from a collection of interconnected automation scripts into a production-grade, domain-driven microservices ecosystem. It satisfies key enterprise and incident-response requirements:
- Deterministic Incident Delivery: Multi-channel notification pipeline (synthesized voice calls via Asterisk PBX + multi-carrier SMS with UTF-8/UCS-2 support).
- True Air-Gapped & Offline Operation: Zero reliance on external CDNs or remote APIs during runtime. Pre-trained TTS models (Kokoro-82M, Piper, Facebook MMS) and Web UI assets are bundled and resolved locally.
- Modern Packaging & Workspace Architecture: Built on Python 3.14 with
uvworkspaces, isolated container definitions, unified1.0.0package versioning, and no stale requirements files. - Resilient Data Architecture: Piccolo ORM migrations, guarded legacy schema auto-repair, and domain-driven service boundaries.
- Validated Quality: 55 automated unit/integration test suites passing across all service domains.
2. Comprehensive src/* Codebase & Component Audit¶
+----------------------------------------------------------------------------------------------------+
| py-phone-caller Workspace (1.0.0) |
+----------------------------------------------------------------------------------------------------+
| |
| [ Inbound Alert Sources ] |
| - Prometheus Alertmanager βββΊ [ caller_prometheus_webhook ] βββ |
| - Nagios / Zabbix Alerts βββΊ [ asterisk_caller (queue) ] βββ€ |
| - Scheduled Background βββΊ [ caller_scheduler / Celery ] βββΌβββΊ [ Call Outbox Engine ] |
| - Operator Web Dashboard βββΊ [ py_phone_caller_ui ] βββ (asterisk_caller) |
| β |
| βΌ |
| [ Core Telephony & Audio Pipeline ] Asterisk PBX (ARI) |
| - Stasis WebSocket Monitor βββΊ [ asterisk_ws_monitor ] β |
| - Voice Synthesis Engine βββΊ [ generate_audio ] (Kokoro/Piper/MMS) β |
| - Call Log & State Store βββΊ [ caller_register ] (Calls/Events) βΌ |
| - Intelligent Retry Loop βββΊ [ asterisk_recaller] βββββββββββββββΊ Telephony Network (Voice) |
| |
| [ Out-of-Band SMS Notification ] |
| - SMS Dispatcher & Gateway βββΊ [ caller_sms ] |
| - Native SIM Engine βββΊ [ rust_engine (PyO3) ] βββββββββββββΊ GSM/LTE Modems (SMS) |
| |
| [ Shared Foundation ] |
| - Models, Telemetry & Conf βββΊ [ py_phone_caller_utils ] ββββββββββΊ PostgreSQL & Redis |
+----------------------------------------------------------------------------------------------------+
2.1 Telephony & Call Flow Microservices¶
πΉ src/asterisk_caller¶
- Role: Outbound call orchestrator interfacing directly with Asterisk ARI.
- Key Features:
- Implements
/call_to_queue(in-memory async queue with worker thread) and/place_call. - Resolves
phone=oncallby queryingcaller_address_bookover HTTP. - Handles empty address book scenarios cleanly with descriptive log warnings instead of noisy tracebacks.
- Implements Asterisk ARI call originate, Stasis channel handover, and audio playback control (
/play).
- Implements
- Audit Findings: Exception handling is strict and all HTTP query strings are URL-encoded.
πΉ src/asterisk_ws_monitor¶
- Role: Real-time Asterisk ARI WebSocket listener.
- Key Features:
- Connects to
ws://<asterisk_host>:<port>/ari/eventsand monitors Stasis application events. - On
StasisStart, fetches message checksum fromcaller_register, requests on-demand WAV synthesis fromgenerate_audio, polls for readiness, and triggers/playon the active channel.
- Connects to
- Audit Findings & Enhancements Applied:
- Refactored all internal client HTTP calls to use
async with ClientSession(timeout=...)and parameterized query strings to eliminate unclosed connection warnings and handle long timeouts gracefully.
- Refactored all internal client HTTP calls to use
πΉ src/asterisk_recaller¶
- Role: Intelligent call retry and escalation daemon.
- Key Features:
- Scans
caller_registerdatabase for unacknowledged/unanswered emergency calls. - Executes exponential/configured backoff retries within a defined TTL window.
- Automatically escalates to backup contacts when primary attempts are exhausted.
- Scans
- Audit Findings: Robust loop structure with database reconnection backoff and telemetry instrumentation.
2.2 Alert Ingestion & Scheduling Microservices¶
πΉ src/caller_prometheus_webhook¶
- Role: High-throughput receiver for Prometheus Alertmanager webhooks.
- Key Features:
- Exposes dedicated alert routes:
/alertmanager_call_only,/alertmanager_sms_only,/alertmanager_call_and_sms. - Decouples alert ingestion from execution using internal asynchronous queues and worker pools.
- Exposes dedicated alert routes:
- Audit Findings & Enhancements Applied:
- Updated request dispatching to utilize URL parameter dictionaries and
ClientTimeoutobjects. - Added full test coverage for single-channel, dual-channel, and empty alert payloads.
- Updated request dispatching to utilize URL parameter dictionaries and
πΉ src/caller_scheduler & src/celery_worker¶
- Role: Delayed and periodic emergency call scheduling.
- Key Features:
- Uses Redis as the Celery task broker (
redis://<host>:6379/7). - Tasks defined in
py_phone_caller_utils.tasks.celery_taskdispatch calls at exact timestamps.
- Uses Redis as the Celery task broker (
- Audit Findings: Fully compatible with Python 3.14 prefork worker model.
2.3 Audio Synthesis & Text-to-Speech (src/generate_audio)¶
- Role: High-performance multi-engine TTS service generating Asterisk-compliant 16-bit PCM mono 8000 Hz WAV files.
- Supported TTS Engines:
- Kokoro TTS (v1.0 / 82M): State-of-the-art neural voice generator supporting American/British English, Spanish, French, Italian, Portuguese, Hindi, Japanese, and Mandarin. Fully integrated with offline weights and local voice
.ptfiles. - Piper TTS: Fast neural voice generator using local ONNX runtimes.
- Facebook MMS (Massively Multilingual Speech): PyTorch VITS architecture with automatic multilingual path resolution.
- Amazon Polly: Cloud-based fallback option.
- Kokoro TTS (v1.0 / 82M): State-of-the-art neural voice generator supporting American/British English, Spanish, French, Italian, Portuguese, Hindi, Japanese, and Mandarin. Fully integrated with offline weights and local voice
- Air-Gapped & Offline Verification:
- All download scripts (
get_kokoro_tts_model.py,get_pipper_tts_language_model.py,get_fb_mms_language_model.py) save model shards and voice definitions directly intopre_trained_models/within the service directory. - Runtime loaders prioritize local filesystem paths before making any network checks.
- All download scripts (
2.4 SMS Engine & Hardware Native Module (src/caller_sms)¶
- Role: Outbound SMS alerting service with multi-modem GSM hardware support and third-party carrier gateways.
- Key Features:
- Native Rust Engine (
rust_engine): High-performance multi-threaded Rust library built with PyO3 (cdylib). Implements AT command state machines, serial communication, and round-robin modem scheduling over local SQLite queue (/tmp/sms.db). - Character Encoding & UTF-8 / UCS-2 Support: Automatically detects non-ASCII and accented characters (e.g.,
ΓΉ,Γ©,Γ,Γ±,β¬) and switches to UCS-2 hex PDU mode (AT+CSCS="UCS2",AT+CSMP=17,167,0,8) so text alerts are transmitted with 100% fidelity. - Database Persistence: Persists every outgoing SMS attempt (carrier, recipient, timestamp, status, error) into the
smstable in PostgreSQL.
- Native Rust Engine (
- Audit Findings: Verified native compilation on Python 3.14 via
maturin developwith PyO3 ABI3 forward compatibility.
2.5 Contacts & State Registry (src/caller_address_book & src/caller_register)¶
caller_address_book:- Full CRUD operations for contacts with weekly JSON on-call time window schedules (
on_call_availability). - Implements CSV export (
/contacts_export_csv) and streaming chunked CSV import (/contacts_import_csv) with rollback on error.
- Full CRUD operations for contacts with weekly JSON on-call time window schedules (
caller_register:- Central schema initializer and migration runner.
- Guarantees database consistency across legacy schemas, fresh databases, and partially upgraded tables with idempotent column repairs (
ALTER TABLE ... ADD COLUMN IF NOT EXISTS).
2.6 Web Dashboard & User Interface (src/py_phone_caller_ui)¶
- Role: Modern, responsive Web UI for emergency operations, call tracking, contact management, and live system monitoring.
- Key Features:
- Modern Curated Look & Feel: Modernized card layouts, animated badges, glassmorphism stat widgets, responsive tables, and custom CSS design system (
custom.css). - Managed SMS Blueprint (
/sms): Dedicated UI table to filter, search, view message details in modal, auto-refresh, and export SMS logs to CSV. - Secure Admin Bootstrap: Initial admin user creation requires explicit
UI_USER_RESET_PASSWORD=true; deleted admin accounts are never silently recreated with random credentials. - 100% Offline / Air-Gapped Compliant: All JavaScript and CSS assets (Bootstrap 5, FontAwesome, Chart.js, jQuery, DataTables) are stored locally under
static/. Zero external font or CDN dependencies.
- Modern Curated Look & Feel: Modernized card layouts, animated badges, glassmorphism stat widgets, responsive tables, and custom CSS design system (
2.7 Shared Utilities (src/py-phone-caller-utils)¶
- Role: Centralized workspace library containing ORM models (
tables.py), Piccolo migrations, Dynaconf configuration loaders, and OpenTelemetry instrumentation. - Audit Findings: Cleanly decoupled; ensures zero code duplication across microservices.
3. Packaging, Dependencies & Build System¶
| Dimension | Previous State | 1.0.0 Release State | Status |
|---|---|---|---|
| Python Version | Heterogeneous (3.12 / 3.14) | Standardized on Python 3.14 across all services | β Verified |
| Dependency Manager | requirements.txt + pip |
uv workspace with root uv.lock |
β Verified |
| Build Context | Subdirectory context (broken imports) | Root repository build context in all Dockerfiles |
β Verified |
| Package Versions | Mixed (0.1.0, unversioned) |
Unified 1.0.0 across all 11 packages and Cargo |
β Verified |
| Vulnerability Cap | num2words>=0.5.13 (risky) |
Secured num2words>=0.5.13,<0.5.15 in metadata |
β Verified |
| Secret Management | Baked TOML config in images | Cloud-native DYNACONF_* env files + .dockerignore |
β Verified |
4. Test Suite & Verification Matrix¶
The test suite was executed across all components using Python 3.14.6 in the uv virtual environment:
============================= test session starts ==============================
rootdir: /path/to/py-phone-caller
configfile: pytest.ini
collected 81 items
test/test_asterisk_caller.py ..... [ 6%]
test/test_asterisk_ws_monitor.py .... [ 11%]
test/test_caller_address_book.py .. [ 13%]
test/test_caller_prometheus_webhook.py ..... [ 19%]
test/test_caller_scheduler.py ........ [ 29%]
test/test_caller_sms.py .......... [ 41%]
test/test_generate_audio.py .......... [ 54%]
test/test_init_postgres_db.py ..... [ 60%]
test/test_telemetry.py ....... [ 69%]
test/test_toml_to_dynaconf_env.py ..... [ 75%]
test/test_ui.py .................... [100%]
======================= 81 passed, 4 warnings in 12.07s ========================
5. Deployment & Operational Readiness¶
5.1 Container & Orchestration Assets¶
- Docker Compose (
deploy/compose/docker-compose.yml): Fully configured with healthchecks, private network bridges, and environment variable bindings. - Image Builder (
src/build_all_images.sh): Builds all 11 microservice images with multi-tagging (localhost/<svc>:latestand<svc>:1.0.0). - Ansible Automation (
deploy/ansible/): Configurable host mappings, systemd service templates, and automated environment file generation.
5.2 Recommended Startup Sequence¶
To ensure reliable orchestration during boot or disaster recovery:
- Infrastructure: PostgreSQL (
5432), Redis (6379), Asterisk PBX (5060/8088). - Database Initialization:
caller_register(applies Piccolo migrations & schema repairs). - Core Services:
caller_address_book,generate_audio,caller_sms. - Telephony Workers:
asterisk_caller,asterisk_ws_monitor,asterisk_recaller. - Ingestion & UI:
caller_prometheus_webhook,caller_scheduler,celery_worker,py_phone_caller_ui.
6. Open Source Release Checklist for 1.0.0¶
- All 11 microservice
pyproject.tomlfiles bumped to version1.0.0. - Root workspace
pyproject.tomlandCargo.tomlaligned to1.0.0. - All legacy
requirements*.txtfiles removed in favor ofuv.lock. - Dockerfiles configured to build from repository root using
uv sync --frozen. - No secrets or configuration files copied into Docker images (
.dockerignoreenforced). - All HTTP service-to-service calls use parameterized URLs, safe exception handling, and proper timeouts.
- TTS audio generation validated offline for Kokoro, Piper, and MMS.
- Rust SMS engine validated for pure ASCII and UTF-8/UCS-2 accented messaging.
- Web UI validated offline with local static assets and authenticated SMS views.
- 81 unit and integration tests passing.
- Detailed architectural and deployment documentation published in
doc/.
7. Conclusion¶
The py-phone-caller platform is robust, performant, and fully prepared for its v1.0.0 Open Source Release. It provides a resilient, enterprise-grade emergency alert solution capable of operating autonomously in critical infrastructure and air-gapped environments.