Loyalty Club System

A points-and-tiers loyalty club for a food delivery business at Sepand. A .NET 6 REST API on PostgreSQL, with one Flutter app for Android and iOS.

Full Stack Developer · 2022 - 2024 · Food Delivery

Tech: .NET 6, EF Core 6, Flutter, GetX, PostgreSQL, REST API

The problem

Food delivery runs on thin margins and customers switch apps easily. The business wanted a loyalty program to keep repeat customers: points on every order, membership tiers, and gift card redemption.

The approach

I built a .NET 6 Web API with EF Core 6 on PostgreSQL and a Flutter app using GetX. Earning rules are stored as data, so the business can change them without a redeploy.

Outcomes

  • Loyalty club shipped on Android and iOS from one Flutter codebase
  • Points kept in an append-only ledger, with idempotent earning per order
  • Earning rules the business can change without code changes

What it is

The Loyalty Club System is a retention platform for a food delivery business at Sepand. Repeat customers earn points, move up tiers and redeem gift cards. A REST API serves a Flutter app that runs on Android and iOS.

Why the business wanted it

Food delivery has low margins and high churn. Customers move between competing apps freely unless they have a reason to stay. The loyalty engine needed to:

  • award points on every completed order, with configurable earning rules
  • support Bronze, Silver and Gold tiers, each with its own perks
  • let customers redeem points for gift cards and discounts at checkout
  • run on Android and iOS from one codebase

Architecture

flowchart LR
  subgraph Client
    A[Flutter App<br/>GetX state]
  end
  subgraph Backend[.NET 6 REST API]
    B[Auth & Members]
    C[Points Engine]
    D[Rewards & Gift Cards]
  end
  E[(PostgreSQL)]
  F[Order Events]

  A -->|HTTPS / JWT| B
  A -->|HTTPS| C
  A -->|HTTPS| D
  F -->|order completed| C
  B --> E
  C --> E
  D --> E

How it's built

  • Backend: ASP.NET (.NET 6) Web API in layers. Controllers, application services, and an EF Core 6 persistence layer on PostgreSQL.
  • Points engine: earning rules are data (points per currency unit, bonus multipliers per tier), so marketing can tune them without a redeploy.
  • Mobile: Flutter with GetX for state, dependency injection and routing. Screens stay thin and the logic sits in controllers.
  • Auth: JWT bearer tokens, with refresh tokens for long-lived mobile sessions.

Earning and redeeming points

sequenceDiagram
  participant U as Customer (Flutter)
  participant API as .NET 6 API
  participant PE as Points Engine
  participant DB as PostgreSQL

  U->>API: Place / complete order
  API->>PE: Calculate points(order, tier)
  PE->>DB: Persist ledger entry
  PE-->>API: New balance + tier
  API-->>U: Updated points & tier
  U->>API: Redeem points for gift card
  API->>DB: Debit ledger, issue gift card
  API-->>U: Gift card code

Two problems worth mentioning

  • Double awards on retries. Order events could arrive more than once, so the ledger is keyed by order id. Processing the same order a second time does nothing.
  • Balance integrity. The balance is calculated from an append-only ledger instead of a counter that gets overwritten. Every change can be audited and reconciled.

Result

  • A working loyalty program on Android and iOS from a single Flutter codebase.
  • An auditable, append-only points ledger with idempotent earning.
  • Earning rules the business can adjust without touching code.