Skip to content

Step 0: Full Project Analysis & Architectural Trace ​

0.1 What the Project Is ​

OmniPost (20-Notification-Delivery-Platform) is an enterprise-grade, high-throughput omnichannel notification delivery engine and operations platform built using Python 3.13, FastAPI, AsyncIO, SQLAlchemy 2.0 (AsyncSession), and a Vanilla JS / HTML5 / CSS3 operations console.

Problem Solved ​

In enterprise distributed systems, notification delivery is inherently fragile:

  1. Third-Party Volatility: Downstream provider APIs (SendGrid, Twilio, AWS SES) frequently encounter transient network errors, latency spikes, rate limits, and regional outages.
  2. Channel Starvation: Mass marketing email blasts or batch digests clog queues, delaying time-critical transactional alerts like two-factor authentication (2FA) OTP codes or fraud alerts.
  3. Template Sprawl & SSTI Vulnerability: Unvetted string formatting exposes servers to Server-Side Template Injection (SSTI) and inconsistent multilingual rendering.
  4. Regulatory & User Fatigue: Failing to respect recipient quiet hours across international timezones violates telecom regulations and degrades customer trust.

Architectural Solution ​

OmniPost centralizes all outbound messaging across five channels (Email, SMS, Webhook, Push, In-App). It enforces:

  • Strict request idempotency using (tenant_id, idempotency_key) constraints.
  • Multi-tier priority scheduling where URGENT (weight 100) and HIGH (weight 50) messages preempt NORMAL (weight 10) and LOW (weight 0) messages.
  • Lease-based worker concurrency with row-level locks and starvation protection.
  • Provider capability matching & automatic fallback when a primary vendor returns retryable 5xx or rate-limit codes.
  • Exponential backoff retries with full jitter and dead-letter queue (DLQ) manual redrive and replay APIs.
  • Sandboxed template execution with nested variable interpolation, localization fallback, and administrative approval workflows.
  • Timezone-aware quiet hours with midnight wrap-around and rolling 24-hour frequency capping.

0.2 System Architecture & End-to-End Traces ​


0.3 Complete API Inventory ​

Backend REST Endpoints (Port 8200) ​

HTTP MethodRoute PathAuth RequiredHandler FunctionFile & LineCore Responsibility
GET/healthz, /healthNonehealthz()api/app.py:107Liveness probe returning service metadata and UTC timestamp.
GET/readyzNonereadyz()api/app.py:120Readiness probe executing SELECT 1 against database session.
GET/metricsNonemetrics_endpoint()api/app.py:143Prometheus text metrics exporter for delivery latency & throughput.
POST/api/v1/deliveryOptional/Keydeliver_notification()api/app.py:192Core delivery ingestion, validation, preferences, and dispatch.
POST/api/v1/scheduleOptional/Keyschedule_notification()api/app.py:319Delayed/scheduled job creation with run_at UTC timestamp.
GET/api/v1/schedule/dueNoneget_due_scheduled()api/app.py:340Worker polling endpoint retrieving due scheduled notifications.
POST/api/v1/notifications/{id}/retryOptional/Keyretry_notification()api/app.py:371Manual retry creating new delivery attempt and audit log.
POST/api/v1/notifications/{id}/replayOptional/Keyreplay_notification()api/app.py:398Replays failed notification through pipeline with audit tracking.
POST/api/v1/dlq/reprocessOptional/Keyreprocess_dead_letter()api/app.py:424Removes item from DLQ, resets state to QUEUED, and re-dispatches.
GET/v1/notifications/{id}Noneget_notification_status()api/app.py:454Status lookup returning full lifecycle history and delivery attempts.
POST/v1/templatesOptional/Keycreate_template()api/app.py:481Registers new template version with channel and language metadata.
GET/v1/templates/{name}Noneget_template()api/app.py:499Fetches active template definition for inspection or editing.
GET/v1/notificationsNonelist_notifications()api/app.py:518Paginated query of notifications filtered by tenant and status.
POST/notifications/dispatchNonelegacy_dispatch()api/app.py:552Direct synchronous dispatch adapter for legacy callers.
GET/api/v1/console/overviewNoneget_console_overview()api/app.py:578Delivers aggregated KPIs (delivered, queued, suppressed, failed).
GET/api/v1/console/providersNoneget_console_providers()api/app.py:618Returns provider fleet dashboard with capability matrix.
GET/api/v1/console/queuesNoneget_console_queues()api/app.py:638Returns queue depth and active worker leases.
GET/api/v1/console/dlqNoneget_console_dlq()api/app.py:667Returns unhandled dead-letter queue records for investigation.
GET/api/v1/console/notifications/{id}Noneget_console_detail()api/app.py:695Detailed diagnostic view with delivery attempts breakdown.

0.4 Database Schema & Relational Stores (ER Diagram) ​

The persistence layer defines 9 relational entities managed through SQLAlchemy:


0.5 Final Inventory Counts ​

To guarantee documentation integrity across all subsequent sections, the following verifiable metrics are established:

DimensionCountVerification File
Total Features (Cataloged)19 Feature Groups (F1 - F19)docs/01-features.md, FEATURES.csv
Backend REST Endpoints19 Distinct Path/Method Combinationsbackend/src/api/app.py
Relational Database Tables9 Tables + 1 DLQ Table (10 Models)backend/src/models/store.py, backend/src/retries/failure.py
Automated Pytest Tests114 Tests Across 56 Test Filesbackend/tests/, frontend/tests/
Supported Notification Channels5 Channels (Email, SMS, Webhook, Push, In-App)backend/src/core/engine.py
Priority Levels4 Tiers (URGENT: 100, HIGH: 50, NORMAL: 10, LOW: 0)backend/src/core/engine.py:32
Frontend Operations Views4 Tabs (Console, Providers, Queues, DLQ Viewer)frontend/src/app.js:26
Master Checklist Items275 Exhaustive Audit Itemsdocs/13-master-checklist.md