BR-001: Multi-Tenant Organization Support

Priority: CRITICAL
Owner: Product Owner

Description

The system shall support multiple independent utility companies (organizations) with complete data isolation at blob storage, processing, and user access levels.

Business Value

  1. Revenue Model: Enables SaaS subscription model across Nordic markets
  2. Cost Efficiency: Shared infrastructure reduces per-customer cost by 60-70%
  3. Market Penetration: Faster onboarding enables rapid customer acquisition
  4. Scalability: Single platform scales to serve 150+ Swedish utilities alone

Nordic Market Context

Total Addressable Market: 700+ potential customers

Acceptance Criteria

#CriterionMeasurement MethodTarget
1Concurrent organizations supportedLoad test with 50 orgsAll batches process successfully
2Data isolation enforcementCross-org access attempts100% blocked (403 Forbidden)
3Organization-specific blob containersVerify storage pathsPattern: {org-id}-{type}-{year}/
4User organization boundary enforcementAPI calls with wrong org contextAll rejected
5Independent branding per organizationUpload logo, verify renderingBranding applied correctly
6Configurable delivery channelsSet priority [email, postal]Order respected

Dependencies

Risks & Mitigation

RiskLikelihoodImpactMitigation
Data leakage between orgsLOWCRITICALMiddleware enforcement, automated testing, penetration testing
Performance degradation (50+ tenants)MEDIUMHIGHBlob auto-scaling, connection pooling, indexed queries
Swedish data residency requirementsLOWHIGHWest Europe primary, no cross-border transfer

BR-002: Multi-Vendor XML Format Support

Priority: HIGH
Owner: Product Owner

Description

The system shall process invoice batch files from multiple vendor billing systems (GASEL/Telinet, XELLENT/Karlskoga, ZYNERGY/EG Software) with automatic format detection and transformation to canonical JSON.

Business Value

  1. Market Coverage: Supports 70% of Swedish utilities market
  2. Zero Custom Development: No per-vendor integration coding required
  3. Faster Onboarding: 80% reduction in integration time
  4. Vendor Agnostic: Future-proofs against vendor migrations

Nordic Market Context

Top 3 Billing Systems in Swedish Market:

Combined Coverage: ~70% of addressable market

Acceptance Criteria

#CriterionMeasurement MethodTarget
1GASEL format detection50 sample files100% accuracy
2XELLENT format detection50 sample files100% accuracy
3ZYNERGY format detection50 sample files100% accuracy
4Canonical JSON transformationSchema validationAll fields present
5XSD schema validationVendor-specific XSDPass validation
6Unsupported format handlingUnknown XML upload415 error with vendor list
7Detection performance100MB file< 1 second

Vendor-Specific Requirements

GASEL (Telinet/EDIEL):

XELLENT (Karlskoga/OIOXML):

ZYNERGY (EG Software):

Dependencies

Risks & Mitigation

RiskLikelihoodImpactMitigation
Vendor schema changes without noticeMEDIUMHIGHVersion all schemas, support multiple versions, 3-month deprecation notice
EDIEL standard evolutionMEDIUMMEDIUMMonitor Ediel.org, participate in Nordic working groups, backward compatibility
Complex namespace handling (OIOXML)LOWMEDIUMXmlNamespaceManager, extensive unit testing per vendor
Incomplete field mappingsMEDIUMMEDIUMComprehensive validation, custom fields dictionary, lenient parsing mode

BR-003: Batch Invoice Processing

Priority: HIGH
Owner: Product Owner

Description

The system shall process batch invoice files containing up to 100,000 invoices with parallel processing, retry logic, and granular status tracking.

Business Value

  1. High-Volume Support: Typical Swedish utility has 50K-200K customers
  2. Time Efficiency: 95% reduction in manual processing effort
  3. Customer Satisfaction: Days → hours delivery time
  4. Predictable SLAs: Enables committed service levels

Nordic Market Context

Monthly Invoice Patterns:

Acceptance Criteria

#CriterionMeasurement MethodTarget
1Single batch capacityUpload 100K invoicesAll processed
2Asynchronous processingAPI response time< 500ms (202 Accepted)
3Real-time progress trackingPoll during processingUpdates every 30 seconds
4Failed item isolation10 errors in 1000-item batch990 succeed independently
5Retry mechanismForce temporary failure3 retries then poison queue
6Processing time SLA100K invoice batch≤ 120 minutes
7Format support (Phase 1)Upload XML, JSON, CSVXML fully supported

Processing Flow

1. API receives batch upload → 201 Created (batch stored)
2. POST /start → 202 Accepted (queued for processing)
3. ParserService picks from batch-upload-queue
4. Parse XML → Individual JSON files (canonical format)
5. Group into 32-item batches → Enqueue to batch-items-queue
6. DocumentGenerator renders 32 items in parallel
7. Generate HTML → PDF → Store in blob
8. Route to delivery queue (email or postal)
9. Update batch statistics in real-time
10. Complete when all items processed

Dependencies

Risks & Mitigation

RiskLikelihoodImpactMitigation
Processing timeout during heating seasonMEDIUMHIGHPre-warm workers 1st/last week, priority queue, off-peak scheduling
Memory constraints (large XML >50MB)MEDIUMMEDIUMStream-based parsing, chunk processing, 100MB hard limit
Disk space exhaustionLOWMEDIUMEphemeral storage cleanup, blob-only persistence
Queue 64KB message limitMEDIUMMEDIUMStore data in blob, queue references only

BR-004: Template-Based Invoice Rendering

Priority: HIGH
Owner: Product Owner

Description

The system shall generate PDF and HTML invoices using organization-specific Handlebars templates with dynamic data binding and brand customization.

Business Value

  1. Brand Consistency: Professional appearance across all communications
  2. Regulatory Compliance: Swedish Energy Markets Inspectorate requirements
  3. Flexibility: Per-organization customization without code changes
  4. Future-Proof: Multi-language support foundation (SE, NO, DK, FI)

Swedish Regulatory Requirements

Energimarknadsinspektionen (Swedish Energy Markets Inspectorate) mandates:

Acceptance Criteria

#CriterionMeasurement MethodTarget
1Custom template uploadUpload via API/blobStored successfully
2Dynamic data bindingTest with invoice dataAll fields populated
3PDF generationHTML → PDFA4 format, readable
4Template versioningCreate v2.0.0Old batches use v1.0.0
5In-flight batch isolationUpdate template during processingIn-flight uses old version
6Template validationMissing variable uploadValidation error returned
7Organization brandingLogo, colors, fontsVisible in rendered PDF
8Swedish regulatory fieldsVerify required elementsAll present

Template Structure

Required Fields (Swedish Regulations):

Dependencies

Risks & Mitigation

RiskLikelihoodImpactMitigation
Template rendering bottleneckHIGHHIGHCompiled template caching (24h), parallel rendering (32 items), POC: 10K in <5 min
PDF generation quality (Swedish chars)MEDIUMMEDIUMUTF-8 encoding, font embedding (åäö), visual regression testing
Swedish regulatory complianceLOWCRITICALLegal review, required fields checklist, annual update review
Template injection attacksLOWCRITICALSandboxed execution, no eval/exec helpers, sanitization, security review

BR-005: Multi-Channel Delivery with Nordic Integration

Priority: HIGH
Owner: Product Owner

Description

The system shall deliver invoices through multiple channels (email, postal, future: Kivra, e-Faktura) with configurable priority, automatic fallback, and integration with Nordic delivery partners.

Business Value

  1. Delivery Success: >98% vs ~92% email-only
  2. Cost Reduction: Reduced returned mail costs
  3. Customer Preference: Digital-first with postal backup
  4. Legal Compliance: Swedish "rätt till pappersfaktura" (right to paper invoice)
  5. Future-Ready: Digital mailbox mandate preparations

Nordic Market Context

Legal Requirements:

Delivery Statistics (Industry Average):

Acceptance Criteria

#CriterionMeasurement MethodTarget
1Email delivery (SendGrid)1000 test invoices>95% delivered
2Postal delivery (21G SFTP)Create ZIP, uploadFile accepted by 21G
3Channel priority configurationSet [email, postal]Email attempted first
4Automatic fallbackForce email failurePostal triggered auto
5Delivery status trackingCheck invoice metadataStatus + timestamps recorded
6Retry logic (transient failures)Simulate SendGrid 429Retries with backoff
7Delivery confirmation loggingVerify audit logAll deliveries logged
821G bulk processing scheduleVerify postal queue12:00 and 20:00 CET

Channel Specifications

Email (SendGrid):

Postal (21G Bulk SFTP):

Phase 2 Channels:

Dependencies

Risks & Mitigation

RiskLikelihoodImpactMitigation
SendGrid Nordic deliverability issuesMEDIUMHIGHDedicated IP, SPF/DKIM/DMARC, sender reputation monitoring, backup: Azure Communication Services
21G SFTP connectivity issuesLOWHIGHRetry logic, dual credentials, alert on failure, 21G SLA monitoring, manual upload procedure
Postal delivery delays (Swedish postal)MEDIUMMEDIUMSet expectations (5-7 days), track confirmations, escalation for >10 days
Email spam filtering (Swedish ISPs)MEDIUMMEDIUMIP warmup, monitor bounce rates, ISP whitelist requests (Telia, Tele2, Telenor)