Daftar
Order Processing System

A comprehensive .NET 9 system for monitoring order status changes in Supabase, generating professional PDFs with Arabic support, uploading to cloud storage, and sending WhatsApp notifications with PDF attachments.

Daftar System

Technical Overview for .NET Developers

A production-ready system built with clean architecture principles

Architecture Highlights

  • Clean Architecture - Separated Core, Services, Dashboard, and Host layers
  • Domain-Driven Design - Rich domain models with clear boundaries
  • SOLID Principles - Interface-based design with dependency injection
  • Background Services - IHostedService for continuous order monitoring
  • Real-time Updates - SignalR for live dashboard updates

Key Implementation Details

  • Async/Await Pattern - Throughout for non-blocking operations
  • Polly Resilience - Retry policies for external service calls
  • Channel<T> - In-memory queue for notification processing
  • Serilog Structured Logging - With contextual information
  • Health Checks - ASP.NET Core health monitoring

Code Quality & Best Practices

Zero Warnings

Clean compilation

C# 12

Latest Features

Modern syntax

DI

Full DI Container

Service lifetimes

🐳

Docker Ready

Production deployment

Detailed System Architecture

Clean architecture with dependency injection and separation of concerns

Clean Architecture Layers

DaftarOrderProcessor.Core

Domain layer - No external dependencies

Models/ Interfaces/ Enums/ Configuration/

DaftarOrderProcessor.Services

Application layer - Business logic implementation

BackgroundServices/ PdfGeneration/ Integration/

DaftarOrderProcessor.Dashboard

Presentation layer - Blazor Server UI

Pages/ Components/ Services/ Hubs/

DaftarOrderProcessor.Host

Infrastructure layer - Composition root & DI setup

Program.cs appsettings.json wwwroot/

Dependency Injection Setup

Program.cs - Service Registration
// Core Services
builder.Services.AddSingleton<ISupabaseService, SupabaseService>();
builder.Services.AddSingleton<INotificationQueue, NotificationQueue>();
builder.Services.AddSingleton<IMetricsCollector, MetricsCollector>();

// Background Services
builder.Services.AddHostedService<OrderMonitoringService>();
builder.Services.AddHostedService<NotificationProcessorService>();

// Integration Services
builder.Services.AddScoped<IPdfGenerationService, PdfGenerationService>();
builder.Services.AddScoped<IWhatsAppService, WhatsAppService>();

// Blazor Dashboard
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSignalR();

Key Interfaces

  • ISupabaseService - Database operations
  • IPdfGenerationService - PDF document creation
  • IWhatsAppService - WhatsApp messaging
  • INotificationQueue - Queue management
  • IMetricsCollector - Performance metrics
  • IOrderTaskProcessor - Order processing logic

Background Services

  • OrderMonitoringService - Watches for order changes
  • NotificationProcessorService - Processes notification queue
  • Uses IHostedService pattern
  • Implements graceful shutdown with CancellationToken
  • Periodic health checks and retry mechanisms
  • Structured logging with correlation IDs

Detailed Processing Pipeline

Supabase Trigger

Real-time subscription

Task Processing

Status-based routing

PDF Generation

QuestPDF + Storage

Notification

WhatsApp + Retry

Powerful Features

Everything you need for complete order automation

Real-time Monitoring

Monitors order status changes instantly using Supabase Realtime subscriptions.

Professional PDFs

Generates beautiful PDFs with QuestPDF, including full Arabic/RTL support.

WhatsApp Integration

Sends notifications via WAHA API with PDF attachments to all stakeholders.

Cloud Storage

Automatically uploads documents to Supabase Storage for secure access.

Admin Dashboard

Real-time Blazor dashboard for monitoring, configuration, and queue management.

Production Ready

Docker deployment, health checks, structured logging, and resilient error handling.

Technology Stack

Cutting-edge technologies powering a robust .NET ecosystem

🟣

.NET 9

Core Framework

Blazor Server

Web UI

🔗

SignalR

Real-time

📊

Supabase

Database

📄

QuestPDF

PDF Generation

💬

WAHA API

WhatsApp

🐳

Docker

Deployment

🔄

Polly

Resilience

📝

Serilog

Logging

🎨

Bootstrap 5

UI Framework

🔍

Swagger

API Docs

🏥

Health Checks

Monitoring

OrderMonitoringService.cs
C# Service
public class OrderMonitoringService : BackgroundService
{
    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
    {
        // Setup realtime subscription
        await SetupRealtimeSubscription();
        
        // Process existing orders on startup
        await ProcessMissedOrders();
        
        // Periodic check every 5 minutes
        using var timer = new PeriodicTimer(TimeSpan.FromMinutes(5));
    }
}
PurchaseOrderDocument.cs
PDF Generation
public void Compose(IDocumentContainer container)
{
    container.Page(page =>
    {
        page.DefaultTextStyle(x => x.FontFamily("Noto Sans Arabic"));
        page.ContentFromRightToLeft();
        
        page.Header().Element(ComposeHeader);
        page.Content().Element(ComposeContent);
        page.Footer().Element(ComposeFooter);
    });
}

Project Structure

DaftarOrderProcessor/
├── src/
│ ├── DaftarOrderProcessor.Core/
│ │ ├── Models/
│ │ ├── Interfaces/
│ │ └── Enums/
│ ├── DaftarOrderProcessor.Services/
│ │ ├── BackgroundServices/
│ │ ├── PdfGeneration/
│ │ └── Integration/
│ ├── DaftarOrderProcessor.Dashboard/
│ │ ├── Pages/
│ │ ├── Components/
│ │ └── Services/
│ └── DaftarOrderProcessor.Host/
├── tests/
├── docker/
└── README.md

System Layers

Core Layer

Domain models and business interfaces

Services Layer

Business logic and service implementations

Dashboard Layer

User interface and admin controls

Host Layer

Application entry point and configuration

Live Demonstration

Experience the real-time dashboard and see the system in action

Daftar Admin Dashboard
localhost:8080
6
Orders Today
Rate 1.2/min
3
PDFs Generated
Successfully
0
Notifications
Sent Today
0
Queue Size
0.0% Error Rate

Real-time Activity

Live
efa9df08...f5f6
Purchase Order Completed
2 mins ago
ec949d9c...84d3
PDF Generated
3 mins ago
e05a4e68...78ad
WhatsApp Notification Sent
5 mins ago

System Status

Supabase Connected
WhatsApp Ready
Processing Active

Quick Actions

Notification Queue

View All
Order # Type Status Created Actions

No items in queue

Quick Installation

Get up and running in minutes

Docker Deployment

bash
# Clone the repository
git clone https://github.com/ahmedalsamaani/daftar-dotnet.git
cd daftar-dotnet/docker

# Configure environment
cp .env.example .env
nano .env

# Start services
docker-compose up -d

# View logs
docker-compose logs -f daftar-order-processor

Local Development

bash
# Install .NET 9 SDK
# https://dotnet.microsoft.com/download

# Build the solution
dotnet build

# Run with dashboard
dotnet run --project src/DaftarOrderProcessor.Host

# Run tests
dotnet test

Access Points

Admin Dashboard

http://localhost:5000

Health Check

http://localhost:5000/health

WhatsApp API

http://localhost:3000

API Docs

http://localhost:5000/swagger

Code Review Considerations

Areas for technical discussion and potential improvements

Current Strengths

  • Clean Architecture - Clear separation between layers with dependency flow
  • Async/Await Throughout - Non-blocking operations for scalability
  • Resilience Patterns - Polly retry policies on external service calls
  • Structured Logging - Serilog with contextual information
  • Health Monitoring - Built-in health checks for all dependencies
  • Docker Ready - Multi-stage build with optimized layers

Potential Improvements

  • Unit Test Coverage - Add comprehensive test suite with mocking
  • Message Queue - Consider RabbitMQ/Azure Service Bus for reliability
  • Caching Strategy - Add Redis for frequently accessed data
  • API Versioning - Implement versioning for future compatibility
  • Authentication - Add identity management for dashboard access
  • Observability - Add OpenTelemetry for distributed tracing

Performance Characteristics

< 100ms

Order Detection

Real-time trigger

< 2s

PDF Generation

Complex documents

99.9%

Uptime Target

With retry logic

1000+

Orders/Hour

Scalable design

Ready to Review and Contribute?

Let's collaborate to make this system even better

Quick Setup

docker-compose up -d

Run Tests

dotnet test

View Dashboard

localhost:8080