Skip to content

Commit 62aef69

Browse files
committed
docs: rewrite CLAUDE.md with architecture overview
Comprehensive update to developer guidance file: - Add project overview clarifying library vs application - Consolidate commands in copyable code block - Document package structure and key components - Explain entry points, core services, and extension points - Summarize configuration namespaces - Condense code style to essential patterns
1 parent 2fbbdc2 commit 62aef69

1 file changed

Lines changed: 101 additions & 19 deletions

File tree

CLAUDE.md

Lines changed: 101 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,103 @@
1-
# Spring User Framework - Developer Guide
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+
Spring User Framework is a reusable Spring Boot library (not an application) that provides user authentication and management features built on Spring Security. It supports Spring Boot 4.0 (Java 21+) and Spring Boot 3.5 (Java 17+).
28

39
## Commands
4-
- **Build**: `./gradlew build`
5-
- **Run Tests**: `./gradlew test`
6-
- **Run Single Test**: `./gradlew test --tests "com.digitalsanctuary.spring.user.service.UserServiceTest"`
7-
- **Test with JDK17**: `./gradlew testJdk17`
8-
- **Test with JDK21**: `./gradlew testJdk21`
9-
- **Test All JDKs**: `./gradlew testAll`
10-
- **Lint/Check**: `./gradlew check`
11-
- **Publish Locally**: `./gradlew publishLocal`
12-
13-
## Code Style Guidelines
14-
- **Imports**: Organize imports alphabetically, no wildcards
15-
- **Formatting**: Use proper indentation (4 spaces)
16-
- **Documentation**: Use JavaDoc for all public classes and methods
17-
- **Naming**: CamelCase for classes, lowerCamelCase for methods/variables
18-
- **Logging**: Use SLF4J (Lombok @Slf4j) with appropriate log levels
19-
- **Error Handling**: Use specific exceptions, provide meaningful messages
20-
- **Nullability**: Check for null before accessing potentially null references
21-
- **Services**: Use @RequiredArgsConstructor with final fields for DI
10+
11+
```bash
12+
# Build
13+
./gradlew build
14+
15+
# Run tests
16+
./gradlew test
17+
18+
# Run single test
19+
./gradlew test --tests "com.digitalsanctuary.spring.user.service.UserServiceTest"
20+
21+
# Test with specific JDK
22+
./gradlew testJdk17
23+
./gradlew testJdk21
24+
25+
# Test all JDKs
26+
./gradlew testAll
27+
28+
# Lint/check
29+
./gradlew check
30+
31+
# Publish locally (for testing in consuming apps)
32+
./gradlew publishLocal
33+
```
34+
35+
## Architecture
36+
37+
### Package Structure
38+
```
39+
com.digitalsanctuary.spring.user
40+
├── api/ # REST endpoints (UserAPI)
41+
├── audit/ # Audit logging system
42+
├── controller/ # MVC controllers for HTML pages
43+
├── dto/ # Data transfer objects
44+
├── event/ # Spring application events
45+
├── exceptions/ # Custom exceptions
46+
├── listener/ # Event listeners (auth, registration)
47+
├── mail/ # Email service components
48+
├── persistence/ # JPA entities and repositories
49+
│ ├── model/ # User, Role, Privilege, tokens
50+
│ └── repository/ # Spring Data repositories
51+
├── profile/ # User profile extension framework
52+
├── roles/ # Role/privilege configuration
53+
├── security/ # Spring Security configuration
54+
├── service/ # Business logic services
55+
├── validation/ # Custom validators
56+
└── web/ # Web interceptors and config
57+
```
58+
59+
### Key Components
60+
61+
**Entry Points:**
62+
- `UserConfiguration` - Main auto-configuration class, enables async/scheduling/method security
63+
- `WebSecurityConfig` - Spring Security filter chain configuration
64+
- `UserAPI` - REST endpoints at `/user/*` (registration, password reset, profile update)
65+
66+
**Core Services:**
67+
- `UserService` - User CRUD, password management, token handling
68+
- `UserEmailService` - Verification and password reset emails
69+
- `PasswordPolicyService` - Password strength validation using Passay
70+
- `DSUserDetailsService` - Spring Security UserDetailsService implementation
71+
- `SessionInvalidationService` - Session management for security events
72+
73+
**Security:**
74+
- `DSUserDetails` - Custom UserDetails implementation wrapping User entity
75+
- `DSOAuth2UserService` / `DSOidcUserService` - OAuth2/OIDC user services
76+
- `LoginAttemptService` - Brute force protection with account lockout
77+
78+
**Extension Points:**
79+
- `BaseUserProfile` - Extend for custom user data (see PROFILE.md)
80+
- `UserProfileService<T>` - Interface for profile management
81+
- `BaseSessionProfile<T>` - Session-scoped profile access
82+
- `UserPreDeleteEvent` - Listen for user deletion to clean up related data
83+
84+
### Configuration
85+
86+
All configuration uses `user.*` prefix in application.yml. Key properties:
87+
- `user.security.*` - URIs, default action (allow/deny), bcrypt strength, lockout
88+
- `user.registration.*` - Email verification toggle
89+
- `user.mail.*` - Email sender settings
90+
- `user.audit.*` - Audit logging configuration
91+
- `user.roles.*` - Role/privilege definitions and hierarchy
92+
93+
## Code Style
94+
95+
- **Imports**: Alphabetical, no wildcards
96+
- **Indentation**: 4 spaces
97+
- **Logging**: SLF4J via Lombok `@Slf4j`
98+
- **DI**: `@RequiredArgsConstructor` with `final` fields
99+
- **Documentation**: JavaDoc on public classes/methods
100+
101+
## Testing
102+
103+
Tests use H2 in-memory database. The framework uses JUnit 5 with parallel execution enabled. Key test dependencies: Testcontainers, WireMock, GreenMail (email), AssertJ, REST Assured.

0 commit comments

Comments
 (0)