---
name: "WSJ File Naming Tool"
client: Dow Jones
status: active
server: local
tech: [PHP, JavaScript, HTML/CSS, Google Gemini API, Microsoft MSAL, CSV]
local_path: /Users/ai_leed/Documents/Projects/Oliver/wsj-filenaming
deploy: python server.py
url: 
tags: [dowjones, wsj, filenaming, gemini]
created: 2026-04-14
---

## Overview
wsj-filenaming is a web-based tool for generating standardized job names following Dow Jones' naming convention. It serves marketing and brand teams who need to create compliant filenames across multiple domains (Performance Marketing, Brand, Events, B2B). The tool features an AI-powered command bar using Google Gemini for natural language job creation, an interactive spreadsheet interface with live filename generation, dropdown validation, and Azure AD SSO authentication via MSAL.

## Tech Stack
- **Frontend:** Vanilla JavaScript, HTML5, CSS3, Google Sheets-like grid UI
- **Backend:** PHP 7.4+
- **Database:** N/A (file-based or session storage)
- **Infrastructure:** Local web server (Apache/Nginx compatible)
- **AI/ML:** Google Gemini API (command bar)
- **Authentication:** Microsoft Azure AD / MSAL 2.32.2 (SSO)
- **Key libraries:** MSAL.js (2.32.2), Google Gemini SDK

## Architecture
The application follows a client-server model:

**Frontend Layer:**
- Interactive spreadsheet grid with editable cells
- Real-time filename generation as user edits fields
- AI command bar powered by Google Gemini for natural language queries
- Voice input support (speech-to-text)
- Dropdown validation for Domain, Subteam, Brand, and Event fields
- Campaign management (save/load/export CSV)
- One-click filename copy functionality

**Backend Layer:**
- PHP scripts for server-side logic (validation, CSV export, campaign persistence)
- Azure AD / MSAL SSO authentication flow

**Data Flow:**
```
User Input (Grid/Command Bar)
    ↓
JavaScript validation + AI processing (Gemini API)
    ↓
Filename generation (client-side)
    ↓
PHP backend (export/save operations)
    ↓
Output (Grid display, CSV, clipboard)
```

**Naming Convention Logic:**
- Standard format: `[OMGID] - [Domain]-[Subteam]-[Brand]-[Initiative]-[YY]-[Sequence]_[AssetName]_v[Version]`
- Event format: `[OMGID] - EVNT-[EventAbbrev]-[YY]-[Sequence]_[AssetName]_v[Version]`
- Validation enforced via dropdown menus for all enumerated fields

## Dev Commands
```bash
# Start local development server (Apache/Nginx)
# Ensure PHP 7.4+ is running and document root points to project directory
php -S localhost:8000

# No build step required; edit files directly and reload browser

# Export/test functionality (via web interface)
# Command bar: type natural language job descriptions
# Manual grid editing: click cells and update values
```

## Deployment
- **Server:** local (intended for internal Dow Jones deployment)
- **Deploy:** N/A (self-contained PHP + JS, no build pipeline)
- **URL:** Determined by hosting setup (typically company intranet)
- **Port:** Standard web server port (80/443)
- **Service:** N/A (runs on existing web server)
- **Local path:** `/Users/ai_leed/Documents/Projects/Oliver/wsj-filenaming`

## Environment Variables
- `GEMINI_API_KEY` — Google Gemini API key for command bar AI functionality
- `AZURE_CLIENT_ID` — Azure AD application ID for MSAL SSO
- `AZURE_TENANT_ID` — Azure AD tenant ID
- `AZURE_REDIRECT_URI` — OAuth redirect URI (must match registered URI in Azure; note: trailing slash fix applied in commit b13985e)

## Known Issues
- **MSAL Authentication:** 
  - AADSTS50011 error fixed by ensuring redirect URI trailing slash matches Azure registration (commit b13985e)
  - AADSTS90014 error fixed by enabling `storeAuthStateInCookie` (commit cee80cc)
  - MSAL CDN pinned to v2.32.2 (known stable; v2.38.3 caused issues per commit 74ffaf5)
  - `msalInstance.initialize()` must be called before MSAL API calls (commit f4b4630)
- **README incomplete:** Setup section cut off mid-sentence in source file
- **No documented test suite or CI/CD pipeline**

## Git
- **Remote:** `git@bitbucket.org:zlalani/wsj-filenaming.git`
- **Recent work:** Azure AD MSAL SSO integration (commits f4b4630–523be05), Builder/Decoder page rebuild (1b2cfb8)

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