# CLAUDE.md - Solid EDC UI Project Context

This file provides guidance to Claude Code when working with the Solid EDC UI project.

## Project Overview

**Solid EDC UI** is a comprehensive web components-based management interface for Eclipse Dataspace Connector (EDC) v3 API. It provides a professional, internationalized interface for managing Assets, Policies, and Contract Definitions in EDC dataspaces.

## Architecture

### Core Technologies
- **Lit Web Components** with TypeScript
- **lit-localize** for internationalization (EN/FR/ES)
- **TEMS Design System** with fuchsia primary colors
- **Cypress** for component testing
- **Vite** for build tooling and development server

### Component Structure
```
src/
├── components/
│   ├── edc-management-simple.ts     # Main EDC management interface
│   └── language-selector.ts         # Language switching component
├── helpers/
│   └── i18n/
│       └── configureLocalization.ts # Internationalization setup
├── generated/
│   ├── locale-codes.ts              # Auto-generated locale definitions
│   └── locales/                     # Translation files (en.ts, fr.ts, es.ts)
└── styles/
    └── tems-variables.css           # TEMS design system variables
```

## Key Components

### 1. EDC Management Simple (`edc-management-simple.ts`)
- **Purpose**: Main management interface with full-page sidebar layout
- **Features**:
  - Professional vertical sidebar navigation
  - Complete Assets CRUD operations (create, read, update, delete)
  - Complete ODRL Policies CRUD with advanced constraint editor
  - Connection configuration display
  - Search, sort, and filter functionality
  - Loading states and error handling

### 2. Language Selector (`language-selector.ts`)
- **Purpose**: Runtime language switching component
- **Features**:
  - EN/FR/ES support with flag emojis
  - localStorage persistence
  - Event-driven locale switching without page reloads
  - Accessible keyboard navigation

## Design System

### TEMS Integration
- **Layout**: Full-page design with left sidebar navigation
- **Colors**: Fuchsia primary (#d946ef), proper gray scales
- **Typography**: Consistent spacing and modern font system
- **Responsive**: Mobile-friendly with proper breakpoints

### CSS Architecture
- CSS custom properties from `tems-variables.css`
- Shadow DOM styling within components
- Consistent spacing using TEMS grid system

## Internationalization (i18n)

### Setup
- **Framework**: lit-localize with XLIFF format
- **Languages**: English (default), French, Spanish
- **Implementation**: All UI strings use `msg()` function calls
- **Build Process**: `npm run locale:extract` → `npm run locale:build`

### Translation Guidelines
- **Policy terminology**: "Policy" → "Règle" (French), "Regla" (Spanish)
- **Consistency**: All buttons, labels, messages, and tooltips translated
- **Context**: Translation IDs include context hints for translators

## EDC Integration

### Store Architecture
- **DataspaceConnectorStore**: Main store for EDC API interactions
- **Endpoints**: Full CRUD operations for Assets, Policies, Contract Definitions
- **Authentication**: Configurable API key authentication
- **Error Handling**: Comprehensive error states and user feedback

### EDC Types
```typescript
interface Asset {
  '@type': 'Asset';
  '@id': string;
  '@context'?: any;
  properties?: Record<string, any>;
  dataAddress?: DataAddress;
}

interface PolicyDefinition {
  '@type': 'PolicyDefinition';
  '@id': string;
  '@context': any;
  policy: Policy;
}
```

## Development Workflow

### Commands
- `npm run dev` - Start development server (localhost:5175)
- `npm run build` - Build for production
- `npm run watch` - Build with watch mode
- `npm run cy:run` - Run Cypress component tests
- `npm run cy:open` - Open Cypress test runner
- `npm run locale:extract` - Extract translation strings
- `npm run locale:build` - Build translation files

### File Structure Conventions
- Components use `@customElement` decorator
- Path aliases configured: `@helpers`, `@components`, `@styles`, `@src`
- TypeScript with strict mode enabled
- CSS-in-JS using Lit's `css` template literal

## Testing

### Test Files
- `cypress/component/edc-management-simple.cy.ts` - Main component tests
- `cypress/component/language-selector.cy.ts` - Language selector tests
- `cypress/component/edc-management-interface.cy.ts` - Legacy (disabled)

### Testing Patterns
- Shadow DOM testing with `cy.get().shadow().find()`
- Event testing for custom events
- Accessibility testing for keyboard navigation
- Form validation and error state testing

## Current Status (2025-10-08)

### ✅ Completed Features
1. **Phase 1-2**: DataspaceConnectorStore CRUD methods and type definitions
2. **Phase 3**: Full-page sidebar layout with TEMS design system
3. **Phase 4**: Complete Assets management with professional UI
4. **Phase 5**: Complete ODRL Policies management with constraint editor
5. **i18n**: Full internationalization with EN/FR/ES support
6. **Testing**: Comprehensive test coverage for all components
7. **Architecture**: Clean component structure with proper imports

### 🎯 Next Phases
- **Phase 6**: Contract Definitions management tab
- **Phase 7**: Complete demo integration and optimization

## Code Patterns

### Component Declaration
```typescript
@customElement("component-name")
export class ComponentName extends LitElement {
  @property() myProperty: string = '';

  render() {
    return html`<div>${msg('Hello', { id: 'hello' })}</div>`;
  }
}
```

### Internationalization
```typescript
import { msg } from '@lit/localize';

// In templates
html`<button>${msg('Create Asset', { id: 'createasset' })}</button>`
```

### TEMS Styling
```typescript
static styles = css`
  .container {
    padding: var(--tems-space-4);
    background: var(--tems-color-background);
    color: var(--tems-color-primary-600);
  }
`;
```

## Important Notes

### Import Patterns
- Use path aliases: `@helpers/i18n/configureLocalization`
- Component imports: `./components/component-name.js` (in tests)
- No file extensions in TypeScript imports (handled by bundler)

### Event Handling
- Custom events should be `bubbles: true, composed: true`
- Use proper TypeScript event typing
- Handle both mouse and keyboard interactions

### Error Handling
- Always provide user feedback for async operations
- Use loading states during API calls
- Graceful degradation for network failures

## Debugging Tips

### Common Issues
1. **Import Resolution**: Check path aliases in `vite.config.ts` and `tsconfig.json`
2. **Translation Missing**: Run `npm run locale:extract` then `npm run locale:build`
3. **Component Not Rendering**: Verify `@customElement` decorator and proper imports
4. **Test Failures**: Ensure shadow DOM access and proper component mounting

### Development Server
- Hot reload enabled for TypeScript and CSS changes
- Translation files require rebuild to see changes
- Component registration happens automatically via decorators

---

**Last Updated**: 2025-10-08
**Project Status**: Production-ready Assets and Policies management with full i18n support
**Next Priority**: Contract Definitions implementation for complete EDC management suite