Skip to content

Commit cde7681

Browse files
febus982claude
andauthored
Maintenance PR (#311)
* Add CLAUDE.md for Claude Code guidance Provides essential commands, architecture overview, and development patterns to help Claude Code instances work effectively in this repo. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add .claudeignore file Excludes IDE files, caches, build artifacts, and lock files from Claude Code indexing to reduce noise and improve context relevance. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Misc PyCharm changes * Update README.md * Update dependencies in `uv.lock` Upgrade multiple packages to newer versions, adjust `requires-python` specification, and apply other dependency updates for maintenance. * Test only latest python version * Simplify Python test workflow by removing matrix strategy * Update remaining python 3.13 leftovers * Remove QLTY and duplicate typing * Bump up dependencies and force test engine disposal * Fix some warnings and deprecations * Format --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 64e384a commit cde7681

File tree

19 files changed

+899
-1459
lines changed

19 files changed

+899
-1459
lines changed

.claudeignore

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# IDE and editor files
2+
.idea/
3+
.vscode/
4+
*.iws
5+
*.iml
6+
7+
# Python cache and bytecode
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
.mypy_cache/
12+
.dmypy.json
13+
.pytest_cache/
14+
.hypothesis/
15+
16+
# Virtual environments
17+
.venv/
18+
venv/
19+
env/
20+
ENV/
21+
22+
# Build and distribution
23+
build/
24+
dist/
25+
*.egg-info/
26+
*.egg
27+
.eggs/
28+
29+
# Coverage reports
30+
htmlcov/
31+
.coverage
32+
.coverage.*
33+
coverage.xml
34+
35+
# Documentation build
36+
docs/_build/
37+
/site
38+
39+
# Database files
40+
*.db
41+
db.sqlite3
42+
43+
# Credentials and secrets
44+
credentials.env
45+
.env
46+
47+
# Docker volumes
48+
volumes/
49+
50+
# OS files
51+
.DS_Store
52+
Thumbs.db
53+
54+
# Lock files (large, not useful for code understanding)
55+
uv.lock
56+
57+
# Quality tools cache
58+
.qlty
59+
.tox/
60+
.nox/

.github/workflows/github-pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Checkout
2828
uses: actions/checkout@v6
2929

30-
- name: Set up Python 3.13
30+
- name: Set up Python 3.14
3131
uses: actions/setup-python@v6
3232
with:
3333
python-version: "3.14"

.github/workflows/python-code-style.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v6
20-
- name: Set up Python 3.13
20+
- name: Set up Python 3.14
2121
uses: actions/setup-python@v6
2222
with:
2323
python-version: "3.14"

.github/workflows/python-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v6
20-
- name: Set up Python 3.13
20+
- name: Set up Python 3.14
2121
uses: actions/setup-python@v6
2222
with:
2323
python-version: "3.14"

.github/workflows/python-quality.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v6
20-
- name: Set up Python 3.13
20+
- name: Set up Python 3.14
2121
uses: actions/setup-python@v6
2222
with:
2323
python-version: "3.14"
@@ -29,7 +29,3 @@ jobs:
2929
run: make dev-dependencies
3030
- name: Run coverage
3131
run: make ci-coverage
32-
- uses: qltysh/qlty-action/coverage@v2
33-
with:
34-
token: ${{secrets.QLTY_COVERAGE_TOKEN}}
35-
files: ${{github.workspace}}/coverage.lcov

.github/workflows/python-tests.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,17 @@ on:
1313

1414
jobs:
1515
test:
16-
strategy:
17-
matrix:
18-
version: ["3.10", "3.11", "3.12", "3.13"]
19-
os: [ubuntu-latest]
20-
runs-on: ${{ matrix.os }}
16+
runs-on: ubuntu-latest
2117
steps:
2218
- uses: actions/checkout@v6
23-
- name: Set up Python ${{ matrix.version }}
19+
- name: Set up Python 3.14
2420
uses: actions/setup-python@v6
2521
with:
26-
python-version: "${{ matrix.version }}"
22+
python-version: "3.14"
2723
- name: Install uv
2824
uses: astral-sh/setup-uv@v7
2925
- name: Install dependencies
3026
run: make dev-dependencies
3127
- name: Test with pytest
3228
run: |
3329
make ci-test
34-
- name: Check typing
35-
run: |
36-
make typing

.github/workflows/python-typing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v6
20-
- name: Set up Python 3.13
20+
- name: Set up Python 3.14
2121
uses: actions/setup-python@v6
2222
with:
2323
python-version: "3.14"

.idea/bootstrap-python-fastapi.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CLAUDE.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build and Development Commands
6+
7+
**Package Management (uv):**
8+
- `make dev-dependencies` - Install all dependencies including dev
9+
- `make install-dependencies` - Install production dependencies only
10+
- `make update-dependencies` - Update and sync dependencies
11+
12+
**Running Applications:**
13+
- `make dev-http` - Run HTTP application with hot reload (Docker)
14+
- `make dev-socketio` - Run Socket.io application with hot reload (Docker)
15+
- `docker compose up dramatiq-worker` - Run Dramatiq worker
16+
17+
**Testing:**
18+
- `make test` - Run full test suite with coverage (parallel execution)
19+
- `uv run pytest tests/path/to/test_file.py` - Run a single test file
20+
- `uv run pytest tests/path/to/test_file.py::test_function` - Run a specific test
21+
- `uv run pytest -k "pattern"` - Run tests matching pattern
22+
23+
**Code Quality:**
24+
- `make check` - Run all checks (lint, format, typing, test)
25+
- `make fix` - Auto-fix linting and formatting issues
26+
- `make typing` - Run mypy type checking
27+
- `make lint` - Run ruff linter
28+
- `make format` - Check code formatting
29+
30+
**Database:**
31+
- `make migrate` - Run database migrations
32+
- `make autogenerate-migration` - Generate new migration file
33+
34+
**Documentation:**
35+
- `make docs` - Serve documentation locally
36+
37+
## Architecture Overview
38+
39+
This is a Clean Architecture Python application with multiple entry points (HTTP/FastAPI, WebSocket/Socket.io, async tasks/Dramatiq).
40+
41+
### Layer Structure (`src/`)
42+
43+
```
44+
domains/ → Business logic (services, models, DTOs, events)
45+
gateways/ → External system interfaces (event gateways)
46+
http_app/ → FastAPI application and routes
47+
socketio_app/ → Socket.io application and namespaces
48+
dramatiq_worker/ → Async task worker
49+
common/ → Shared infrastructure (config, DI, storage, telemetry)
50+
migrations/ → Alembic database migrations
51+
```
52+
53+
### Dependency Injection Pattern
54+
55+
Uses `dependency-injector` library. Interface mappings are defined in `src/common/di_container.py`:
56+
57+
```python
58+
# Container maps interfaces to implementations
59+
BookRepositoryInterface: Factory[BookRepositoryInterface] = Factory(
60+
SQLAlchemyAsyncRepository,
61+
bind=SQLAlchemyBindManager.provided.get_bind.call(),
62+
model_class=BookModel,
63+
)
64+
```
65+
66+
Services use `@inject` decorator with `Provide[]`:
67+
68+
```python
69+
@inject
70+
def __init__(
71+
self,
72+
book_repository: BookRepositoryInterface = Provide[BookRepositoryInterface.__name__],
73+
)
74+
```
75+
76+
### Application Bootstrap
77+
78+
All applications share common initialization via `application_init()` in `src/common/bootstrap.py`:
79+
- Configures DI container
80+
- Initializes logging (structlog)
81+
- Sets up SQLAlchemy storage
82+
- Configures Dramatiq
83+
- Instruments OpenTelemetry
84+
85+
### Domain Structure (example: `domains/books/`)
86+
87+
- `_models.py` - SQLAlchemy models (imperative mapping)
88+
- `_service.py` - Business logic services
89+
- `_gateway_interfaces.py` - Repository/gateway protocols
90+
- `_tasks.py` - Dramatiq async tasks
91+
- `dto.py` - Pydantic DTOs for API layer
92+
- `events.py` - CloudEvents definitions
93+
- `interfaces.py` - Public domain interfaces
94+
95+
### Testing
96+
97+
Tests mirror source structure in `src/tests/`. Key patterns:
98+
- Integration tests use `TestClient` with in-memory SQLite
99+
- Unit tests mock dependencies via `AsyncMock`/`MagicMock`
100+
- 100% coverage required (`fail_under = 100` in pyproject.toml)
101+
- Storage tests in `tests/storage/` use isolated database fixtures
102+
103+
### Configuration
104+
105+
Environment-based configuration via Pydantic Settings in `src/common/config.py`. Nested configs use `__` delimiter (e.g., `DRAMATIQ__BROKER_URL`).

0 commit comments

Comments
 (0)