This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Package Management (uv):
make dev-dependencies- Install all dependencies including devmake install-dependencies- Install production dependencies onlymake update-dependencies- Update and sync dependencies
Running Applications:
make dev-http- Run HTTP application with hot reload (Docker)make dev-socketio- Run Socket.io application with hot reload (Docker)docker compose up dramatiq-worker- Run Dramatiq worker
Testing:
make test- Run full test suite with coverage (parallel execution)uv run pytest tests/path/to/test_file.py- Run a single test fileuv run pytest tests/path/to/test_file.py::test_function- Run a specific testuv run pytest -k "pattern"- Run tests matching pattern
Code Quality:
make check- Run all checks (lint, format, typing, test)make fix- Auto-fix linting and formatting issuesmake typing- Run mypy type checkingmake lint- Run ruff lintermake format- Check code formatting
Database:
make migrate- Run database migrationsmake autogenerate-migration- Generate new migration file
Documentation:
make docs- Serve documentation locally
This is a Clean Architecture Python application with multiple entry points (HTTP/FastAPI, WebSocket/Socket.io, async tasks/Dramatiq).
domains/ → Business logic (services, models, DTOs, events)
gateways/ → External system interfaces (event gateways)
http_app/ → FastAPI application and routes
socketio_app/ → Socket.io application and namespaces
dramatiq_worker/ → Async task worker
common/ → Shared infrastructure (config, DI, storage, telemetry)
migrations/ → Alembic database migrations
Uses dependency-injector library. Interface mappings are defined in src/common/di_container.py:
# Container maps interfaces to implementations
BookRepositoryInterface: Factory[BookRepositoryInterface] = Factory(
SQLAlchemyAsyncRepository,
bind=SQLAlchemyBindManager.provided.get_bind.call(),
model_class=BookModel,
)Services use @inject decorator with Provide[]:
@inject
def __init__(
self,
book_repository: BookRepositoryInterface = Provide[BookRepositoryInterface.__name__],
)All applications share common initialization via application_init() in src/common/bootstrap.py:
- Configures DI container
- Initializes logging (structlog)
- Sets up SQLAlchemy storage
- Configures Dramatiq
- Instruments OpenTelemetry
_models.py- SQLAlchemy models (imperative mapping)_service.py- Business logic services_gateway_interfaces.py- Repository/gateway protocols_tasks.py- Dramatiq async tasksdto.py- Pydantic DTOs for API layerevents.py- CloudEvents definitionsinterfaces.py- Public domain interfaces
Tests mirror source structure in src/tests/. Key patterns:
- Integration tests use
TestClientwith in-memory SQLite - Unit tests mock dependencies via
AsyncMock/MagicMock - 100% coverage required (
fail_under = 100in pyproject.toml) - Storage tests in
tests/storage/use isolated database fixtures
Environment-based configuration via Pydantic Settings in src/common/config.py. Nested configs use __ delimiter (e.g., DRAMATIQ__BROKER_URL).