5.1 High-Level System Data Flow
┌─────────────────────────────────────────────────────────────────┐
│ EG Flow Complete Data Flow │
└─────────────────────────────────────────────────────────────────┘
External System EG Flow System (Azure)
(Utility Billing)
│
│ 1. Generate monthly
│ invoice batch (XML)
│
├──────────────────────────────────────────>
│ POST /batches ┌──────────────┐
│ (GASEL/XELLENT/ZYNERGY XML) │ Core API │
│ │ Service │
│ │ │
│ │ • Auth check │
│ │ • Validate │
│ │ • Store blob │
│ └──────┬───────┘
│ │
│ 2. Return Batch ID │
│<────────────────────────────────────────────┤
│ {batchId, status: "uploaded"} │
│ │
│ 3. Start Processing │
├──────────────────────────────────────────> │
│ POST /batches/{id}/start │
│ │
│ ┌──────▼───────┐
│ │ Blob │
│ │ Storage │
│ │ │
│ │ {org}-batches│
│ │ /2025/11/21/ │
│ └──────┬───────┘
│ │
│ 4. 202 Accepted (queued) │
│<────────────────────────────────────────────┤
│ │
│ ┌──────▼────────┐
│ │ Storage │
│ │ Queues │
│ │ │
│ │ • batch-upload│
│ │ • batch-items │
│ │ • email │
│ │ • postal-bulk │
│ └───────┬───────┘
│ │
│ ┌───────────────┼──────────────┐
│ │ │ │
│ ┌──────▼─────┐ ┌──────▼─────┐ ┌──────▼─────┐
│ │ Parser │ │ Document │ │ Email │
│ │ Service │ │ Generator │ │ Service │
│ │ │ │ │ │ │
│ │ • Detect │ │ • Render │ │ • SendGrid │
│ │ • Validate │ │ • PDF gen │ │ • Retry │
│ │ • Parse │ │ • Store │ │ • Fallback │
│ │ • Transform│ │ │ │ │
│ └──────┬─────┘ └─────┬──────┘ └─────┬──────┘
│ │ │ │
│ Creates 157 Creates PDFs Sends emails
│ JSON files & queues │
│ (5000/32) delivery │
│ │ │ │
│ ▼ ▼ ▼
│ ┌──────────────────────────────────────┐
│ │ Blob Storage │
│ │ │
│ │ {org}-invoices-2025/11/21/ │
│ │ ├── {id}.json (canonical data) │
│ │ ├── {id}.html (rendered) │
│ │ └── {id}.pdf (final invoice) │
│ └──────────────────────────────────────┘
│ │
│ 5. Poll Status │
│ GET /batches/{id} │
├───────────────────────────────────────────> │
│ │
│ 6. Status Response │
│<─────────────────────────────────────────────┤
│ {status: "processing", │
│ processedItems: 3200/5000} │
│ │
│ 7. Status: Completed │
│<─────────────────────────────────────────────┤
│ {status: "completed", │
│ successfulItems: 4950, │
│ failedItems: 50} │
│ │
│ ┌───────▼──────┐
│ │ Postal │
│ │ Service │
│ │ │
│ │ • Collect │
│ │ • Create ZIP │
│ │ • 21G SFTP │
│ └───────┬──────┘
│ │
End Customer │
│ │
│ 8a. Receive Email │
│<─────────────────────────────────────────────┤
│ (PDF attachment) │
│ │
│ 8b. Receive Postal │
│<─────────────────────────────────────────────┤
│ (via 21G print partner) │
...
5.2 Batch Upload Flow
┌──────────────────────────────────────────────────────────────┐
│ Batch Upload Data Flow │
└──────────────────────────────────────────────────────────────┘
Client API Gateway Core API Blob Storage
│ │ │ │
├─ POST /batches ────────>│ │ │
│ (XML file) │ │ │
│ ├─ Authenticate ────>│ │
│ │ (Entra ID) │ │
│ │<─ JWT Valid ───────┤ │
│ │ │ │
│ ├─ Authorize ───────>│ │
│ │ (Check role) │ │
│ │<─ Access OK ───────┤ │
│ │ │ │
│ ├─ Upload File ─────>│ │
│ │ ├─ Generate UUID ──────>│
│ │ │ (Batch ID) │
│ │ │ │
│ │ ├─ Store XML ──────────>│
│ │ │ {org}-batches-2025/ │
│ │ │ 11/21/{id}/source.xml│
│ │ │<─ Stored ─────────────┤
│ │ │ │
│ │ ├─ Quick Detect ───────>│
│ │ │ (Namespace peek) │
│ │ │<─ Format: GASEL ──────┤
│ │ │ │
│ │ ├─ Create Metadata ────>│
│ │ │ metadata.json │
│ │ │<─ Created ────────────┤
│ │ │ │
│ │<─ 201 Created ─────┤ │
│ │ {batchId} │ │
│<─ 201 Created ──────────┤ │ │
│ {batchId, status} │ │ │
...
