---
name: "L'Oréal OMG Assistant Global"
client: L'Oréal
status: active
server: local
tech: [PHP, JavaScript, Box API, Azure AD SSO, Mailgun, Make.com Webhooks]
local_path: /Users/ai_leed/Documents/Projects/Oliver/loreal-global-kickoff
deploy: PHP server
url: 
tags: [loreal, box, campaign, global-to-local, php, make]
created: 2026-04-14
---

## Overview
L'Oréal OMG Assistant Global is a PHP web application for managing L'Oréal campaign assets and regional distribution. It provides two primary tools: Master Global Asset Submission (validating and submitting Box folder assets with metadata) and Global to Local CSV Transformation (converting global campaign data into 16 regional market-specific CSVs). The application serves L'Oréal's internal teams to streamline asset management workflows with comprehensive audit logging, SSO authentication, and email notifications.

## Tech Stack
- **Frontend:** HTML5, CSS3, JavaScript (vanilla), Montserrat font
- **Backend:** PHP 7.4+, Composer
- **APIs & Integrations:** Box API (JWT), Azure AD SSO, Make.com webhooks, Mailgun SMTP, OMG API
- **Database:** JSON file-based activity logs (no SQL DB required)
- **Infrastructure:** Local development (MAMP) or web server (Apache/Nginx)
- **Key libraries:** Box PHP SDK, MSAL (Microsoft Authentication), curl for API requests, ZIP file generation

## Architecture
The application follows a modular, request-driven architecture with clear separation of concerns:

```
┌─────────────────────────────────────────────────────────────┐
│                    Web Interface (HTML/CSS/JS)              │
├─────────────────────────────────────────────────────────────┤
│  Master Global         Global to Local          Activity     │
│  Asset Submission      CSV Transform            Logs/Viewer  │
└──────────────┬──────────────────┬──────────────────┬─────────┘
               │                  │                  │
        ┌──────▼──────────────────▼──────────────────▼──────┐
        │         PHP Application Layer (index.php)          │
        │  • Route handling & session management              │
        │  • SSO/RBAC authentication & user tracking          │
        │  • Activity logging to JSON                         │
        └──────┬──────────────────┬──────────────────┬───────┘
               │                  │                  │
      ┌────────▼────────┐  ┌──────▼──────┐  ┌──────▼──────┐
      │   Box API       │  │  Make.com   │  │  Mailgun    │
      │   (folders,     │  │  Webhooks   │  │  (email)    │
      │   validation)   │  │  (submit)   │  │             │
      └─────────────────┘  └─────────────┘  └─────────────┘
               │
      ┌────────▼────────────────────┐
      │  Azure AD SSO / OMG API      │
      │  (auth, business unit lookup)│
      └─────────────────────────────┘

Data Storage:
  • logs/activity_log.json — Audit trail of all user actions
  • config.php — Application configuration
  • roles.json — User RBAC assignments (admin/user)
```

**Key Design Decisions:**
- **No SQL Database**: Uses JSON file logging for simplicity and portability
- **Two-Mode Auth**: SSO disabled in local dev (hardcoded user), enabled in production (Azure AD)
- **Stateless Processing**: CSV transformation tracked via multi-stage progress with visual feedback
- **Webhook-Based Submission**: Master asset submission delegates to Make.com for external processing
- **Comprehensive Audit Trail**: Every action (login, submission, error) logged with timestamp, IP, user agent
- **16-Market Localization**: Hard-coded ISO codes ensure consistent regional distribution

## Dev Commands
```bash
# Install dependencies
composer install

# Local development server (MAMP or built-in)
# Access via browser: http://localhost:8888 (MAMP) or http://localhost:8000 (built-in PHP)
php -S localhost:8000

# View git history
git log --oneline -20

# Run tests (if available)
# No test command documented; manual testing via web interface

# Check server setup
php server-setup.php

# View environment diagnostics
php server-diagnostics.php
```

## Deployment
- **Server:** Local development (MAMP) or custom web server
- **Deploy:** Manual file sync or git pull on target server
- **URL:** Not yet deployed; development only
- **Port:** 8000 (PHP built-in) or 8888 (MAMP)
- **Service:** None (stateless web application)
- **Local path:** /Users/ai_leed/Documents/Projects/Oliver/loreal-global-kickoff

## Environment Variables
All configuration is managed in `config.php`. Key variables:

- `sso.enabled` — Toggle Azure AD SSO (false for local dev, true for production)
- `sso.local_user.email` — Hardcoded email when SSO disabled (local dev mode)
- `box.client_id` / `box.client_secret` / `box.enterprise_id` — Box API JWT credentials
- `azure_ad.client_id` / `azure_ad.client_secret` / `azure_ad.tenant_id` — Azure AD SSO credentials
- `make_webhook_url` — Make.com webhook endpoint for asset submissions
- `mailgun.domain` / `mailgun.api_key` — Mailgun SMTP credentials for email notifications
- `omg_api.enabled` — Toggle OMG API lookup for business unit (optional)
- `omg_api.api_key` — OMG API authentication key (X-API-Key header)

## Activity Logging & Audit Trail
All user actions are logged to `logs/activity_log.json` with:
- Timestamp (ISO 8601)
- User email
- Action type (login, asset_submission, csv_transform, error, etc.)
- Status (success, error)
- IP address & user agent
- Action-specific data (folder ID, file count, error details, etc.)

The Activity Logs viewer (`/activity-logs`) displays:
- Filterable log entries by action type and user
- Statistics dashboard (total actions, success rates, error count, unique users)
- Export to CSV functionality

## Endpoints
- **GET `/`** — Main application (route-driven via `$_GET['page']`)
- **GET `/?page=master-submission`** — Master Global Asset Submission form
- **GET `/?page=csv-transform`** — Global to Local CSV transformation tool
- **GET `/?page=activity-logs`** — Activity logs viewer & dashboard
- **POST `/api/get-box-folder`** — Fetch Box folder structure (AJAX)
- **POST `/api/process-csv`** — Process CSV transformation (AJAX, multi-stage)
- **POST `/api/submit-assets`** — Submit asset data to Make.com webhook
- **POST `/api/login`** — Azure AD SSO login (if enabled)

## Known Issues
- **OMG API Optional**: OMG business unit lookup can fail in testing; fallback to manual entry
- **Email Delivery**: Mailgun SMTP may require firewall/DNS configuration in production
- **SSO Configuration**: Azure AD redirect_uri must exactly match registered URI (including trailing slash)
- **Box API Rate Limits**: Real-time folder validation may be slow on large hierarchies
- **No Unit Tests**: Application tested manually via web interface only

## Git
- **Remote:** git@bitbucket.org:zlalani/loreal-global-kickoff.git
- **Branch Strategy:** Single main branch (development in progress)
- **Recent Activity:** SSO/RBAC implementation (commit 53e9365), user login logging, activity dashboard enhancements

## Sessions
### 2026-04-14 – Project catalogued
**Done:** Added to Obsidian second brain.

---
## Change Log
| Date | Requested | Changed | Files |
|------|-----------|---------|-------|
| 2026-04-14 | Initial setup | Note created | — |

## Related
- [[loreal-sla-calculator/Loreal SLA Calculator]]
- [[Loreal/Loreal automation]]