π― Learning Objectives
By the end of this module, you will:
- Generate comprehensive project documentation using
@170-java-documentation
- Create professional UML diagrams using
@171-java-diagrams
- Master documentation-driven development practices
- Apply modular, step-based documentation approaches
- Create maintainable, professional documentation that scales with projects
π Module Overview
Duration: 3 hours
Difficulty: Intermediate
Prerequisites: Module 5 completed, basic documentation awareness
This module focuses on creating professional, comprehensive documentation that enhances project maintainability and team collaboration. You'll learn to use AI-powered tools that generate documentation and diagrams automatically while following industry best practices.
πΊοΈ Learning Path
Lesson 6.1: Technical Documentation Generation (105 minutes)
π― Learning Objectives:
- Generate complete project documentation using
@170-java-documentation
- Create README.md, package-info.java, and Javadoc
- Apply modular documentation strategies
π Core Concepts:
Professional Documentation Components:
- README.md: Project overview and quick start
- README-DEV.md: Developer-focused documentation
- package-info.java: Package-level documentation
- Javadoc: API documentation
- Architecture Documentation: High-level system design
π‘ Knowledge Check:
What's the difference between user documentation and developer documentation?
Answer: User documentation focuses on how to use the software (features, workflows), while developer documentation focuses on how to build, modify, and maintain the software (APIs, architecture, setup).
π§ Hands-on Exercise 6.1:
Scenario: Generate comprehensive documentation for a Spring Boot project.
Step 1: Analyze Existing Project
cd examples/spring-boot-demo
Step 2: Interactive Documentation Generation
Use: Generate technical documentation about the project with the cursor rule @170-java-documentation
Step 3: Specific Documentation Type
Try: Generate README.md with @170-java-documentation without any question
Expected Generated Documentation Structure:
README.md:
# Spring Boot Demo Application
## Overview
A comprehensive Spring Boot demonstration application showcasing enterprise-grade development practices including REST APIs, data persistence, security, and testing.
## Features
- RESTful API endpoints for user management
- JPA-based data persistence with H2 database
- Spring Security integration
- Comprehensive test coverage
- Docker support for containerization
## Quick Start
### Prerequisites
- Java 21 or higher
- Maven 3.8+
- Docker (optional)
### Running the Application
```bash
# Clone the repository
git clone <repository-url>
cd spring-boot-demo
# Run with Maven
./mvnw spring-boot:run
# Or build and run JAR
./mvnw clean package
java -jar target/spring-boot-demo-*.jar
API Documentation
The application exposes REST endpoints at http://localhost:8080
:
GET /api/users
- List all usersPOST /api/users
- Create new userGET /api/users/{id}
- Get user by IDPUT /api/users/{id}
- Update userDELETE /api/users/{id}
- Delete user
Configuration
Key configuration properties in application.yml
:
server:
port: 8080
spring:
datasource:
url: jdbc:h2:mem:testdb
jpa:
hibernate:
ddl-auto: create-drop
Testing
# Run all tests
./mvnw test
# Run integration tests
./mvnw verify
# Generate test coverage report
./mvnw jacoco:report
Contributing
See CONTRIBUTING.md for development guidelines.
**README-DEV.md:**
```markdown
# Developer Documentation - Spring Boot Demo
## Development Environment Setup
### Required Tools
- **Java**: OpenJDK 21+ (recommended: Eclipse Temurin)
- **Maven**: 3.8+ (wrapper included)
- **IDE**: IntelliJ IDEA or Eclipse with Spring Boot plugin
- **Database**: H2 (embedded) or PostgreSQL for production
### Project Structure
spring-boot-demo/
βββ src/main/java/com/example/demo/
β βββ DemoApplication.java # Main application class
β βββ controller/ # REST controllers
β βββ service/ # Business logic
β βββ repository/ # Data access layer
β βββ model/ # Domain entities
β βββ config/ # Configuration classes
βββ src/main/resources/
β βββ application.yml # Main configuration
β βββ db/migration/ # Database migrations
βββ src/test/java/ # Test classes
## Build Commands
### Essential Maven Commands
```bash
# Clean and compile
./mvnw clean compile
# Run tests with coverage
./mvnw clean test jacoco:report
# Package application
./mvnw clean package
# Run application locally
./mvnw spring-boot:run
# Run with specific profile
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev
Quality Checks
# Run static analysis
./mvnw spotbugs:check
# Check code style
./mvnw checkstyle:check
# Dependency vulnerability check
./mvnw dependency-check:check
Database Management
H2 Console (Development)
- URL: http://localhost:8080/h2-console
- JDBC URL: jdbc:h2:mem:testdb
- Username: sa
- Password: (empty)
Migration Scripts
Database migrations are located in src/main/resources/db/migration/
:
- V1__Create_users_table.sql
- V2__Add_user_roles.sql
Testing Strategy
Test Categories
- Unit Tests:
*Test.java
- Fast, isolated tests - Integration Tests:
*IT.java
- Component integration - End-to-End Tests:
*E2ETest.java
- Full application flow
Test Data
- Test fixtures in
src/test/resources/fixtures/
- TestContainers for integration testing
- MockMvc for web layer testing
Deployment
Docker
# Build image
docker build -t spring-boot-demo .
# Run container
docker run -p 8080:8080 spring-boot-demo
Production Considerations
- Use PostgreSQL instead of H2
- Configure proper logging levels
- Set up health checks and metrics
- Configure SSL/TLS certificates
**package-info.java Files:**
```java
/**
* Spring Boot Demo Application - Controller Layer
*
* <p>This package contains REST controllers that handle HTTP requests
* and provide JSON responses. All controllers follow RESTful conventions
* and include comprehensive error handling.
*
* <h2>Key Controllers:</h2>
* <ul>
* <li>{@link com.example.demo.controller.UserController} - User management operations</li>
* <li>{@link com.example.demo.controller.HealthController} - Health check endpoints</li>
* </ul>
*
* <h2>Error Handling:</h2>
* Global exception handling is provided by {@link com.example.demo.controller.GlobalExceptionHandler}
* which ensures consistent error response format across all endpoints.
*
* @author Development Team
* @version 1.0
* @since 1.0
*/
package com.example.demo.controller;
π Documentation Benefits:
- Consistency: Standardized format across projects
- Completeness: Covers all essential aspects
- Maintainability: Easy to update and extend
- Onboarding: New team members can start quickly
- Professional: Industry-standard documentation quality
Lesson 6.2: UML Diagram Generation (75 minutes)
π― Learning Objectives:
- Create comprehensive UML diagrams using
@171-java-diagrams
- Generate class, sequence, and state diagrams
- Apply C4 model for architecture documentation
π Core Concepts:
Diagram Types:
- UML Class Diagrams: Static structure relationships
- UML Sequence Diagrams: Interaction flows
- UML State Machine Diagrams: State transitions
- C4 Model Diagrams: Architecture at different levels
π§ Hands-on Exercise 6.2:
Step 1: Interactive Diagram Generation
Use: Generate diagrams about the project with the cursor rule @171-java-diagrams
Step 2: Specific Diagram Type
Try: Create UML class diagrams with @171-java-diagrams without any question
Expected Generated Diagrams:
1. UML Class Diagram (PlantUML):
@startuml
!define RECTANGLE class
RECTANGLE User {
-Long id
-String username
-String email
-String password
-LocalDateTime createdAt
-LocalDateTime updatedAt
+getId(): Long
+getUsername(): String
+getEmail(): String
+setUsername(String): void
+setEmail(String): void
}
RECTANGLE UserController {
-UserService userService
+getAllUsers(): ResponseEntity<List<User>>
+getUserById(Long): ResponseEntity<User>
+createUser(User): ResponseEntity<User>
+updateUser(Long, User): ResponseEntity<User>
+deleteUser(Long): ResponseEntity<Void>
}
RECTANGLE UserService {
-UserRepository userRepository
-PasswordEncoder passwordEncoder
+findAll(): List<User>
+findById(Long): Optional<User>
+save(User): User
+update(Long, User): User
+deleteById(Long): void
}
RECTANGLE UserRepository {
+findAll(): List<User>
+findById(Long): Optional<User>
+save(User): User
+deleteById(Long): void
+findByUsername(String): Optional<User>
+findByEmail(String): Optional<User>
}
UserController --> UserService : uses
UserService --> UserRepository : uses
UserService --> User : manages
UserRepository --> User : persists
@enduml
2. UML Sequence Diagram:
@startuml
actor Client
participant UserController
participant UserService
participant UserRepository
database Database
Client -> UserController: POST /api/users
activate UserController
UserController -> UserService: save(user)
activate UserService
UserService -> UserService: validateUser(user)
UserService -> UserService: encodePassword(user)
UserService -> UserRepository: save(user)
activate UserRepository
UserRepository -> Database: INSERT INTO users
activate Database
Database --> UserRepository: user_id
deactivate Database
UserRepository --> UserService: saved_user
deactivate UserRepository
UserService --> UserController: saved_user
deactivate UserService
UserController --> Client: 201 Created + user_data
deactivate UserController
@enduml
3. C4 Context Diagram:
@startuml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
Person(user, "User", "Application user")
System(demo_app, "Spring Boot Demo", "Manages users and provides REST API")
System_Ext(database, "Database", "Stores user data")
System_Ext(email_service, "Email Service", "Sends notifications")
Rel(user, demo_app, "Uses", "HTTPS")
Rel(demo_app, database, "Reads/Writes", "JPA/Hibernate")
Rel(demo_app, email_service, "Sends emails", "SMTP")
@enduml
π‘ Diagram Generation Workflow:
Step 1: Generate PlantUML Files
The system prompt creates .puml
files in docs/diagrams/
Step 2: Convert to Images (Optional)
# Install PlantUML to PNG converter
jbang puml-to-png@jabrena --watch .
# Or use online converter
# Copy .puml content to http://www.plantuml.com/plantuml/
Step 3: Include in Documentation
## Architecture Overview
### System Context

### Class Structure

### User Creation Flow

π Module Assessment
Knowledge Validation Checkpoint
Question 1: What are the key components of professional project documentation?
Question 2: When should you use sequence diagrams vs. class diagrams?
Question 3: How does the C4 model help with architecture documentation?
Question 4: What's the purpose of package-info.java files?
Practical Assessment Project
Project: "Complete Documentation Suite"
Scenario: Create comprehensive documentation for a Java microservice project.
Requirements:
1. Generate complete project documentation using system prompts
2. Create UML diagrams covering all architectural aspects
3. Ensure documentation follows professional standards
4. Include both user and developer documentation
5. Validate documentation completeness and accuracy
Deliverables:
- Complete README.md and README-DEV.md files
- Package-level documentation with package-info.java
- Comprehensive Javadoc for all public APIs
- UML class, sequence, and architecture diagrams
- Documentation maintenance guidelines
Success Criteria:
- Documentation covers all project aspects
- Diagrams accurately represent system architecture
- Professional formatting and structure
- Easy onboarding for new team members
- Maintainable and updatable documentation
Time Investment:
- Documentation Generation: 1.5 hours
- Diagram Creation: 1 hour
- Review and Refinement: 1 hour
- Validation: 30 minutes
- Total: 4 hours
π Next Steps
Excellent Work! You've mastered professional documentation and diagram generation.
What You've Accomplished:
- β
Generated comprehensive project documentation
- β
Created professional UML diagrams
- β
Applied modular documentation strategies
- β
Established maintainable documentation practices
Ready for the final advanced module?
π Continue to Module 7: Advanced Patterns β
In Module 7, you'll learn to:
- Create custom system prompts
- Apply progressive learning behaviors
- Design educational content from technical prompts
- Master advanced AI-powered development workflows
π Additional Resources
Complete your journey with advanced system prompt creation and educational content generation.