|
| 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 | +JSON-DOC is a standardized format for storing structured content in JSON files, inspired by Notion's data model. It supports a wide variety of content types including paragraphs, headings, lists, tables, images, code blocks, and more. |
| 8 | + |
| 9 | +The project consists of: |
| 10 | +1. A JSON schema specification for the format |
| 11 | +2. A Python implementation |
| 12 | +3. A TypeScript implementation (in progress) |
| 13 | +4. Converters for various formats (HTML, Markdown, etc.) |
| 14 | + |
| 15 | +## Project Structure |
| 16 | + |
| 17 | +- `/schema/`: JSON schemas defining the structure of JSON-DOC files |
| 18 | +- `/python/`: Python implementation |
| 19 | +- `/ts/`: TypeScript implementation (in progress) |
| 20 | +- `/docs/`: Documentation |
| 21 | +- `/examples/`: Example files showing the format |
| 22 | +- `/tests/`: Tests for both implementations |
| 23 | + |
| 24 | +## Development Commands |
| 25 | + |
| 26 | +### Python Development |
| 27 | + |
| 28 | +```bash |
| 29 | +# Set up development environment |
| 30 | +cd /Users/onur/tc/JSON-DOC/python |
| 31 | +python -m pip install -e . |
| 32 | +python -m pip install -e ".[dev]" |
| 33 | + |
| 34 | +# Run tests |
| 35 | +cd /Users/onur/tc/JSON-DOC/python |
| 36 | +pytest |
| 37 | + |
| 38 | +# Run a specific test |
| 39 | +cd /Users/onur/tc/JSON-DOC/python |
| 40 | +pytest tests/test_serialization.py -v |
| 41 | + |
| 42 | +# Run validation tests |
| 43 | +cd /Users/onur/tc/JSON-DOC/python |
| 44 | +python tests/test_validation.py schema |
| 45 | + |
| 46 | +# Run linting |
| 47 | +cd /Users/onur/tc/JSON-DOC/python |
| 48 | +ruff check . |
| 49 | +ruff format . |
| 50 | +``` |
| 51 | + |
| 52 | +### TypeScript Development |
| 53 | + |
| 54 | +```bash |
| 55 | +# Set up development environment |
| 56 | +cd /Users/onur/tc/JSON-DOC/ts |
| 57 | +npm install |
| 58 | + |
| 59 | +# Build TypeScript |
| 60 | +cd /Users/onur/tc/JSON-DOC/ts |
| 61 | +npm run build |
| 62 | + |
| 63 | +# Run tests |
| 64 | +cd /Users/onur/tc/JSON-DOC/ts |
| 65 | +npm test |
| 66 | +``` |
| 67 | + |
| 68 | +## Architecture Overview |
| 69 | + |
| 70 | +### JSON-DOC Schema |
| 71 | + |
| 72 | +The JSON-DOC schema is defined in JSONSchema format, with the following primary components: |
| 73 | + |
| 74 | +1. **Page**: The top-level container for all content |
| 75 | +2. **Block**: Content blocks of various types (paragraph, heading, list item, etc.) |
| 76 | +3. **Rich Text**: Text content with formatting (bold, italic, etc.) |
| 77 | +4. **File**: External file references (images, etc.) |
| 78 | + |
| 79 | +Each block type has specific schemas and validation rules. |
| 80 | + |
| 81 | +### Python Implementation |
| 82 | + |
| 83 | +The Python implementation uses Pydantic models for validation and serialization, with: |
| 84 | + |
| 85 | +- Block types implemented as classes inheriting from a base Block class |
| 86 | +- Rich text types implemented as classes inheriting from a base RichText class |
| 87 | +- Serialization/deserialization functions for loading and saving JSON-DOC files |
| 88 | +- Converters for HTML, Markdown, and other formats |
| 89 | + |
| 90 | +Key modules: |
| 91 | +- `jsondoc.models`: Pydantic models for JSON-DOC |
| 92 | +- `jsondoc.serialize`: Functions for loading/saving JSON-DOC |
| 93 | +- `jsondoc.validate`: Schema validation |
| 94 | +- `jsondoc.convert`: Conversion between formats |
| 95 | + |
| 96 | +### TypeScript Implementation |
| 97 | + |
| 98 | +The TypeScript implementation is in progress, following similar architecture to the Python version: |
| 99 | + |
| 100 | +- Type definitions for all JSON-DOC structures |
| 101 | +- Functions for loading/saving JSON-DOC files |
| 102 | +- Schema validation |
| 103 | +- Converters for other formats |
| 104 | + |
| 105 | +## Testing Strategy |
| 106 | + |
| 107 | +- Schema validation tests ensure examples conform to schemas |
| 108 | +- Serialization tests ensure round-trip conversion preserves data |
| 109 | +- Conversion tests verify correct transformation between formats |
| 110 | +- Integration tests for end-to-end workflows |
| 111 | + |
| 112 | +## Implementation Notes |
| 113 | + |
| 114 | +1. The project follows a modular architecture with clear separation between: |
| 115 | + - Schema definition |
| 116 | + - Model implementation |
| 117 | + - Validation |
| 118 | + - Serialization |
| 119 | + - Conversion |
| 120 | + |
| 121 | +2. The TypeScript implementation should follow the same patterns as the Python implementation, with appropriate adaptations for the TypeScript ecosystem. |
| 122 | + |
| 123 | +3. The core functionality is focused on: |
| 124 | + - Loading JSON-DOC files into typed objects |
| 125 | + - Validating JSON-DOC files against schemas |
| 126 | + - Converting between JSON-DOC and other formats |
| 127 | + |
| 128 | + |
| 129 | +# Code generation guidelines |
| 130 | +- don's assume things, if some things are clear, ask for clarification |
0 commit comments