Forge notifications module — thin wrapper around domain-notifications. Sprint 57 prerequisite for application-tickets.
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/notifications |
| Edition | 2024 |
| Targets | application_notifications, pg_forge_notifications |
| Public items | 23 across 4 modules |
| Tests | 4 |
What it is for
application-notifications — Layer 3 module for notifications.
Thin wrapper around domain-notifications. Extracted from rust-cms-engine in sprint 57 as a prerequisite for application-tickets (tickets fire notifications on state transitions).
B-009: before this, migrations() returned Vec::new() and migrate_pending returned Ok(0) while ignoring the pool, so notifications/notification_templates/notification_preferences/ delivery_attempts (plus the unread-count/channel-enabled helper functions and RLS policies, crates/domain/notifications/migrations/001_notifications_init.sql) were never created by anything that actually called this module's own migration path. All four tables are self-contained (FKs stay inside this library crate's own schema — recipient_party_id/party_id are bare UUIDs, not constraints), so migrate_pending needs no cross-module bootstrap. Mirrors application-encounters's and application-calendar's pattern exactly.
Capabilities
NotificationsModule
application-notifications — Layer 3 module for notifications.
| Item |
|---|
pub struct NotificationsModule |
NotificationsModule :: fn new() -> Self |
NotificationsModule :: fn name(& self) -> & 'static str |
NotificationsModule :: fn version(& self) -> & 'static str |
NotificationsModule :: fn migrations(& self) -> Vec <MigrationSet> |
NotificationsModule :: async fn migrate_pending(& self, pool : & PgPool) -> Result <u32, MigrationError> |
NotificationsModule :: fn permission_codes(& self) -> Vec <String> |
api (other)
HTTP API routers for application-notifications.
| Item |
|---|
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
api::notifications_admin (other)
Notifications admin REST router.
| Item |
|---|
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, |
ListQuery
Notifications admin REST router.
| Item |
|---|
pub struct ListQuery |
MarkAllReadInput
Notifications admin REST router.
| Item |
|---|
pub struct MarkAllReadInput |
PreferencesQuery
Notifications admin REST router.
| Item |
|---|
pub struct PreferencesQuery |
UnreadCountQuery
Notifications admin REST router.
| Item |
|---|
pub struct UnreadCountQuery |
UpdatePreferenceInput
Notifications admin REST router.
| Item |
|---|
pub struct UpdatePreferenceInput |
services::notifications (other)
Notifications service — thin wrapper around
| Item |
|---|
async fn list(pool : & PgPool, tenant_id : Uuid, party_id : Uuid, limit : i64, offset : i64,) -> Result <Vec <Notification>, NotificationError> |
async fn list_unread(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <Vec <Notification>, NotificationError> |
async fn count_unread(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <i64, NotificationError> |
async fn get(pool : & PgPool, id : Uuid) -> Result <Option <Notification>, NotificationError> |
async fn mark_read(pool : & PgPool, id : Uuid) -> Result <bool, NotificationError> |
async fn mark_all_read(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <i64, NotificationError> |
async fn get_preferences(pool : & PgPool, party_id : Uuid, tenant_id : Uuid,) -> Result <Vec <NotificationPreference>, NotificationError> |
async fn update_preferences(pool : & PgPool, party_id : Uuid, tenant_id : Uuid, channel : NotificationChannel, event_type : Option <String>, enabled : bool,) -> Result <NotificationPreference, NotificationError> |
async fn create_for_party(pool : & PgPool, tenant_id : Uuid, recipient_party_id : Uuid, event_type : impl Into <String>, title : impl Into <String>, body : impl Into <String>, entity_type : Option <& str>, entity_id : Option <Uuid>, idempotency_key : Option <String>,) -> Result <Notification, NotificationError> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
application_notifications
apiapi::notifications_adminservicesservices::notifications
flowchart TD n_application_notifications["application_notifications"] n_application_notifications --> n_api["api"] n_api --> n_api__notifications_admin["notifications_admin"] n_application_notifications --> n_services["services"] n_services --> n_services__notifications["notifications"]
Public surface
`crate root`
| Item | What it is |
|---|---|
pub struct NotificationsModule | — |
NotificationsModule :: fn new() -> Self | — |
NotificationsModule :: fn name(& self) -> & 'static str | — |
NotificationsModule :: fn version(& self) -> & 'static str | — |
NotificationsModule :: fn migrations(& self) -> Vec <MigrationSet> | — |
NotificationsModule :: async fn migrate_pending(& self, pool : & PgPool) -> Result <u32, MigrationError> | — |
NotificationsModule :: fn permission_codes(& self) -> Vec <String> | sprint-3.7 S1 T3 — the permission vocabulary this module's admin router expects a host to enforce |
`api`
| Item | What it is |
|---|---|
fn admin_router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | Admin router composing all notifications admin sub-routers. |
`api::notifications_admin`
| Item | What it is |
|---|---|
pub struct ListQuery | — |
pub struct UnreadCountQuery | — |
pub struct MarkAllReadInput | — |
pub struct PreferencesQuery | — |
pub struct UpdatePreferenceInput | — |
fn router <S>() -> Router <S> where S : Clone + Send + Sync + 'static, PgPool : FromRef <S>, | — |
`services::notifications`
| Item | What it is |
|---|---|
async fn list(pool : & PgPool, tenant_id : Uuid, party_id : Uuid, limit : i64, offset : i64,) -> Result <Vec <Notification>, NotificationError> | — |
async fn list_unread(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <Vec <Notification>, NotificationError> | — |
async fn count_unread(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <i64, NotificationError> | — |
async fn get(pool : & PgPool, id : Uuid) -> Result <Option <Notification>, NotificationError> | — |
async fn mark_read(pool : & PgPool, id : Uuid) -> Result <bool, NotificationError> | — |
async fn mark_all_read(pool : & PgPool, tenant_id : Uuid, party_id : Uuid,) -> Result <i64, NotificationError> | — |
async fn get_preferences(pool : & PgPool, party_id : Uuid, tenant_id : Uuid,) -> Result <Vec <NotificationPreference>, NotificationError> | — |
async fn update_preferences(pool : & PgPool, party_id : Uuid, tenant_id : Uuid, channel : NotificationChannel, event_type : Option <String>, enabled : bool,) -> Result <NotificationPreference, NotificationError> | — |
async fn create_for_party(pool : & PgPool, tenant_id : Uuid, recipient_party_id : Uuid, event_type : impl Into <String>, title : impl Into <String>, body : impl Into <String>, entity_type : Option <& str>, entity_id : Option <Uuid>, idempotency_key : Option <String>,) -> Result <Notification, NotificationError> | Create an in-app notification for a specific party |
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into domain, platform.
Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | application |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/application/notifications |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_application["application"] --> n_domain["domain"] n_application["application"] --> n_platform["platform"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-core` | application | no | always |
| `domain-notifications` | domain | no | always |
| `platform-dto` | platform | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
axum | ^0.7 | multipart | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 2 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_dlp["application-dlp"] -->|uses| SELF n_application_tickets["application-tickets"] -->|uses| SELF SELF["application-notifications"] SELF -->|runtime| n_application_core["application-core"] SELF -->|runtime| n_domain_notifications["domain-notifications"] SELF -->|runtime| n_platform_dto["platform-dto"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | application_notifications | `src/lib.rs` |
| test | pg_forge_notifications | `tests/pg_forge_notifications.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | yes |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CARGO_PKG_VERSION | src/lib.rs |
Related capabilities
2 workspace crates depend on this one: application-dlp, application-tickets.
Verification
| Kind | Count |
|---|---|
| Unit tests | 3 |
| Integration tests | 1 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 1 | 0 | 0 |
api | 1 | 0 | 2 |
api::notifications_admin | 6 | 0 | 1 |
services::notifications | 9 | 0 | 5 |
What the tests establish, by name:
migrate_pending_creates_notifications_table—tests/pg_forge_notifications.rsdeclares_a_read_and_a_write_permission_code—src/lib.rsdeclares_no_code_without_a_route_behind_it—src/lib.rstest_module_migrations_non_empty—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 3 | 23 |
Public modules with a //! block | 3 | 4 |
pie showData
title Public items with rustdoc
"Documented" : 3
"No rustdoc detected" : 20
Metrics
| Metric | Value |
|---|---|
| Rust source files | 5 |
| Source lines | 512 |
| Code lines | 375 |
| Public API items | 23 |
| Public modules | 4 |
| Tests | 4 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 10 |
| Workspace reverse dependencies | 2 |
pie showData
title Public API by kind
"function" : 11
"method" : 6
"struct" : 6
pie showData
title Rust source composition
"Code" : 375
"Blank or comment" : 137
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.