Skip to content

Commit bb0f287

Browse files
nakamura-toclaude
andcommitted
Add CLAUDE.md for Claude Code guidance
Add documentation file to help Claude Code understand the Komapper quickstart project structure, build commands, and architectural patterns. This includes common Gradle tasks and explains the key concepts like entity annotations, KSP code generation, and the type-safe query DSL. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 35b03f1 commit bb0f287

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

CLAUDE.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Build and Run
8+
```bash
9+
# Run the application
10+
./gradlew run
11+
12+
# Build the project (compile and test)
13+
./gradlew build
14+
15+
# Run tests
16+
./gradlew test
17+
18+
# Run a single test class
19+
./gradlew test --tests ApplicationTest
20+
21+
# Clean build artifacts
22+
./gradlew clean
23+
24+
# Compile without running tests
25+
./gradlew assemble
26+
```
27+
28+
### Development Commands
29+
```bash
30+
# Check code (runs all verification tasks)
31+
./gradlew check
32+
33+
# Generate KSP code (happens automatically during build)
34+
./gradlew kspKotlin
35+
```
36+
37+
## Code Architecture
38+
39+
### Overview
40+
This is a Komapper quickstart project demonstrating the Komapper ORM framework for Kotlin. Komapper provides type-safe database access with compile-time code generation via KSP (Kotlin Symbol Processing).
41+
42+
### Key Architectural Patterns
43+
44+
1. **Entity Definition with Annotations**
45+
- Entities are defined as immutable data classes with Komapper annotations
46+
- `@KomapperEntity` marks a class as a database entity
47+
- `@KomapperId` with `@KomapperAutoIncrement` for primary keys
48+
- `@KomapperVersion` for optimistic locking
49+
- `@KomapperCreatedAt`/`@KomapperUpdatedAt` for automatic timestamps
50+
51+
2. **Code Generation via KSP**
52+
- KSP generates metamodel classes (e.g., `_Employee`) at compile time
53+
- Metamodels provide type-safe property references accessed via `Meta.employee`
54+
- No runtime reflection, improving performance
55+
56+
3. **Type-Safe Query DSL**
57+
- All database operations use Komapper's type-safe DSL
58+
- Queries are built using `QueryDsl` with compile-time verification
59+
- Example: `QueryDsl.from(e).where { e.name eq "John" }`
60+
61+
4. **Transaction Management**
62+
- Explicit transactions using `database.withTransaction { ... }`
63+
- All operations within the block are atomic
64+
65+
### Project Structure
66+
67+
- `src/main/kotlin/org/komapper/quickstart/`
68+
- `Application.kt` - Main entry point demonstrating Komapper usage
69+
- `Employee.kt` - Entity definition with Komapper annotations
70+
- `build/generated/ksp/` - Generated metamodel classes (created during build)
71+
- Database: Uses H2 in-memory database for the example
72+
73+
### Important Technical Details
74+
75+
- **Kotlin Version**: 2.1.21
76+
- **Komapper Version**: 5.3.0
77+
- **Target JVM**: Java 11
78+
- **KSP**: Version 2.1.21-2.0.2 with KSP2 enabled
79+
- **Testing**: JUnit 5 (Jupiter)
80+
81+
### External Documentation
82+
For detailed Komapper documentation, refer to: https://www.komapper.org/docs/quickstart/

0 commit comments

Comments
 (0)