# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

Mod Comms is an AI-powered proof review tool for Barclays marketing materials. It uses multiple AI agents to analyze uploaded proofs (marketing assets) for legal compliance, brand adherence, tone of voice, and channel suitability.

## Development Commands

```bash
cd frontend
npm install        # Install dependencies
npm run dev        # Start dev server on port 3000
npm run build      # Production build
npm run preview    # Preview production build
```

## Environment Setup

Create `frontend/.env.local` with:
```
GEMINI_API_KEY=your_api_key_here
```

## Architecture

### Frontend Structure (`frontend/`)
- **App.tsx** - Main application component, handles routing between views and manages global state (campaigns, proofs, flagged/resolved/error items)
- **components/** - React components for each view and UI element
- **services/geminiService.ts** - Google Gemini AI integration for proof analysis

### Multi-Agent System
Four specialist AI agents analyze each proof:
- **Legal Agent** - Checks advertising standards, disclaimers, financial promotion detection
- **Brand Agent** - Verifies brand guidelines (logos, colors, branding)
- **Tone Agent** - Analyzes copy clarity, brand personality, grammar
- **Channel Agent** - Assesses technical suitability for digital channels

A **Lead Agent** mediates specialist feedback and determines overall RAG status:
- Green: All pass, max 1 amber issue per agent (except Legal amber triggers overall Amber)
- Amber: >1 actionable issue per agent, or any Legal amber
- Red: Failure from any agent

### Key Data Types (`types.ts`)
- `AgentReview` - Complete analysis result with all agent reviews
- `RagStatus` - 'Red' | 'Amber' | 'Green' | 'Error'
- `OverallStatus` - 'Passed' | 'Failed' | 'Analysis Error' | 'Requires Manual Legal Review'

### State Persistence
Application state persists to localStorage with `barclays_modcomms_*_v3` keys. Large preview URLs are stripped before saving to avoid quota errors.

### User Roles
- **Admin** - Full access to all campaigns, Settings, Analytics, Auditing
- **Basic User** - Limited to own agency's campaigns

## Reference Documentation

Brand and channel guidelines are in `reference_docs/`:
- `brand/` - Barclays/Barclaycard brand guidelines, tone of voice, design principles
- `channel/` - Digital and social media guidelines

Product requirements specification: `specs/Barclays_ModComms_Req_v5.md`
