|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides context for Claude Code when working in the EventRelay repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +EventRelay is an AI-powered video automation platform that transforms YouTube videos into actionable workflows. It captures transcripts, extracts events, dispatches them to MCP (Model Context Protocol) agents, and builds a RAG-based knowledge store. The backend is Python/FastAPI and the frontend is a Next.js/React/TypeScript monorepo. |
| 8 | + |
| 9 | +## Repository Structure |
| 10 | + |
| 11 | +``` |
| 12 | +src/ # Python backend |
| 13 | + youtube_extension/ |
| 14 | + backend/ # FastAPI app (api/v1/, services/, models/, middleware/) |
| 15 | + services/ # Orchestration (agents/, workflows/, ai/) |
| 16 | + mcp/ # MCP ecosystem coordinator |
| 17 | + main.py # FastAPI entry point |
| 18 | +apps/ |
| 19 | + web/ # Next.js frontend (port 3000) |
| 20 | +packages/ # Shared monorepo packages (eslint-config, tsconfig, logger, etc.) |
| 21 | +mcp-servers/ # MCP server implementations (litert-mcp, shared-state) |
| 22 | +tests/ # Python tests (unit/, integration/, fixtures/, workflows/) |
| 23 | +docs/ # Extended documentation |
| 24 | +infrastructure/ # Kubernetes manifests, Terraform, database setup |
| 25 | +.github/workflows/ # CI/CD (ci.yml, security.yml, deploy-cloud-run.yml, etc.) |
| 26 | +``` |
| 27 | + |
| 28 | +## Common Commands |
| 29 | + |
| 30 | +### Python Backend |
| 31 | + |
| 32 | +```bash |
| 33 | +# Install (editable with dev extras) |
| 34 | +pip install -e .[dev,youtube,ml] |
| 35 | + |
| 36 | +# Run backend server |
| 37 | +uvicorn src.youtube_extension.main:app --reload --port 8000 |
| 38 | + |
| 39 | +# Run tests |
| 40 | +pytest tests/ -v |
| 41 | +pytest tests/unit/ -v # Unit tests only |
| 42 | +pytest tests/ -m "not slow" # Skip slow tests |
| 43 | + |
| 44 | +# Lint and format |
| 45 | +ruff check src/ # Lint |
| 46 | +ruff check src/ --fix # Auto-fix |
| 47 | +black src/ # Format |
| 48 | +isort src/ # Sort imports |
| 49 | +mypy src/ # Type check |
| 50 | +``` |
| 51 | + |
| 52 | +### Frontend (Next.js) |
| 53 | + |
| 54 | +```bash |
| 55 | +# Install all workspace dependencies |
| 56 | +npm install |
| 57 | + |
| 58 | +# Build (all workspaces via Turbo) |
| 59 | +turbo run build |
| 60 | +# or: npm run build |
| 61 | + |
| 62 | +# Dev server |
| 63 | +turbo run dev |
| 64 | +# or: npm run dev |
| 65 | + |
| 66 | +# Lint |
| 67 | +turbo run lint |
| 68 | + |
| 69 | +# Test |
| 70 | +turbo run test |
| 71 | +``` |
| 72 | + |
| 73 | +## Code Style |
| 74 | + |
| 75 | +### Python |
| 76 | +- **Formatter**: Black, 88-char line length |
| 77 | +- **Import sorting**: isort (profile: black) |
| 78 | +- **Linter**: Ruff (E, W, F, I, B, C4, UP rules; E501 ignored) |
| 79 | +- **Type checking**: mypy strict mode (`disallow_untyped_defs = true`) |
| 80 | +- Target Python 3.9+ |
| 81 | +- Config in `pyproject.toml` |
| 82 | + |
| 83 | +### TypeScript/JavaScript |
| 84 | +- **Strict mode** TypeScript (`apps/web/tsconfig.json`) |
| 85 | +- **ESLint** with Next.js rules (shared config in `packages/eslint-config/`) |
| 86 | +- **Tailwind CSS** for styling |
| 87 | +- Path alias: `@/*` maps to `src/*` |
| 88 | + |
| 89 | +## Testing |
| 90 | + |
| 91 | +### Python (pytest) |
| 92 | +- Config: `pyproject.toml` `[tool.pytest.ini_options]` |
| 93 | +- `pythonpath = src`, `testpaths = tests` |
| 94 | +- Async mode: `asyncio_mode = "auto"` |
| 95 | +- Markers: `unit`, `integration`, `slow`, `asyncio`, `database`, `security`, `e2e`, `performance` |
| 96 | +- Coverage target: 90% minimum, source: `src/youtube_extension` |
| 97 | + |
| 98 | +### Frontend |
| 99 | +- Tests in `apps/web/src/components/__tests__/` and `apps/web/src/__tests__/` |
| 100 | + |
| 101 | +## Architecture Notes |
| 102 | + |
| 103 | +- **Event-driven**: Events follow `<domain>.<entity>.<action>` naming (e.g. `youtube.video.captured`) |
| 104 | +- **Dependency injection**: Service container pattern in `backend/containers/` |
| 105 | +- **Multi-provider AI**: Routes to Gemini, OpenAI, Anthropic, or Grok |
| 106 | +- **MCP integration**: Agent orchestration via Model Context Protocol |
| 107 | +- **Database**: SQLite (dev), PostgreSQL (prod); migrations via Alembic |
| 108 | +- **Auth**: NextAuth.js (frontend), python-jose (backend) |
| 109 | +- **Monorepo**: Turbo for JS workspaces (`apps/*`, `packages/*`, `mcp-servers/*`) |
| 110 | + |
| 111 | +## Key Policies |
| 112 | + |
| 113 | +- **REAL_MODE_ONLY**: No mock delays, fake data, or simulated responses in production code |
| 114 | +- **No secrets in code**: All keys/credentials go in `.env` (gitignored) |
| 115 | +- **Security**: Validate inputs via Pydantic; no `dangerouslySetInnerHTML` in React; sanitize subprocess args |
| 116 | +- **Type safety enforced**: mypy strict (Python), TypeScript strict (frontend) |
0 commit comments