# Lovdata Chat Development Environment This setup creates a container-per-visitor architecture for the Norwegian legal research chat interface with socket-based Docker communication. ## Quick Start 1. **Set up environment variables:** ```bash cp .env.example .env # Edit .env with your API keys and MCP server URL ``` 3. **Start the services:** ```bash docker-compose up --build ``` 4. **Create a session:** ```bash curl http://localhost/api/sessions -X POST ``` 5. **Access the chat interface:** Open the returned URL in your browser ## Architecture - **session-manager**: FastAPI service managing container lifecycles with socket-based Docker communication - **lovdata-mcp**: External Norwegian legal research MCP server (configured via MCP_SERVER env var) - **caddy**: Reverse proxy with dynamic session-based routing ## Security Features - **Socket-based Docker communication**: Direct Unix socket access for container management - **Container isolation**: Each visitor gets dedicated container with resource limits - **Automatic cleanup**: Sessions expire after 60 minutes of inactivity - **Resource quotas**: 4GB RAM, 1 CPU core per container, max 3 concurrent sessions ## Development Notes - Session data persists in ./sessions/ directory - Docker socket mounted from host for development - External MCP server configured via environment variables - Health checks ensure service reliability ## API Endpoints - `POST /api/sessions` - Create new session - `GET /api/sessions` - List all sessions - `GET /api/sessions/{id}` - Get session info - `DELETE /api/sessions/{id}` - Delete session - `POST /api/cleanup` - Manual cleanup - `GET /api/health` - Health check - `/{path}` - Dynamic proxy routing (with X-Session-ID header) ## Environment Variables ```bash # Required MCP_SERVER=http://your-lovdata-mcp-server:8001 # Optional LLM API keys OPENAI_API_KEY=your_key ANTHROPIC_API_KEY=your_key GOOGLE_API_KEY=your_key ```