> ## Documentation Index
> Fetch the complete documentation index at: https://memberpulseptyltd.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Membership Management

> Create, edit, and manage member accounts with full CRUD operations

Manage all member accounts in your organization with comprehensive CRUD operations, bulk actions, and advanced filtering.

## Capabilities

| Action          | ROLE\_CLIENT\_ADMIN | ROLE\_CLIENT\_USER |
| --------------- | ------------------- | ------------------ |
| View members    | ✅                   | ✅                  |
| Create members  | ✅                   | ❌                  |
| Edit members    | ✅                   | ❌                  |
| Delete members  | ✅                   | ❌                  |
| Bulk operations | ✅                   | ❌                  |
| Export data     | ✅                   | ✅                  |

## Features

### Member List View

<Steps>
  <Step title="Access Member List">
    Navigate to **Members** in the sidebar to view all members in a paginated data table.
  </Step>

  <Step title="Search & Filter">
    Use the search bar to find members by name or email. Apply filters for:

    * Membership type
    * Status (active, inactive, suspended)
    * Join date range
    * Membership expiry
  </Step>

  <Step title="Customize Columns">
    Click the column selector to show/hide fields in the table view.
  </Step>
</Steps>

#### Acceptance Criteria

##### Frontend

* [ ] Members list displays in data table with TanStack Table
* [ ] Search bar filters members by name, email
* [ ] Filter dropdowns for membership type, status
* [ ] Pagination controls (30 members per page)
* [ ] Add member button opens form modal/page
* [ ] Edit button opens edit form with current data
* [ ] Delete button shows confirmation dialog
* [ ] Bulk actions: export, email, status change
* [ ] Loading states during API calls
* [ ] Success/error toasts for actions

##### Backend / API

* [ ] `?membershipType=` - Filter by type
* [ ] `?search=` - Search by name/email
* [ ] `?status=` - Filter by status
* [ ] `?page=` - Pagination
* [ ] `?itemsPerPage=` - Results per page (default: 30)

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] `ROLE_CLIENT_USER` role can view members (read-only)
* [ ] Cannot delete member with active membership
* [ ] Email must be unique across organization
* [ ] All actions logged to audit trail

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Create New Member

#### Acceptance Criteria

##### Frontend

* [ ] UI supports the workflows described in this feature.

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Only `ROLE_CLIENT_ADMIN` role can create/edit/delete members

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

#### UI Spec (from supplied spreadsheet)

The following field inventory is sourced from `workspace/sources/entity-registry.csv` ("Members" / membership-related fields).

> This is a UI/requirements inventory (not the ERD). Some fields are system-generated or may be configured as optional during implementation.

##### Create/Edit Member – Field Inventory

| Field          | Input Type | Required     | Notes                                                        |
| -------------- | ---------- | ------------ | ------------------------------------------------------------ |
| First Name     | Text       | Required     | model: `firstName`                                           |
| Last Name      | Text       | Required     | model: `lastName`                                            |
| Date of Birth  | Date       | Required     | model: `dateOfBirth`                                         |
| Email          | Email      | Required     | model: `user.email` (unique per client)                      |
| Contact Number | Number     | Required     | model: `contactNumber`                                       |
| Mobile         | Number     | Required     | model: `mobile`                                              |
| Company        | Text       | Required     | model: `company`                                             |
| Position       | Text       | Required     | model: `position`                                            |
| Gender         | Select     | Required     | Options: Male, Female, Other, Not Specified; model: `gender` |
| Address        | Text       | Required     | model: `address`                                             |
| City           | Text       | Required     | model: `city`                                                |
| Postcode       | Number     | Required     | model: `postcode`                                            |
| State          | Select     | Required     | model: `state`                                               |
| Country        | Select     | Required     | model: `country`                                             |
| LinkedIn URL   | URL        | Not Required | model: `linkedinUrl`                                         |
| Website URL    | URL        | Not Required | model: `websiteUrl`                                          |

##### Membership – Field Inventory

| Field                        | Input Type | Required     | Notes                                                                          |
| ---------------------------- | ---------- | ------------ | ------------------------------------------------------------------------------ |
| Membership ID                | Number     | Required     | Automatically Generated; model: `membership` (rel: OneToMany `UserMembership`) |
| Membership Plan              | Selector   | Required     | Pull through a list of membership plan entities                                |
| Membership Registration Date | Date       | Required     | Start date for the membership period                                           |
| Membership Expiry Date       | Date       | Required     | Grace period may be applied automatically based on plan settings               |
| Membership Status            | Selector   | Required     | Set from plan defaults but can be overridden by admins                         |
| Group Membership Assignment  | Selector   | Not Required | Assign member to a corporate/group plan (if applicable)                        |

#### Data Model Cross‑Reference (Entities)

* Member profile + personal fields: [`User / Member`](/entities/core/user-member)
* Plan configuration (pricing, grace period, CPD requirements): [`Membership Plan`](/entities/core/membership-plan)
* Membership periods (per member, per plan): `UserMembership` (referenced throughout Entities)
* Corporate/group memberships: [`Group / Corporate Membership`](/entities/core/group-corporate-membership)

### Edit Member

All member fields can be edited except:

* Email address (contact support to change)
* Member ID
* Created date

#### Acceptance Criteria

##### Frontend

* [ ] Edit Member workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Edit Member as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Delete Member

<Warning>
  Soft delete is used - member data is retained for audit purposes but the account is deactivated. Members with active memberships cannot be deleted until the membership expires or is cancelled.
</Warning>

#### Acceptance Criteria

##### Frontend

* [ ] Delete Member workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Delete Member as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## Bulk Operations

### Bulk Export

Export members to CSV or Excel with selected fields:

1. Select members using checkboxes (or select all)
2. Click **Export** button
3. Choose format (CSV, Excel)
4. Select fields to include
5. Download generated file

#### Acceptance Criteria

##### Frontend

* [ ] Bulk Export workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Bulk Export as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Bulk Update

Update multiple members at once:

1. Select members using checkboxes
2. Click **Bulk Actions** → **Update**
3. Choose field to update (e.g., membership type, status)
4. Enter new value
5. Confirm changes

#### Acceptance Criteria

##### Frontend

* [ ] Bulk Update workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Bulk Update as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Import Members

Import members from CSV file:

1. Click **Import** button
2. Download template CSV
3. Fill in member data
4. Upload completed CSV
5. Review validation results
6. Confirm import

#### Acceptance Criteria

##### Frontend

* [ ] Import Members workflow is implemented in the UI as described.

##### Backend / API

* [ ] Backend behavior supports Import Members as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## Implementation Contracts

### Backend (API)

```
GET    /api/members                      # List all members (paginated)
POST   /api/members                      # Create new member
GET    /api/members/{id}                 # Get member details
PUT    /api/members/{id}                 # Update member
DELETE /api/members/{id}                 # Soft delete member
POST   /api/members/bulk-export          # Export members
POST   /api/members/bulk-update          # Bulk update
POST   /api/members/import               # Import from file
POST   /api/members/import/validate      # Validate import data
```

**Query Parameters:**

### Error Handling

| Error             | HTTP Status | Message                                       |
| ----------------- | ----------- | --------------------------------------------- |
| Duplicate email   | 409         | "A member with this email already exists"     |
| Not found         | 404         | "Member not found"                            |
| Unauthorized      | 403         | "Access denied"                               |
| Validation error  | 400         | Field-specific error messages                 |
| Active membership | 400         | "Cannot delete member with active membership" |

## AI-Powered Engagement

### Login Activity Tracking

The system monitors member login activity and identifies inactive members based on configurable thresholds.

<Steps>
  <Step title="Configure Inactivity Threshold">
    Set the number of days of inactivity that triggers a re-engagement email (e.g., 30, 60, or 90 days)
  </Step>

  <Step title="Monitor Login Dates">
    System automatically tracks and stores last login dates for all members
  </Step>

  <Step title="Trigger Re-engagement">
    When a member exceeds the inactivity threshold, the system queues a personalized re-engagement email
  </Step>
</Steps>

### AI Re-engagement Emails

When members exceed the inactivity threshold, the system sends personalized re-engagement emails containing:

<Tabs>
  <Tab title="Content Recommendations">
    AI-curated recommendations based on member interests:

    * **Community Articles**: Relevant articles from the community feed
    * **Polls**: Active polls matching the member's interest categories
    * **Discussion Threads**: Trending or popular discussions they might enjoy
  </Tab>

  <Tab title="Personalized Suggestions">
    Tailored recommendations based on member profile and history:

    * **Upcoming Events**: Events matching their interests or past attendance
    * **Resources**: Documents, videos, or materials relevant to their profession
    * **CPD Opportunities**: Learning content to maintain certifications
  </Tab>
</Tabs>

#### Acceptance Criteria

##### Frontend

* [ ] Inactivity threshold configuration in settings
* [ ] Dashboard showing inactive member counts by threshold
* [ ] Preview of re-engagement email template
* [ ] Manual trigger option for sending re-engagement emails

##### Backend / API

* [ ] Track and store last login date for all members
* [ ] Scheduled job to identify inactive members
* [ ] AI service integration for generating personalized recommendations
* [ ] Email queue for re-engagement campaigns

##### Permissions

* [ ] Only `ROLE_CLIENT_ADMIN` can configure inactivity thresholds and email templates

##### Business Rules

* [ ] Re-engagement emails sent maximum once per configured period (e.g., once every 30 days)
* [ ] Members can opt-out of re-engagement emails
* [ ] Email content respects member interest category preferences
* [ ] Recommendations exclude content the member has already viewed

##### Error Handling

* [ ] If AI recommendation service unavailable, send email with generic content
* [ ] Failed email deliveries logged and retried

### Implementation Contracts (AI Engagement)

```
GET    /api/members/inactive                 # List inactive members
POST   /api/members/re-engage                # Trigger re-engagement emails
GET    /api/members/{id}/recommendations     # Get AI recommendations for member
PUT    /api/settings/engagement              # Update engagement settings
```
