Skip to content

Commit e85cc51

Browse files
author
Johannes Lichtenberger
committed
docs: add CLAUDE.md for Claude Code guidance
1 parent 58e3bb0 commit e85cc51

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

CLAUDE.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
sirix-python-client is a Python SDK for SirixDB, a temporal versioned NoSQL database. It supports both synchronous and asynchronous operations and includes a CLI shell interface.
8+
9+
## Build and Development Commands
10+
11+
```bash
12+
# Install all dependencies (runtime + dev + docs)
13+
pip install -r requirements-all.txt
14+
15+
# Install in development mode
16+
pip install -e .
17+
18+
# Run tests (requires Docker services running)
19+
python -m pytest --cov=pysirix --cov-config=.coveragerc -v -s
20+
21+
# Run a single test file
22+
python -m pytest tests/test_sirix_sync.py -v -s
23+
24+
# Run a single test
25+
python -m pytest tests/test_sirix_sync.py::test_function_name -v -s
26+
27+
# Start test infrastructure (Keycloak + SirixDB)
28+
bash test.sh
29+
30+
# Build documentation
31+
cd docs && make html
32+
```
33+
34+
## Test Infrastructure
35+
36+
Tests require Docker Compose services (Keycloak for auth, SirixDB server):
37+
- `tests/resources/docker-compose.yml` - Service definitions
38+
- Keycloak runs on port 8080
39+
- SirixDB runs on port 9443
40+
- Run `bash test.sh` to start services before running tests
41+
42+
## Architecture
43+
44+
### Dual Sync/Async Pattern
45+
The library provides identical interfaces for sync and async code:
46+
- `sirix_sync(username, password, client: httpx.Client)` → synchronous operations
47+
- `sirix_async(username, password, client: httpx.AsyncClient)` → async/await operations
48+
- Both use the same underlying `Sirix` class, which detects the client type and instantiates `SyncClient` or `AsyncClient`
49+
50+
### Three-Level Resource Hierarchy
51+
1. **Sirix** (`sirix.py`) - Server-level orchestrator: access databases, execute global queries
52+
2. **Database** (`database.py`) - Database-level: create/delete databases, access resources
53+
3. **Resource** (`resource.py`) - Resource-level: CRUD operations on JSON/XML documents
54+
55+
### Two-Tier API
56+
- **High-level**: `JsonStoreSync`/`JsonStoreAsync` (`json_store.py`) - MongoDB-like interface with `insert()`, `find()`, `update()`, `delete()`
57+
- **Low-level**: `SyncClient`/`AsyncClient` (`sync_client.py`, `async_client.py`) - Direct HTTP endpoint wrappers
58+
59+
### Key Files
60+
- `pysirix/__init__.py` - Entry points and public API exports
61+
- `pysirix/auth.py` - Keycloak OAuth2 authentication with automatic token refresh
62+
- `pysirix/errors.py` - `SirixServerError` exception and `include_response_text_in_errors()` context manager
63+
- `pysirix/types.py` - TypedDict definitions for API responses
64+
- `pysirix/constants.py` - Enums: `DBType`, `Insert`, `TimeAxisShift`
65+
66+
### CLI Shell
67+
- Entry point: `pysirix` command (configured in setup.py)
68+
- Implementation: `pysirix/shell/sirixsh.py`
69+
- Config file: `~/.pysirix-shell/config.json`
70+
71+
## Conventions
72+
73+
- Python 3.9+ required
74+
- Uses httpx (0.21-0.24) for HTTP client
75+
- Conventional commits: `feat:`, `fix:`, etc.
76+
- Test files mirror source structure: `test_sirix_sync.py`, `test_sirix_async.py`, etc.

0 commit comments

Comments
 (0)