# Google Meet Configuration Module

## Overview

This Laravel module provides comprehensive Google Meet integration for the SSHIA system, It allows Super Managers to configure OAuth2 credentials, authenticate with Google, and provides a reusable service for creating Google Meet video conferences.

## Module Structure

```
google-meet-module/
├── database/
│   ├── migrations/
│   │   ├── 2026_01_15_000000_create_google_meet_configurations_table.php
│   │   └── 2026_01_15_000001_create_meeting_logs_table.php
│   └── seeders/
│       └── GoogleMeetPermissionSeeder.php
├── app/
│   ├── Models/
│   │   ├── GoogleMeetConfiguration.php
│   │   └── MeetingLog.php
│   ├── Services/
│   │   ├── ConfigurationService.php
│   │   ├── OAuth2Service.php
│   │   ├── MeetProvider.php
│   │   └── MeetService.php
│   └── Http/
│       ├── Controllers/
│       │   └── GoogleMeetController.php
│       └── Requests/
│           └── GoogleMeetConfigurationRequest.php
├── routes/
│   └── web.php
├── resources/
│   └── views/
│       └── config/
│           └── google-meet/
│               ├── index.blade.php
│               ├── form.blade.php
│               ├── test.blade.php
│               ├── logs.blade.php
│               └── documentation.blade.php
├── DEPENDENCY_REQUIREMENTS.md
└── README.md
```

## Features

- **OAuth2 Authentication Flow** - Complete Google OAuth2 authentication with automatic token refresh
- **Secure Credential Storage** - All sensitive data encrypted at rest using Laravel's encryption
- **Role-Based Access Control** - Only Super Manager role can access configuration
- **Activity Logging** - Comprehensive logging of all API interactions
- **Connection Testing** - Test API connectivity before production use
- **Reusable MeetService** - Simple API for other modules to create meetings
- **Full Documentation** - Built-in integration guide for developers

## Installation

### 1. Copy Files

Copy the module files to your Laravel application:

```bash
# Copy migrations
cp -r database/migrations/* /path/to/your/app/database/migrations/

# Copy seeders
cp database/seeders/GoogleMeetPermissionSeeder.php /path/to/your/app/database/seeders/

# Copy models
cp -r app/Models/* /path/to/your/app/Models/

# Copy services
cp -r app/Services/* /path/to/your/app/Services/

# Copy controllers
cp app/Http/Controllers/GoogleMeetController.php /path/to/your/app/Http/Controllers/

# Copy requests (if using form requests)
cp app/Http/Requests/GoogleMeetConfigurationRequest.php /path/to/your/app/Http/Requests/

# Copy routes (merge with your existing routes)
# Note: Merge the routes with your existing web.php

# Copy views
cp -r resources/views/config/google-meet/* /path/to/your/app/resources/views/config/google-meet/
```

### 2. Install Dependencies

```bash
composer require spatie/laravel-permission:^6.24
composer require guzzlehttp/guzzle:^7.8
```

### 3. Run Migrations

```bash
php artisan migrate
```

### 4. Seed Permissions

```bash
php artisan db:seed --class=GoogleMeetPermissionSeeder
```

### 5. Configure Environment

Add to your `.env`:

```env
GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=your-client-secret
GOOGLE_REDIRECT_URI=https://your-domain.com/config/google-meet/callback
```

### 6. Clear Cache

```bash
php artisan cache:clear
php artisan config:clear
```

## Usage

### Creating a Meeting

```php
use App\Services\MeetService;

$meetService = app(MeetService::class);

$result = $meetService->createMeeting(
    summary: 'Team Meeting',
    startTime: '2024-01-15T10:00:00',
    endTime: '2024-01-15T11:00:00',
    attendees: ['user@example.com'],
    description: 'Weekly team sync'
);

if ($result['success']) {
    echo $result['meeting_link'];
}
```

### Checking Configuration Status

```php
use App\Services\ConfigurationService;

$configService = app(ConfigurationService::class);

if ($configService->isConfigured() && $configService->isAuthenticated()) {
    // Ready to create meetings
}
```

## Routes

| Route | Method | Description |
|------|-------|-------------|
| `/config/google-meet` | GET | Dashboard |
| `/config/google-meet/create` | GET | Create configuration form |
| `/config/google-meet` | POST | Store configuration |
| `/config/google-meet/edit` | GET | Edit configuration form |
| `/config/google-meet` | PUT | Update configuration |
| `/config/google-meet/authenticate` | GET | Start OAuth flow |
| `/config/google-meet/callback` | GET | OAuth callback |
| `/config/google-meet/test` | GET/POST | Test connection |
| `/config/google-meet/test-meeting` | POST | Create test meeting |
| `/config/google-meet/logs` | GET | View activity logs |
| `/config/google-meet/documentation` | GET | Integration guide |
| `/config/google-meet` | DELETE | Delete configuration |

## Permissions

| Permission | Description |
|-----------|-------------|
| `view google meet configuration` | View configuration dashboard |
| `create google meet configuration` | Create new configuration |
| `edit google meet configuration` | Edit existing configuration |
| `delete google meet configuration` | Delete configuration |
| `test google meet connection` | Test API connection |
| `view google meet logs` | View activity logs |
| `manage google meet settings` | Manage settings |
| `create google meet meetings` | Create Google Meet meetings |

## Security

- All OAuth credentials are encrypted using Laravel's encryption
- Access restricted to Super Manager role
- CSRF protection on OAuth state parameter
- XSS prevention with input sanitization
- Tokens never exposed in logs or responses

## Support

For detailed documentation, see `DEPENDENCY_REQUIREMENTS.md` or visit the documentation page in the application.

## License

This module is part of the SSHIA Laravel System.
