# Plan: User Society Projects with Sponsorship System

## Overview
Create a "Society Projects" feature where users can share their projects (video, PDF, text) from their dashboard. Projects go through admin approval before being published. Factories, sponsors, and other users can view projects and become sponsors - their logos appear on the project's society page.

## Features

### 1. User Project Submission
From user dashboard, users can submit:
- **Video** - Upload or link to project video
- **PDF** - Upload project documents/reports
- **Text** - Project description, details, markdown content
- **NotebookLM Data** - Share study data, AI-generated content

### 2. Admin Approval System
- Super admin reviews submitted projects
- Approve/reject with feedback
- Edit project details before publishing
- Set project visibility (public, members only, etc.)

### 3. Project Viewing
- **Users** - Browse and view approved projects
- **Factories** (المصانع) - View projects for partnership opportunities
- **Sponsors/Investors** (المستثمرين) - View projects to sponsor

### 4. Sponsorship System
- Sponsors can request to sponsor a project
- Admin approves sponsorship
- Sponsor's logo appears on project page
- Multiple sponsors per project
- Sponsorship tiers (Platinum, Gold, Silver)

### 5. Society Page
Each published project has a dedicated page showing:
- Project title, description, media
- User/author info
- All sponsors with logos
- Comments/engagement
- Share functionality

## Database Schema

### Tables to Create

#### 1. society_projects
```sql
id SERIAL PRIMARY KEY
user_id INTEGER REFERENCES users(id)
title VARCHAR(500) NOT NULL
title_ar VARCHAR(500)
slug VARCHAR(255) UNIQUE NOT NULL
description TEXT
description_ar TEXT
content TEXT  -- Markdown content
video_url VARCHAR(500)
video_path VARCHAR(500)
pdf_path VARCHAR(500)
cover_image VARCHAR(500)
notebooklm_data JSONB  -- Shared AI content/study data
status VARCHAR(20) DEFAULT 'pending'  -- pending, approved, rejected, published
is_featured BOOLEAN DEFAULT FALSE
view_count INTEGER DEFAULT 0
sponsorship_target INTEGER  -- Target sponsorship amount
currency VARCHAR(10) DEFAULT 'SAR'
created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW()
published_at TIMESTAMP
```

#### 2. society_project_sponsors
```sql
id SERIAL PRIMARY KEY
project_id INTEGER REFERENCES society_projects(id)
sponsor_id INTEGER REFERENCES users(id)  -- User or Factory user
sponsor_type VARCHAR(50)  -- factory, investor, individual
tier VARCHAR(20) DEFAULT 'bronze'  -- platinum, gold, silver, bronze
logo_url VARCHAR(500)
website_url VARCHAR(500)
status VARCHAR(20) DEFAULT 'pending'  -- pending, approved, rejected
monthly_contribution DECIMAL(10,2)
notes TEXT
created_at TIMESTAMP DEFAULT NOW()
approved_at TIMESTAMP
```

#### 3. society_project_likes
```sql
id SERIAL PRIMARY KEY
project_id INTEGER REFERENCES society_projects(id)
user_id INTEGER REFERENCES users.id)
created_at TIMESTAMP DEFAULT NOW()
UNIQUE(project_id, user_id)
```

#### 4. society_project_comments
```sql
id SERIAL PRIMARY KEY
project_id INTEGER REFERENCES society_projects(id)
user_id INTEGER REFERENCES users(id)
parent_id INTEGER REFERENCES society_project_comments(id)
content TEXT NOT NULL
created_at TIMESTAMP DEFAULT NOW()
updated_at TIMESTAMP DEFAULT NOW()
is_deleted BOOLEAN DEFAULT FALSE
```

## Implementation Plan

### Phase 1: Database & Models
1. Create migration for all tables
2. Create models:
   - `SocietyProject`
   - `SocietyProjectSponsor`
   - `SocietyProjectLike`
   - `SocietyProjectComment`

### Phase 2: User Dashboard - Project Submission
1. Create `/society/submit` route and template
2. Form with:
   - Title (Arabic/English)
   - Description fields
   - Video upload/link
   - PDF upload
   - Content editor (markdown)
   - NotebookLM data import
3. Handle file uploads to CDN/storage

### Phase 3: Admin Approval System
1. `/admin/society-projects` - List pending projects
2. `/admin/society-projects/<id>/review` - Review & approve/reject
3. `/admin/society-projects/<id>/edit` - Edit before publishing
4. Batch operations

### Phase 4: Public Project Viewing
1. `/society` - Browse all published projects
2. `/society/<slug>` - Individual project page
3. Filter by category, tags, date
4. Search functionality

### Phase 5: Sponsorship System
1. Sponsor request form on project page
2. `/society/<slug>/sponsor-request` - Submit sponsorship
3. Admin approves sponsorships
4. Display sponsor logos on project page

### Phase 6: Engagement Features
1. Like/bookmark projects
2. Comments system
3. Share to social media
4. Embed functionality

## Files to Create

### Models
- `app/models/society.py` - All society-related models

### Routes
- `app/routes/society.py` - Public viewing, submission
- Update `app/routes/admin.py` - Admin approval

### Templates
- `app/templates/society/index.html` - Browse projects
- `app/templates/society/detail.html` - Project page
- `app/templates/society/submit.html` - Submission form
- `app/templates/society/my_projects.html` - User's projects
- `app/templates/admin/society_projects.html` - Admin approval list
- `app/templates/admin/society_review.html` - Admin review page

### Migrations
- `migrations/versions/006_add_society_projects.py`

## File Structure
```
app/
├── models/
│   └── society.py          [NEW]
├── routes/
│   ├── society.py          [NEW]
│   └── admin.py            [UPDATE]
├── templates/
│   ├── society/
│   │   ├── index.html      [NEW]
│   │   ├── detail.html     [NEW]
│   │   ├── submit.html     [NEW]
│   │   └── my_projects.html [NEW]
│   └── admin/
│       ├── society_projects.html [NEW]
│       └── society_review.html   [NEW]
└── static/
    └── css/society.css     [NEW - optional]
```

## Key Features by User Type

### Regular Users
- Submit projects
- View all projects
- Like/comment
- Share projects
- See their own projects

### Factories (مصانع)
- All user features
- Request sponsorship
- Browse for partnership opportunities

### Investors (مستثمرين)
- All user features
- Sponsor projects
- View sponsorship opportunities
- Logo display on sponsored projects

### Super Admin
- Approve/reject projects
- Approve/reject sponsorships
- Edit all projects
- Manage sponsors
- View analytics

## Sponsorship Tiers & Display

| Tier | Min Contribution | Logo Size | Features |
|------|------------------|-----------|----------|
| Platinum | 50,000+ SAR | Large (120px) | Top placement, featured |
| Gold | 20,000+ SAR | Medium (90px) | Below platinum |
| Silver | 10,000+ SAR | Small (60px) | Below gold |
| Bronze | 5,000+ SAR | Mini (40px) | Footer placement |

## NotebookLM Integration

Users can share their study content:
- Import from existing reports
- Include AI-generated insights
- Share mind maps, flashcards
- Export to society project

## Security & Permissions

- Only logged-in users can submit
- Email verification required
- File size limits
- Content moderation
- Rate limiting on submissions

## Future Enhancements

- Project categories/tags
- Advanced search filters
- Sponsorship analytics dashboard
- Project collaboration features
- Notification system for new projects
- Sponsorship expiration/renewal

## Implementation Steps

1. Create database migration
2. Create models
3. Create submission form
4. Create admin approval interface
5. Create public project browsing
6. Create individual project pages
7. Implement sponsorship system
8. Add engagement features
9. Test all user flows
10. Deploy
