# Custom Program Type — Vision

**Date**: 2026-05-13
**Status**: Draft

---

## Problem

Every time a new program type is needed, a developer has to write a new workflow config file. There is no way for an admin to set up a new kind of program without a code change.

---

## What Needs to Be Built

### 1. Create a new Program Type: CUSTOM

A new entry in `program_type` table with key `CUSTOM`.

Unlike HDB / MSD / ENT / TAT — where feature flags are fixed at the type level — the CUSTOM type has no fixed flags. All features are configured per template by the admin.

---

### 2. Create Program Templates

When creating a template under the CUSTOM type, the admin configures which features apply. These flags are saved on the template and inherited by every program created from it.

#### Program Mode

| Flag | Options |
| --- | --- |
| `modeOfOperation` | ONLINE / OFFLINE / HYBRID |
| `onlineType` | MEETING / WEBINAR / LIVE_STREAM (only if online) |
| `hasMultipleSessions` | Yes / No |
| `isGroupedProgram` | Yes / No (e.g. city-wise sub-programs) |

#### Registration Rules

| Flag | Meaning |
| --- | --- |
| `requiresApproval` | Must a seeker be approved before paying? |
| `allowSaveAsDraft` | Can a seeker save and come back later? |
| `allowsProxyRegistration` | Can someone register on behalf of another person? |
| `limitedSeats` | Is there a seat cap? |
| `waitlistApplicable` | Is there a waitlist when seats are full? |

#### Stages to Enable

| Flag | Stage it activates |
| --- | --- |
| `requiresPayment` | Payment & Invoice |
| `isTravelInvolved` | Travel |
| `hasGoodies` | Goodies |
| `seekerCanShareExperience` | Share Experience (post-program) |

> If `modeOfOperation = ONLINE`, travel is automatically disabled.

Once this is in place, the existing program types — HDB, MSD, TAT, ENT — should also be created as named templates under CUSTOM, with their flags pre-filled as below:

| Template | Approval | Payment | Travel | Goodies |
| --- | --- | --- | --- | --- |
| HDB | ✅ | ✅ | ✅ | ✅ |
| MSD | ✅ | ✅ | ✅ | ✅ |
| TAT | ✅ | ✅ | ✅ | ❌ |
| ENT | ❌ | ✅ | ✅ | ❌ |

---

### 3. Create a Universal Workflow

A single workflow — `UNIVERSAL_WORKFLOW` — that contains all possible stages. The system reads the template flags and shows only the stages that apply to that program.

All stages (in fixed order):

```
1. Basic Details         — always shown
2. Mahatria Sections     — if program has those questions configured
3. Payment & Invoice     — if requiresPayment = true
4. Travel                — if isTravelInvolved = true
5. Goodies               — if hasGoodies = true
```

Approval is not a seeker-facing stage. It is a background admin action that unlocks the next applicable stage once approved.

#### Each stage must have: Actions + Success Screen + Success Screen Actions

All of these are conditional based on what flags are enabled.

##### Basic Details — Actions

| Action | Condition |
| --- | --- |
| Save as Draft | `allowSaveAsDraft = true` |
| Submit | Always |
| Cancel | Always |

##### Basic Details — Success Screen

| Scenario | Message | Next Button |
| --- | --- | --- |
| Approval required | "Submitted. You will be notified once approved." | — |
| No approval, payment required | "Submitted! Please complete your payment." | Go to Payment |
| No approval, no payment | "You are registered! No further steps needed." | — |
| Waitlisted | "You are #N on the waitlist. We will notify you when a seat is available." | — |

##### Payment & Invoice — Actions

| Action | Condition |
| --- | --- |
| Pay Online | Always (if online payment configured) |
| Pay Offline | Always |
| Download Proforma Invoice | After proforma is generated |
| Edit Billing Details | After invoice is raised |
| Cancel Registration | Always (if not completed) |

##### Payment & Invoice — Success Screen

| Scenario | Message | Next Button |
| --- | --- | --- |
| Online payment done | "Payment received. Your registration is confirmed!" | Download Receipt |
| Offline submitted | "Payment details submitted. Finance will confirm within 2 working days." | Download Proforma |

##### Travel — Actions

| Action | Condition |
| --- | --- |
| Save Travel Info | Always |
| Save Travel Plan | After travel info is saved |
| Edit | After submission |

##### Travel — Success Screen

| Scenario | Message | Next Button |
| --- | --- | --- |
| Both sections saved | "Travel details saved. The coordinator will reach out before the program." | Edit Travel |
| Only info saved | "Travel info saved. Please also complete your travel plan." | Fill Travel Plan |

##### Goodies — Actions

| Action | Condition |
| --- | --- |
| Save Preferences | Always |
| Edit | Before cutoff date |

##### Goodies — Success Screen

"Your merchandise preferences have been saved!"

> Registration is marked COMPLETE when all active stages are done.

---

### 4. Dynamic Communication Templates

Currently, communication templates are hardcoded per program type. With the CUSTOM type, templates must be resolved based on program flags at the time of sending — not at setup time.

Each communication event (registration submitted, approved, payment done, travel submitted, cancelled) maps to a set of templates. Whether a template is sent depends on which flags are active.

| Event | Template sent | Condition |
| --- | --- | --- |
| Registration submitted | Registration confirmed — seeker email + WhatsApp | Always |
| Registration submitted | Notify RM | If RM is assigned |
| Approval approved | Blessed email + WhatsApp to seeker | `requiresApproval = true`, `requiresPayment = true` |
| Approval approved — free seat | Blessed no-payment email to seeker | `requiresApproval = true`, `requiresPayment = false` |
| Payment completed | Payment acknowledgement to seeker | `requiresPayment = true` |
| Travel submitted | Travel confirmation to seeker + coordinator | `isTravelInvolved = true` |
| Registration cancelled | Cancellation email to seeker, RM, finance | Always |
| Put on hold | Hold notification to seeker | `requiresApproval = true` |

When a program is created from the CUSTOM template, the system seeds only the templates relevant to its active flags. If `requiresApproval = false`, approval-related templates are not seeded at all.

Admins can then customise the subject and body of each template per program without affecting other programs.

---

## What Stays the Same

- Existing HDB / MSD / ENT programs continue on their current workflows until migrated
- No change to registrations, approvals, or payments processing
- All existing APIs remain unchanged
