---
name: analyze-structure
description: Analyze Java project structure, package hierarchy, and code organization. Use when user wants to understand project architecture, identify modules, or map code organization.
version: 1.0.0
---
# Java Project Structure Analysis
This skill analyzes Java project structure and organization.
## When to Use
- User wants to understand project architecture
- User needs to identify modules and packages
- User wants to map code organization
- User needs to find specific code components
## Analysis Steps
### 1. Package Hierarchy
Map the package structure:
```bash
# Get all packages
find
-name "*.java" -o -name "*.class" | \
sed 's|/[^/]*\.\(java\|class\)$||' | \
sort -u | \
sed 's|/|.|g'
```
### 2. Module Identification
Identify logical modules:
| Pattern | Likely Module |
|---------|---------------|
| `*.domain` | Data models/entities |
| `*.dao` | Data access layer |
| `*.service` | Business logic |
| `*.action` | Web controllers (Struts) |
| `*.util` | Utility classes |
| `*.common` | Shared components |
| `*.framework` | Framework code |
### 3. Class Distribution
Count classes per package:
```bash
find -name "*.java" | \
sed 's|/[^/]*\.java$||' | \
sort | uniq -c | sort -rn
```
### 4. Architecture Layers
Identify architecture patterns:
```
Presentation Layer
├── Actions (Struts)
├── Controllers (Spring MVC)
└── View (JSP/HTML)
Business Layer
├── Services
├── Service Implementations
└── Business Logic
Data Access Layer
├── DAOs
├── DAO Implementations
└── ORM (iBatis/Hibernate)
Domain Layer
├── Domain Objects
├── Value Objects
└── Entities
```
### 5. Dependency Flow
Analyze package dependencies:
```bash
# Find imports in each file
grep -r "^import" | \
sed 's|:.*import |: |' | \
sed 's|;||'
```
## Structure Report
Generate a structure report:
```bash
# Run the analysis script
bash C:/Users/K/.claude/plugins/cache/claude-plugins-official/plugin-dev/9eae436aa296/scripts/analyze-deps.sh
```
## Common Patterns
### Enterprise Java (EJB/J2EE)
```
com.company.project
├── ejb/ # Enterprise beans
├── web/ # Web components
├── common/ # Shared code
└── util/ # Utilities
```
### Spring Application
```
com.company.project
├── controller/ # Spring MVC controllers
├── service/ # Service interfaces
├── service/impl/ # Service implementations
├── repository/ # Data repositories
├── model/ # Domain models
└── config/ # Configuration
```
### Struts Application
```
com.company.project
├── action/ # Struts actions
├── form/ # Action forms
├── bo/ # Business objects
├── dao/ # Data access
└── domain/ # Domain objects
```
## Output Format
The analysis should produce:
1. **Package Map**: Visual hierarchy of packages
2. **Module List**: Identified modules with descriptions
3. **Class Count**: Statistics per package
4. **Dependency Graph**: Package dependencies
5. **Architecture Diagram**: Layer structure
## Integration
After structure analysis:
1. Use `generate-project` to create build structure
2. Use `understand-code` to dive into specific modules
3. Use `analyze-dependencies` for detailed dependency mapping