Back to page

Realtime Database Mapping (wb_ast)

Raw Markdown & AI/RAG Chunks
Raw Markdown Source 3242 chars
# Realtime Database Mapping (wb_ast)

To maximize performance, the core routing logic bypasses web REST latency entirely during low-level call execution. **Asterisk 2** utilizes a dedicated Entity Framework Core proxy context (`AstDbContext`) that maps directly to the external Asterisk infrastructure database (`wb_ast`).

---

## Proxy Entity Framework Mapping Engine

The layout below illustrates how low-latency operational database queries are decoupled from administrative data structures:

```mermaid
graph TD
    %% Query Consumer
    subgraph Consumer["Telephony Routing Engine"]
        SIP_Logic["PJSIP Registration / CDR Handlers"]
    end

    %% Decoupled Proxy Mapping Context
    subgraph ProxyContext["Decoupled EF Core Proxy Layer"]
        AstCtx["AstDbContext Class<br/>(Read-Only Database Proxy)"]
    end

    %% External Schema Targets
    subgraph TargetSchema["External Operational Engine (wb_ast)"]
        Tab_Endpoint[("ps_endpoints Table<br/>(SIP Realtime Auth)")]
        Tab_Servers[("servers Table<br/>(Node Load Stats)")]
        Tab_Cdr[("cdr Table<br/>(Call Records)")]
        Tab_Cel[("cel Table<br/>(Channel Events)")]
        Tab_Queue[("queue_log Table<br/>(Call Center Wait Logic)")]
    end

    %% Data Requests
    Consumer -->|"Direct LINQ Query"| AstCtx
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Endpoint
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Servers
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Cdr
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Cel
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Queue

    %% Premium Palette Tokens
    classDef consumerToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef proxyToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef schemaToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class Consumer,SIP_Logic consumerToken;
    class ProxyContext,AstCtx proxyToken;
    class TargetSchema,Tab_Endpoint,Tab_Servers,Tab_Cdr,Tab_Cel,Tab_Queue schemaToken;
```

---

## Mapped Entity Framework DbSet Specifications

| Entity Framework DbSet | External DB Table Name | Query Tracking Setting | Core Functional Telephony Duty |
| :--- | :--- | :--- | :--- |
| `PsEndpoints` | `ps_endpoints` | **AsNoTracking** | Verifies standard PJSIP client authorization credentials, transport options, and audio codec arrays instantly. |
| `Servers` | `servers` | **Read / Write** | Tracks individual active Asterisk cluster instances, CPU stats, and heartbeat timestamps. |
| `Cdrs` | `cdr` | **AsNoTracking** | Long-term tracking archive capturing finalized call sessions, duration stats, and answer statuses. |
| `Cels` | `cel` | **AsNoTracking** | Captures real-time channel sub-events, state mutations, and call transfer handshakes. |
| `QueueLogs` | `queue_log` | **AsNoTracking** | Exposes native call center queue events, agent dropouts, and customer wait metrics cleanly. |

---

## Infrastructure Parity
Because `AstDbContext` directly queries live operational databases, all migration operations are explicitly disabled for this context. Application updates must never alter native schema structures to avoid breaking internal PBX database drivers.
AI Chunks (RAG) 4 chunks
Chunk #1 Realtime Database Mapping (wb_ast)
# Realtime Database Mapping (wb_ast)

To maximize performance, the core routing logic bypasses web REST latency entirely during low-level call execution. **Asterisk 2** utilizes a dedicated Entity Framework Core proxy context (`AstDbContext`) that maps directly to the external Asterisk infrastructure database (`wb_ast`).

---
Chunk #2 Proxy Entity Framework Mapping Engine
## Proxy Entity Framework Mapping Engine

The layout below illustrates how low-latency operational database queries are decoupled from administrative data structures:

```mermaid
graph TD
    %% Query Consumer
    subgraph Consumer["Telephony Routing Engine"]
        SIP_Logic["PJSIP Registration / CDR Handlers"]
    end

    %% Decoupled Proxy Mapping Context
    subgraph ProxyContext["Decoupled EF Core Proxy Layer"]
        AstCtx["AstDbContext Class<br/>(Read-Only Database Proxy)"]
    end

    %% External Schema Targets
    subgraph TargetSchema["External Operational Engine (wb_ast)"]
        Tab_Endpoint[("ps_endpoints Table<br/>(SIP Realtime Auth)")]
        Tab_Servers[("servers Table<br/>(Node Load Stats)")]
        Tab_Cdr[("cdr Table<br/>(Call Records)")]
        Tab_Cel[("cel Table<br/>(Channel Events)")]
        Tab_Queue[("queue_log Table<br/>(Call Center Wait Logic)")]
    end

    %% Data Requests
    Consumer -->|"Direct LINQ Query"| AstCtx
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Endpoint
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Servers
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Cdr
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Cel
    AstCtx ==>|"Mapped DbSet Connection"| Tab_Queue

    %% Premium Palette Tokens
    classDef consumerToken fill:#0f172a,stroke:#38bdf8,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef proxyToken fill:#312e81,stroke:#ec4899,stroke-width:2px,color:#fff,rx:6px,ry:6px;
    classDef schemaToken fill:#1e293b,stroke:#a855f7,stroke-width:2px,color:#fff,rx:6px,ry:6px;

    class Consumer,SIP_Logic consumerToken;
    class ProxyContext,AstCtx proxyToken;
    class TargetSchema,Tab_Endpoint,Tab_Servers,Tab_Cdr,Tab_Cel,Tab_Queue schemaToken;
```

---
Chunk #3 Mapped Entity Framework DbSet Specifications
## Mapped Entity Framework DbSet Specifications

| Entity Framework DbSet | External DB Table Name | Query Tracking Setting | Core Functional Telephony Duty |
| :--- | :--- | :--- | :--- |
| `PsEndpoints` | `ps_endpoints` | **AsNoTracking** | Verifies standard PJSIP client authorization credentials, transport options, and audio codec arrays instantly. |
| `Servers` | `servers` | **Read / Write** | Tracks individual active Asterisk cluster instances, CPU stats, and heartbeat timestamps. |
| `Cdrs` | `cdr` | **AsNoTracking** | Long-term tracking archive capturing finalized call sessions, duration stats, and answer statuses. |
| `Cels` | `cel` | **AsNoTracking** | Captures real-time channel sub-events, state mutations, and call transfer handshakes. |
| `QueueLogs` | `queue_log` | **AsNoTracking** | Exposes native call center queue events, agent dropouts, and customer wait metrics cleanly. |

---
Chunk #4 Infrastructure Parity
## Infrastructure Parity
Because `AstDbContext` directly queries live operational databases, all migration operations are explicitly disabled for this context. Application updates must never alter native schema structures to avoid breaking internal PBX database drivers.