Sanad

Dynamic Request & Side-Effects Engine

Request Details

Configure the request metadata that triggers the workflow.

Return from Leave Request

Event Trigger Simulation

Press simulate to trigger the event chain.

SQL Preview

PostgreSQL / JSONB
-- Sanad: Write request payload to event store
INSERT INTO sanad.request_payloads (
  id, request_type, payload, status, created_at
)
VALUES (
  @id,
  @requestType,
  @payload::jsonb,
  'pending',
  NOW()
);
Attendance Insert
-- Attendance module: insert record from mapped payload
INSERT INTO attendance.records (
  employee_id, date, type, source, created_at
)
VALUES (
  @empId,
  @date,
  'present',
  'sanad_engine',
  NOW()
);

C# Strategy Pattern

IPluginStrategy / MarkPresentStrategy
public interface IPluginStrategy
{
    string Key { get; }
    Task<PluginResult> ExecuteAsync(
        RequestContext context,
        CancellationToken ct
    );
}

public sealed class MarkPresentStrategy : IPluginStrategy
{
    public string Key => "Attendance.MarkPresent";

    public async Task<PluginResult> ExecuteAsync(
        RequestContext context,
        CancellationToken ct)
    {
        var payload = context.GetPayload<AttendancePayload>();
        var record = new AttendanceRecord
        {
            EmployeeId = payload.EmployeeId,
            Date = payload.ResumptionDate,
            Type = AttendanceType.Present
        };

        await _db.AttendanceRecords.AddAsync(record, ct);
        await _db.SaveChangesAsync(ct);

        return PluginResult.Success(
            "MarkPresent", 1, record.Id);
    }
}