|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a Symfony 7.3 demo application showcasing AI integration capabilities using Symfony AI components. The application demonstrates various AI use cases including RAG (Retrieval Augmented Generation), streaming chat, multimodal interactions, and MCP (Model Context Protocol) server functionality. |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### Core Components |
| 12 | +- **Chat Systems**: Multiple specialized chat implementations in `src/` (Blog, YouTube, Wikipedia, Audio, Stream) |
| 13 | +- **Twig LiveComponents**: Interactive UI components using Symfony UX for real-time chat interfaces |
| 14 | +- **AI Agents**: Configured agents with different models, tools, and system prompts |
| 15 | +- **Vector Store**: ChromaDB integration for embedding storage and similarity search |
| 16 | +- **MCP Tools**: Model Context Protocol tools for extending agent capabilities |
| 17 | + |
| 18 | +### Key Technologies |
| 19 | +- Symfony 7.3 with UX components (LiveComponent, Turbo, Typed) |
| 20 | +- OpenAI GPT-4o-mini models and embeddings |
| 21 | +- ChromaDB vector database |
| 22 | +- FrankenPHP runtime |
| 23 | +- Docker Compose for ChromaDB service |
| 24 | + |
| 25 | +## Development Commands |
| 26 | + |
| 27 | +### Environment Setup |
| 28 | +```bash |
| 29 | +# Start ChromaDB service |
| 30 | +docker compose up -d |
| 31 | + |
| 32 | +# Install dependencies |
| 33 | +composer install |
| 34 | + |
| 35 | +# Set OpenAI API key |
| 36 | +echo "OPENAI_API_KEY='sk-...'" > .env.local |
| 37 | + |
| 38 | +# Initialize vector store |
| 39 | +symfony console app:blog:embed -vv |
| 40 | + |
| 41 | +# Test vector store |
| 42 | +symfony console app:blog:query |
| 43 | + |
| 44 | +# Start development server |
| 45 | +symfony serve -d |
| 46 | +``` |
| 47 | + |
| 48 | +### Testing |
| 49 | +```bash |
| 50 | +# Run all tests |
| 51 | +vendor/bin/phpunit |
| 52 | + |
| 53 | +# Run specific test |
| 54 | +vendor/bin/phpunit tests/SmokeTest.php |
| 55 | + |
| 56 | +# Run with coverage |
| 57 | +vendor/bin/phpunit --coverage-text |
| 58 | +``` |
| 59 | + |
| 60 | +### Code Quality |
| 61 | +```bash |
| 62 | +# Fix code style (uses PHP CS Fixer via Shim) |
| 63 | +vendor/bin/php-cs-fixer fix |
| 64 | + |
| 65 | +# Static analysis |
| 66 | +vendor/bin/phpstan analyse |
| 67 | +``` |
| 68 | + |
| 69 | +### MCP Server |
| 70 | +```bash |
| 71 | +# Start MCP server |
| 72 | +symfony console mcp:server |
| 73 | + |
| 74 | +# Test MCP server (paste in terminal) |
| 75 | +{"method":"tools/list","jsonrpc":"2.0","id":1} |
| 76 | +``` |
| 77 | + |
| 78 | +## Configuration Structure |
| 79 | + |
| 80 | +### AI Configuration (`config/packages/ai.yaml`) |
| 81 | +- **Agents**: Multiple pre-configured agents (blog, stream, youtube, wikipedia, audio) |
| 82 | +- **Platform**: OpenAI integration with API key from environment |
| 83 | +- **Store**: ChromaDB vector store for similarity search |
| 84 | +- **Indexer**: Text embedding model configuration |
| 85 | + |
| 86 | +### Chat Implementations |
| 87 | +Each chat type follows the pattern: |
| 88 | +- `Chat` class: Handles message flow and session management |
| 89 | +- `TwigComponent` class: LiveComponent for UI interaction |
| 90 | +- Agent configuration in `ai.yaml` |
| 91 | + |
| 92 | +### Session Management |
| 93 | +Chat history stored in Symfony sessions with component-specific keys (e.g., 'blog-chat', 'stream-chat'). |
| 94 | + |
| 95 | +## Development Notes |
| 96 | + |
| 97 | +- Uses PHP 8.4+ with strict typing and modern PHP features |
| 98 | +- All AI agents use OpenAI GPT-4o-mini by default |
| 99 | +- Vector embeddings use OpenAI's text-ada-002 model |
| 100 | +- ChromaDB runs on port 8080 (mapped from container port 8000) |
| 101 | +- Application follows Symfony best practices with dependency injection |
| 102 | +- LiveComponents provide real-time UI updates without custom JavaScript |
| 103 | +- MCP server enables tool integration for AI agents |
0 commit comments