> ## 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.

# Resource Management

> Upload and manage resources, documents, and media for members

Manage your organization's resource library including documents, videos, and other media with access control and categorization.

## Capabilities

| Action            | ROLE\_CLIENT\_ADMIN | ROLE\_CLIENT\_USER |
| ----------------- | ------------------- | ------------------ |
| View resources    | ✅                   | ✅                  |
| Upload resources  | ✅                   | ❌                  |
| Edit resources    | ✅                   | ❌                  |
| Delete resources  | ✅                   | ❌                  |
| Manage categories | ✅                   | ❌                  |

## Features

### Resource Types

* **Documents** - PDF, Word, Excel, PowerPoint
* **Videos** - MP4, WebM (with streaming)
* **Audio** - MP3, WAV (podcasts)
* **Images** - PNG, JPG, SVG

#### Acceptance Criteria

##### Frontend

* [ ] Resource grid/list view with filtering
* [ ] Price setting for paid resources
* [ ] Resource preview
* [ ] Progress indicator for large files
* [ ] Category and tag management
* [ ] Bulk operations

##### 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

* [ ] File size limit: 500MB per resource
* [ ] Resources can be versioned (replace file)
* [ ] Deletion removes file from storage
* [ ] Stats tracked: views, downloads, unique users

##### Error Handling

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

### Access Levels

| Level           | Description                                        |
| --------------- | -------------------------------------------------- |
| Public          | Available to all visitors                          |
| Partially Gated | Preview available, full access requires membership |
| Fully Gated     | Members only                                       |
| Paid            | Requires purchase                                  |

#### Acceptance Criteria

##### Frontend

* [ ] Access level configuration

##### 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

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

##### Error Handling

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

### Upload Resource

<Steps>
  <Step title="Upload File">
    Drag and drop or select file to upload (max 500MB)
  </Step>

  <Step title="Add Details">
    * Resource name
    * Description/excerpt
    * Featured image
  </Step>

  <Step title="Categorize">
    * Select categories
    * Add tags
  </Step>

  <Step title="Set Access">
    * Choose access level
    * Set price (if paid)
  </Step>

  <Step title="Publish">
    Save as draft or publish immediately
  </Step>
</Steps>

#### Acceptance Criteria

##### Frontend

* [ ] Drag-and-drop file upload

##### 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

* [ ] Supported formats validated on upload

##### Error Handling

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

## Implementation Contracts

### Backend (API)

```
GET    /api/resources                        # List resources
POST   /api/resources                        # Upload resource
GET    /api/resources/{id}                   # Get resource details
PUT    /api/resources/{id}                   # Update resource
DELETE /api/resources/{id}                   # Delete resource

GET    /api/resources/categories             # List categories
POST   /api/resources/categories             # Create category

GET    /api/resources/{id}/download          # Download file
GET    /api/resources/{id}/stats             # View/download stats
```

### Category Management

Resource categories are managed by the client/association and used for navigation and filtering in the member Resource Library.

Common workflows:

* Create category (name, description, optional icon)
* Edit category
* Reorder categories
* Archive category (hide from member UI but keep historical associations)

#### Acceptance Criteria

##### Frontend

* [ ] Category CRUD UI exists in the Resource Management area.
* [ ] Categories can be reordered.

##### Backend / API

* [ ] Categories are persisted and can be assigned to resources.

##### Permissions

* [ ] Only `ROLE_CLIENT_ADMIN` can manage categories.

##### Business Rules

* [ ] Category names are unique per client.
* [ ] Archiving a category does not delete resources.

##### Error Handling

* [ ] Validation errors are shown inline when creating/updating categories.

### Search

Resource search should support:

* Keyword search across title and description (and optionally file text for PDFs if indexed)
* Filtering by category, type, access level, and publish date

#### Acceptance Criteria

##### Frontend

* [ ] Search input and filter controls exist on resource listing screens.

##### Backend / API

* [ ] Search endpoint supports keyword + filters.

##### Permissions

* [ ] Results are filtered by access control (public/member/premium/paid).

##### Business Rules

* [ ] Search respects draft/published visibility.

##### Error Handling

* [ ] If search indexing is unavailable, the UI shows a clear fallback/error.

## AI-Powered Resource Features

### Phase 2: Resource Chat Interface

A conversational AI interface that allows members to find correct information from the resource library through natural language queries.

<Steps>
  <Step title="Ask Questions">
    Members type questions in natural language (e.g., "What are the CPD requirements for renewal?")
  </Step>

  <Step title="AI Search & Analysis">
    System searches across all accessible resources and analyzes content to find relevant answers
  </Step>

  <Step title="Contextual Response">
    AI provides a synthesized answer with citations to specific resources and page numbers
  </Step>

  <Step title="Follow-up Questions">
    Members can ask follow-up questions to drill deeper into topics
  </Step>
</Steps>

#### Chat Interface Features

* **Natural Language Queries**: Ask questions in plain English
* **Source Citations**: Every answer references the source documents
* **Direct Links**: Click to open the exact resource/page referenced
* **Conversation History**: Previous questions and answers preserved in session
* **Suggested Questions**: AI suggests related questions based on context

#### Acceptance Criteria (Phase 2)

##### Frontend

* [ ] Chat interface panel accessible from resource library
* [ ] Message input with send button
* [ ] Response display with source citations
* [ ] Clickable links to referenced resources
* [ ] Conversation history within session
* [ ] Loading indicator during AI processing

##### Backend / API

* [ ] Resource content indexing for AI search
* [ ] Natural language query processing
* [ ] Source citation extraction and linking
* [ ] Conversation context management

##### Permissions

* [ ] Chat interface respects resource access levels
* [ ] Members only receive answers from resources they can access

##### Business Rules

* [ ] Responses cite specific resources and page numbers where applicable
* [ ] System indicates confidence level in answers
* [ ] Fallback to search results if AI cannot provide a direct answer

##### Error Handling

* [ ] If AI service unavailable, redirect to standard search
* [ ] Clear messaging when no relevant resources found

### Phase 3: NotebookLM Functionality

Advanced AI-powered content transformation that converts resources into alternative formats for enhanced learning and engagement.

<CardGroup cols={2}>
  <Card title="AI Podcasts" icon="podcast">
    Transform documents into engaging audio discussions
  </Card>

  <Card title="Infographics" icon="chart-pie">
    Generate visual summaries of complex content
  </Card>
</CardGroup>

#### AI Podcast Generation

Convert documents and resources into podcast-style audio content:

* **Two-Voice Discussions**: AI-generated conversational format with two speakers
* **Topic Deep Dives**: Extended analysis of key concepts
* **Summary Episodes**: Quick overview episodes for busy members
* **Custom Topics**: Generate podcasts from selected resources

#### Infographic Generation

Transform text-heavy resources into visual formats:

* **Key Takeaways**: Visual summary of main points
* **Process Diagrams**: Step-by-step visual guides
* **Statistics Visualization**: Charts and graphs from data in documents
* **Comparison Charts**: Side-by-side visual comparisons

#### Acceptance Criteria (Phase 3)

##### Frontend

* [ ] "Generate Podcast" button on eligible resources
* [ ] "Create Infographic" option for document resources
* [ ] Audio player for generated podcasts
* [ ] Infographic viewer with download options
* [ ] Generation progress indicator
* [ ] Gallery view of generated content

##### Backend / API

* [ ] Text-to-speech AI service integration
* [ ] Podcast script generation from document content
* [ ] Infographic layout and design generation
* [ ] Generated content storage and delivery

##### Permissions

* [ ] Only `ROLE_CLIENT_ADMIN` can trigger content generation
* [ ] Generated content inherits access level from source resource

##### Business Rules

* [ ] Generation limited to documents under 50 pages (configurable)
* [ ] Generated content linked to source resource
* [ ] Admin can edit/regenerate content before publishing
* [ ] Track engagement metrics for generated content

##### Error Handling

* [ ] Long documents show estimated processing time
* [ ] Failed generation attempts allow retry
* [ ] Fallback messaging if AI services unavailable

### Implementation Contracts (AI Resources)

```
# Phase 2 - Chat Interface
POST   /api/resources/chat                   # Send chat query
GET    /api/resources/chat/history           # Get conversation history
POST   /api/resources/chat/feedback          # Submit answer feedback

# Phase 3 - NotebookLM Features
POST   /api/resources/{id}/generate-podcast  # Generate podcast from resource
GET    /api/resources/{id}/podcast           # Get generated podcast
POST   /api/resources/{id}/generate-infographic  # Generate infographic
GET    /api/resources/{id}/infographic       # Get generated infographic
GET    /api/resources/{id}/generated-content # List all generated content
```

**Chat Request:**

```json theme={null}
{
  "query": "What are the CPD requirements for membership renewal?",
  "conversationId": "optional-session-id",
  "resourceScope": ["category-id"]  // Optional: limit search scope
}
```

**Chat Response:**

```json theme={null}
{
  "answer": "According to the membership guidelines...",
  "sources": [
    {
      "resourceId": "resource-uuid",
      "resourceName": "Membership Handbook 2025",
      "pageNumber": 12,
      "excerpt": "Members must complete 20 CPD points..."
    }
  ],
  "suggestedQuestions": [
    "How do I log CPD points?",
    "What activities count toward CPD?"
  ],
  "confidence": 0.92
}
```
